Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: src/objects.cc

Issue 10442129: Implement implicit instance checks for API accessors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 reinterpret_cast<AccessorDescriptor*>( 171 reinterpret_cast<AccessorDescriptor*>(
172 Foreign::cast(structure)->foreign_address()); 172 Foreign::cast(structure)->foreign_address());
173 MaybeObject* value = (callback->getter)(receiver, callback->data); 173 MaybeObject* value = (callback->getter)(receiver, callback->data);
174 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 174 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
175 return value; 175 return value;
176 } 176 }
177 177
178 // api style callbacks. 178 // api style callbacks.
179 if (structure->IsAccessorInfo()) { 179 if (structure->IsAccessorInfo()) {
180 AccessorInfo* data = AccessorInfo::cast(structure); 180 AccessorInfo* data = AccessorInfo::cast(structure);
181 if (!data->IsCompatibleReceiver(receiver)) {
182 Handle<Object> name_handle(name);
183 Handle<Object> receiver_handle(receiver);
184 Handle<Object> args[2] = { name_handle, receiver_handle };
185 Handle<Object> error =
186 isolate->factory()->NewTypeError("incompatible_method_receiver",
187 HandleVector(args, 2));
188 return isolate->Throw(*error);
189 }
181 Object* fun_obj = data->getter(); 190 Object* fun_obj = data->getter();
182 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); 191 v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj);
183 HandleScope scope(isolate); 192 HandleScope scope(isolate);
184 JSObject* self = JSObject::cast(receiver); 193 JSObject* self = JSObject::cast(receiver);
185 Handle<String> key(name); 194 Handle<String> key(name);
186 LOG(isolate, ApiNamedPropertyAccess("load", self, name)); 195 LOG(isolate, ApiNamedPropertyAccess("load", self, name));
187 CustomArguments args(isolate, data->data(), self, this); 196 CustomArguments args(isolate, data->data(), self, this);
188 v8::AccessorInfo info(args.end()); 197 v8::AccessorInfo info(args.end());
189 v8::Handle<v8::Value> result; 198 v8::Handle<v8::Value> result;
190 { 199 {
(...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 Foreign::cast(structure)->foreign_address()); 1986 Foreign::cast(structure)->foreign_address());
1978 MaybeObject* obj = (callback->setter)(this, value, callback->data); 1987 MaybeObject* obj = (callback->setter)(this, value, callback->data);
1979 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 1988 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1980 if (obj->IsFailure()) return obj; 1989 if (obj->IsFailure()) return obj;
1981 return *value_handle; 1990 return *value_handle;
1982 } 1991 }
1983 1992
1984 if (structure->IsAccessorInfo()) { 1993 if (structure->IsAccessorInfo()) {
1985 // api style callbacks 1994 // api style callbacks
1986 AccessorInfo* data = AccessorInfo::cast(structure); 1995 AccessorInfo* data = AccessorInfo::cast(structure);
1996 if (!data->IsCompatibleReceiver(this)) {
1997 Handle<Object> name_handle(name);
1998 Handle<Object> receiver_handle(this);
1999 Handle<Object> args[2] = { name_handle, receiver_handle };
2000 Handle<Object> error =
2001 isolate->factory()->NewTypeError("incompatible_method_receiver",
2002 HandleVector(args, 2));
Sven Panne 2012/06/04 07:50:32 2 => ARRAY_SIZE(args)
Michael Starzinger 2012/06/04 09:11:15 Done.
2003 return isolate->Throw(*error);
2004 }
1987 Object* call_obj = data->setter(); 2005 Object* call_obj = data->setter();
1988 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); 2006 v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
1989 if (call_fun == NULL) return value; 2007 if (call_fun == NULL) return value;
1990 Handle<String> key(name); 2008 Handle<String> key(name);
1991 LOG(isolate, ApiNamedPropertyAccess("store", this, name)); 2009 LOG(isolate, ApiNamedPropertyAccess("store", this, name));
1992 CustomArguments args(isolate, data->data(), this, JSObject::cast(holder)); 2010 CustomArguments args(isolate, data->data(), this, JSObject::cast(holder));
1993 v8::AccessorInfo info(args.end()); 2011 v8::AccessorInfo info(args.end());
1994 { 2012 {
1995 // Leaving JavaScript. 2013 // Leaving JavaScript.
1996 VMState state(isolate, EXTERNAL); 2014 VMState state(isolate, EXTERNAL);
(...skipping 11300 matching lines...) Expand 10 before | Expand all | Expand 10 after
13297 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13315 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13298 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13316 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13299 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13317 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13300 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13318 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13301 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13319 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13302 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13320 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13303 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13321 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13304 } 13322 }
13305 13323
13306 } } // namespace v8::internal 13324 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698