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

Side by Side Diff: src/ic.cc

Issue 7799026: Make proxies work as prototypes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing Kevin's comments. Created 9 years, 3 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
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false; 1358 if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false;
1359 1359
1360 // If the property is read-only, we leave the IC in its current 1360 // If the property is read-only, we leave the IC in its current
1361 // state. 1361 // state.
1362 if (lookup->IsReadOnly()) return false; 1362 if (lookup->IsReadOnly()) return false;
1363 1363
1364 return true; 1364 return true;
1365 } 1365 }
1366 1366
1367 1367
1368 static bool LookupForWrite(JSReceiver* receiver, 1368 static bool LookupForWrite(JSObject* receiver,
1369 String* name, 1369 String* name,
1370 LookupResult* lookup) { 1370 LookupResult* lookup) {
1371 receiver->LocalLookup(name, lookup); 1371 receiver->LocalLookup(name, lookup);
1372 if (!StoreICableLookup(lookup)) { 1372 if (!StoreICableLookup(lookup)) {
1373 return false; 1373 return false;
1374 } 1374 }
1375 1375
1376 if (lookup->type() == INTERCEPTOR) { 1376 if (lookup->type() == INTERCEPTOR &&
1377 JSObject* object = JSObject::cast(receiver); 1377 receiver->GetNamedInterceptor()->setter()->IsUndefined()) {
1378 if (object->GetNamedInterceptor()->setter()->IsUndefined()) { 1378 receiver->LocalLookupRealNamedProperty(name, lookup);
1379 object->LocalLookupRealNamedProperty(name, lookup); 1379 return StoreICableLookup(lookup);
1380 return StoreICableLookup(lookup);
1381 }
1382 } 1380 }
1383 1381
1384 return true; 1382 return true;
1385 } 1383 }
1386 1384
1387 1385
1388 MaybeObject* StoreIC::Store(State state, 1386 MaybeObject* StoreIC::Store(State state,
1389 StrictModeFlag strict_mode, 1387 StrictModeFlag strict_mode,
1390 Handle<Object> object, 1388 Handle<Object> object,
1391 Handle<String> name, 1389 Handle<String> name,
1392 Handle<Object> value) { 1390 Handle<Object> value) {
1393 // If the object is undefined or null it's illegal to try to set any 1391 if (!object->IsJSObject()) {
1394 // properties on it; throw a TypeError in that case. 1392 // Handle proxies.
1395 if (object->IsUndefined() || object->IsNull()) { 1393 if (object->IsJSProxy()) {
1396 return TypeError("non_object_property_store", object, name); 1394 return JSProxy::cast(*object)->
1397 } 1395 SetProperty(*name, *value, NONE, strict_mode);
1396 }
1398 1397
1399 if (!object->IsJSReceiver()) { 1398 // If the object is undefined or null it's illegal to try to set any
1399 // properties on it; throw a TypeError in that case.
1400 if (object->IsUndefined() || object->IsNull()) {
1401 return TypeError("non_object_property_store", object, name);
1402 }
1403
1400 // The length property of string values is read-only. Throw in strict mode. 1404 // The length property of string values is read-only. Throw in strict mode.
1401 if (strict_mode == kStrictMode && object->IsString() && 1405 if (strict_mode == kStrictMode && object->IsString() &&
1402 name->Equals(isolate()->heap()->length_symbol())) { 1406 name->Equals(isolate()->heap()->length_symbol())) {
1403 return TypeError("strict_read_only_property", object, name); 1407 return TypeError("strict_read_only_property", object, name);
1404 } 1408 }
1405 // Ignore stores where the receiver is not a JSObject. 1409 // Ignore other stores where the receiver is not a JSObject.
1406 return *value; 1410 return *value;
1407 } 1411 }
1408 1412
1409 // Handle proxies.
1410 if (object->IsJSProxy()) {
1411 return JSReceiver::cast(*object)->
1412 SetProperty(*name, *value, NONE, strict_mode);
1413 }
1414
1415 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1413 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1416 1414
1417 // Check if the given name is an array index. 1415 // Check if the given name is an array index.
1418 uint32_t index; 1416 uint32_t index;
1419 if (name->AsArrayIndex(&index)) { 1417 if (name->AsArrayIndex(&index)) {
1420 HandleScope scope(isolate()); 1418 HandleScope scope(isolate());
1421 Handle<Object> result = SetElement(receiver, index, value, strict_mode); 1419 Handle<Object> result = SetElement(receiver, index, value, strict_mode);
1422 if (result.is_null()) return Failure::Exception(); 1420 if (result.is_null()) return Failure::Exception();
1423 return *value; 1421 return *value;
1424 } 1422 }
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 #undef ADDR 2530 #undef ADDR
2533 }; 2531 };
2534 2532
2535 2533
2536 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2534 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2537 return IC_utilities[id]; 2535 return IC_utilities[id];
2538 } 2536 }
2539 2537
2540 2538
2541 } } // namespace v8::internal 2539 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698