Local<Value> AccessorInfo::Data() const {
- return Local<Value>(reinterpret_cast<Value*>(&args_[-3]));
+ return Local<Value>(reinterpret_cast<Value*>(&args_[-2]));
}
};
-// Cursom arguments replicate a small segment of stack that can be
+// Custom arguments replicate a small segment of stack that can be
// accessed through an Arguments object the same way the actual stack
// can.
class CustomArguments : public Relocatable {
inline CustomArguments(Object* data,
JSObject* self,
JSObject* holder) {
- values_[3] = self;
- values_[2] = holder;
- values_[1] = Smi::FromInt(0);
+ values_[2] = self;
+ values_[1] = holder;
values_[0] = data;
}
void IterateInstance(ObjectVisitor* v);
- Object** end() { return values_ + 3; }
+ Object** end() { return values_ + ARRAY_SIZE(values_) - 1; }
private:
- Object* values_[4];
+ Object* values_[3];
};
Register holder,
Register name,
JSObject* holder_obj) {
- __ push(receiver);
- __ push(holder);
__ push(name);
InterceptorInfo* interceptor = holder_obj->GetNamedInterceptor();
ASSERT(!Heap::InNewSpace(interceptor));
-
- Register scratch = receiver;
+ Register scratch = name;
__ mov(scratch, Operand(Handle<Object>(interceptor)));
__ push(scratch);
+ __ push(receiver);
+ __ push(holder);
__ ldr(scratch, FieldMemOperand(scratch, InterceptorInfo::kDataOffset));
__ push(scratch);
}
virtual bool GetCustomCache(Code** code_out);
virtual void SetCustomCache(Code* value);
- static const int kStackSpace = 6;
+ static const int kStackSpace = 5;
static const int kArgc = 4;
private:
Handle<AccessorInfo> info() { return info_; }
void CustomArguments::IterateInstance(ObjectVisitor* v) {
- v->VisitPointers(values_, values_ + 4);
+ v->VisitPointers(values_, values_ + ARRAY_SIZE(values_));
}
Register holder,
Register name,
JSObject* holder_obj) {
- __ push(receiver);
- __ push(holder);
__ push(name);
InterceptorInfo* interceptor = holder_obj->GetNamedInterceptor();
ASSERT(!Heap::InNewSpace(interceptor));
- __ mov(receiver, Immediate(Handle<Object>(interceptor)));
+ Register scratch = name;
+ __ mov(scratch, Immediate(Handle<Object>(interceptor)));
+ __ push(scratch);
__ push(receiver);
- __ push(FieldOperand(receiver, InterceptorInfo::kDataOffset));
+ __ push(holder);
+ __ push(FieldOperand(scratch, InterceptorInfo::kDataOffset));
}
__ push(receiver); // receiver
__ push(reg); // holder
__ mov(other, Immediate(callback_handle));
- __ push(other);
__ push(FieldOperand(other, AccessorInfo::kDataOffset)); // data
__ push(name_reg); // name
// Save a pointer to where we pushed the arguments pointer.
- // This will be passed as the const Arguments& to the C++ callback.
+ // This will be passed as the const AccessorInfo& to the C++ callback.
__ mov(eax, esp);
- __ add(Operand(eax), Immediate(5 * kPointerSize));
+ __ add(Operand(eax), Immediate(4 * kPointerSize));
__ mov(ebx, esp);
// Do call through the api.
- ASSERT_EQ(6, ApiGetterEntryStub::kStackSpace);
+ ASSERT_EQ(5, ApiGetterEntryStub::kStackSpace);
Address getter_address = v8::ToCData<Address>(callback->getter());
ApiFunction fun(getter_address);
ApiGetterEntryStub stub(callback_handle, &fun);
return *value;
}
+
+static const int kAccessorInfoOffsetInInterceptorArgs = 2;
+
+
/**
* Attempts to load a property with an interceptor (which must be present),
* but doesn't search the prototype chain.
* provide any value for the given name.
*/
Object* LoadPropertyWithInterceptorOnly(Arguments args) {
- JSObject* receiver_handle = JSObject::cast(args[0]);
- JSObject* holder_handle = JSObject::cast(args[1]);
- Handle<String> name_handle = args.at<String>(2);
- Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(3);
- Object* data_handle = args[4];
+ Handle<String> name_handle = args.at<String>(0);
+ Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>(1);
+ ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2);
+ ASSERT(args[2]->IsJSObject()); // Receiver.
+ ASSERT(args[3]->IsJSObject()); // Holder.
+ ASSERT(args.length() == 5); // Last arg is data object.
Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
v8::NamedPropertyGetter getter =
{
// Use the interceptor getter.
- CustomArguments args(data_handle, receiver_handle, holder_handle);
- v8::AccessorInfo info(args.end());
+ v8::AccessorInfo info(args.arguments() -
+ kAccessorInfoOffsetInInterceptorArgs);
HandleScope scope;
v8::Handle<v8::Value> r;
{
static Object* LoadWithInterceptor(Arguments* args,
PropertyAttributes* attrs) {
- Handle<JSObject> receiver_handle = args->at<JSObject>(0);
- Handle<JSObject> holder_handle = args->at<JSObject>(1);
- Handle<String> name_handle = args->at<String>(2);
- Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(3);
- Handle<Object> data_handle = args->at<Object>(4);
+ Handle<String> name_handle = args->at<String>(0);
+ Handle<InterceptorInfo> interceptor_info = args->at<InterceptorInfo>(1);
+ ASSERT(kAccessorInfoOffsetInInterceptorArgs == 2);
+ Handle<JSObject> receiver_handle = args->at<JSObject>(2);
+ Handle<JSObject> holder_handle = args->at<JSObject>(3);
+ ASSERT(args->length() == 5); // Last arg is data object.
Address getter_address = v8::ToCData<Address>(interceptor_info->getter());
v8::NamedPropertyGetter getter =
{
// Use the interceptor getter.
- CustomArguments args(*data_handle, *receiver_handle, *holder_handle);
- v8::AccessorInfo info(args.end());
+ v8::AccessorInfo info(args->arguments() -
+ kAccessorInfoOffsetInInterceptorArgs);
HandleScope scope;
v8::Handle<v8::Value> r;
{
// If the property is present, return it.
if (attr != ABSENT) return result;
- return ThrowReferenceError(String::cast(args[2]));
+ return ThrowReferenceError(String::cast(args[0]));
}
Register holder,
Register name,
JSObject* holder_obj) {
- __ push(receiver);
- __ push(holder);
__ push(name);
InterceptorInfo* interceptor = holder_obj->GetNamedInterceptor();
ASSERT(!Heap::InNewSpace(interceptor));
- __ movq(kScratchRegister, Handle<Object>(interceptor),
- RelocInfo::EMBEDDED_OBJECT);
+ __ Move(kScratchRegister, Handle<Object>(interceptor));
__ push(kScratchRegister);
+ __ push(receiver);
+ __ push(holder);
__ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset));
}
}
+static int interceptor_load_not_handled_calls = 0;
+static v8::Handle<Value> InterceptorLoadNotHandled(Local<String> name,
+ const AccessorInfo& info) {
+ ++interceptor_load_not_handled_calls;
+ return v8::Handle<v8::Value>();
+}
+
+
+// Test how post-interceptor lookups are done in the non-cacheable
+// case: the interceptor should not be invoked during this lookup.
+THREADED_TEST(InterceptorLoadICPostInterceptor) {
+ interceptor_load_not_handled_calls = 0;
+ CheckInterceptorLoadIC(InterceptorLoadNotHandled,
+ "receiver = new Object();"
+ "receiver.__proto__ = o;"
+ "proto = new Object();"
+ "/* Make proto a slow-case object. */"
+ "for (var i = 0; i < 1000; i++) {"
+ " proto[\"xxxxxxxx\" + i] = [];"
+ "}"
+ "proto.x = 17;"
+ "o.__proto__ = proto;"
+ "var result = 0;"
+ "for (var i = 0; i < 1000; i++) {"
+ " result += receiver.x;"
+ "}"
+ "result;",
+ 17 * 1000);
+ CHECK_EQ(1000, interceptor_load_not_handled_calls);
+}
+
+
// Test the case when we stored field into
// a stub, but it got invalidated later on due to override on
// global object which is between interceptor and fields' holders.