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

Unified Diff: src/ic.cc

Issue 6992072: Implement set trap for proxies, and revamp class hierarchy in preparation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index 6d5c4dfcbfdc36e1ed9ef68a44735adb81ec9cf3..35c01a729f58e64421a8ff9c3e42076a36beb6cd 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -1343,15 +1343,16 @@ static bool StoreICableLookup(LookupResult* lookup) {
}
-static bool LookupForWrite(JSObject* object,
+static bool LookupForWrite(JSReceiver* receiver,
String* name,
LookupResult* lookup) {
- object->LocalLookup(name, lookup);
+ receiver->LocalLookup(name, lookup);
if (!StoreICableLookup(lookup)) {
return false;
}
if (lookup->type() == INTERCEPTOR) {
+ JSObject* object = JSObject::cast(receiver);
if (object->GetNamedInterceptor()->setter()->IsUndefined()) {
object->LocalLookupRealNamedProperty(name, lookup);
return StoreICableLookup(lookup);
@@ -1373,7 +1374,7 @@ MaybeObject* StoreIC::Store(State state,
return TypeError("non_object_property_store", object, name);
}
- if (!object->IsJSObject()) {
+ if (!object->IsJSReceiver()) {
// The length property of string values is read-only. Throw in strict mode.
if (strict_mode == kStrictMode && object->IsString() &&
name->Equals(isolate()->heap()->length_symbol())) {
@@ -1383,6 +1384,13 @@ MaybeObject* StoreIC::Store(State state,
return *value;
}
+ // Handle proxies.
+ if (object->IsJSProxy()) {
+ HandleScope scope(isolate());
+ return JSReceiver::cast(*object)->
+ SetProperty(*name, *value, NONE, strict_mode);
+ }
+
Handle<JSObject> receiver = Handle<JSObject>::cast(object);
// Check if the given name is an array index.
@@ -1397,7 +1405,7 @@ MaybeObject* StoreIC::Store(State state,
// Use specialized code for setting the length of arrays.
if (receiver->IsJSArray()
&& name->Equals(isolate()->heap()->length_symbol())
- && receiver->AllowsSetElementsLength()) {
+ && JSArray::cast(*receiver)->AllowsSetElementsLength()) {
#ifdef DEBUG
if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n");
#endif

Powered by Google App Engine
This is Rietveld 408576698