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

Side by Side Diff: src/ic.cc

Issue 12040042: Merged r13480, r13481 into trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 11 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 | « src/ic.h ('k') | src/mark-compact.cc » ('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 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // Otherwise, it will fail in the lookup step. 535 // Otherwise, it will fail in the lookup step.
536 } 536 }
537 537
538 // Lookup the property in the object. 538 // Lookup the property in the object.
539 LookupResult lookup(isolate()); 539 LookupResult lookup(isolate());
540 LookupForRead(object, name, &lookup); 540 LookupForRead(object, name, &lookup);
541 541
542 if (!lookup.IsFound()) { 542 if (!lookup.IsFound()) {
543 // If the object does not have the requested property, check which 543 // If the object does not have the requested property, check which
544 // exception we need to throw. 544 // exception we need to throw.
545 return IsContextual(object) 545 return IsUndeclaredGlobal(object)
546 ? ReferenceError("not_defined", name) 546 ? ReferenceError("not_defined", name)
547 : TypeError("undefined_method", object, name); 547 : TypeError("undefined_method", object, name);
548 } 548 }
549 549
550 // Lookup is valid: Update inline cache and stub cache. 550 // Lookup is valid: Update inline cache and stub cache.
551 if (FLAG_use_ic) { 551 if (FLAG_use_ic) {
552 UpdateCaches(&lookup, state, extra_ic_state, object, name); 552 UpdateCaches(&lookup, state, extra_ic_state, object, name);
553 } 553 }
554 554
555 // Get the property. 555 // Get the property.
556 PropertyAttributes attr; 556 PropertyAttributes attr;
557 Handle<Object> result = 557 Handle<Object> result =
558 Object::GetProperty(object, object, &lookup, name, &attr); 558 Object::GetProperty(object, object, &lookup, name, &attr);
559 RETURN_IF_EMPTY_HANDLE(isolate(), result); 559 RETURN_IF_EMPTY_HANDLE(isolate(), result);
560 560
561 if (lookup.IsInterceptor() && attr == ABSENT) { 561 if (lookup.IsInterceptor() && attr == ABSENT) {
562 // If the object does not have the requested property, check which 562 // If the object does not have the requested property, check which
563 // exception we need to throw. 563 // exception we need to throw.
564 return IsContextual(object) 564 return IsUndeclaredGlobal(object)
565 ? ReferenceError("not_defined", name) 565 ? ReferenceError("not_defined", name)
566 : TypeError("undefined_method", object, name); 566 : TypeError("undefined_method", object, name);
567 } 567 }
568 568
569 ASSERT(!result->IsTheHole()); 569 ASSERT(!result->IsTheHole());
570 570
571 // Make receiver an object if the callee requires it. Strict mode or builtin 571 // Make receiver an object if the callee requires it. Strict mode or builtin
572 // functions do not wrap the receiver, non-strict functions and objects 572 // functions do not wrap the receiver, non-strict functions and objects
573 // called as functions do. 573 // called as functions do.
574 ReceiverToObjectIfRequired(result, object); 574 ReceiverToObjectIfRequired(result, object);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 if (FLAG_use_ic) set_target(*generic_stub()); 926 if (FLAG_use_ic) set_target(*generic_stub());
927 return Runtime::GetElementOrCharAt(isolate(), object, index); 927 return Runtime::GetElementOrCharAt(isolate(), object, index);
928 } 928 }
929 929
930 // Named lookup in the object. 930 // Named lookup in the object.
931 LookupResult lookup(isolate()); 931 LookupResult lookup(isolate());
932 LookupForRead(object, name, &lookup); 932 LookupForRead(object, name, &lookup);
933 933
934 // If we did not find a property, check if we need to throw an exception. 934 // If we did not find a property, check if we need to throw an exception.
935 if (!lookup.IsFound()) { 935 if (!lookup.IsFound()) {
936 if (IsContextual(object)) { 936 if (IsUndeclaredGlobal(object)) {
937 return ReferenceError("not_defined", name); 937 return ReferenceError("not_defined", name);
938 } 938 }
939 LOG(isolate(), SuspectReadEvent(*name, *object)); 939 LOG(isolate(), SuspectReadEvent(*name, *object));
940 } 940 }
941 941
942 // Update inline cache and stub cache. 942 // Update inline cache and stub cache.
943 if (FLAG_use_ic) { 943 if (FLAG_use_ic) {
944 UpdateLoadCaches(&lookup, state, object, name); 944 UpdateLoadCaches(&lookup, state, object, name);
945 } 945 }
946 946
947 PropertyAttributes attr; 947 PropertyAttributes attr;
948 if (lookup.IsInterceptor() || lookup.IsHandler()) { 948 if (lookup.IsInterceptor() || lookup.IsHandler()) {
949 // Get the property. 949 // Get the property.
950 Handle<Object> result = 950 Handle<Object> result =
951 Object::GetProperty(object, object, &lookup, name, &attr); 951 Object::GetProperty(object, object, &lookup, name, &attr);
952 RETURN_IF_EMPTY_HANDLE(isolate(), result); 952 RETURN_IF_EMPTY_HANDLE(isolate(), result);
953 // If the property is not present, check if we need to throw an 953 // If the property is not present, check if we need to throw an
954 // exception. 954 // exception.
955 if (attr == ABSENT && IsContextual(object)) { 955 if (attr == ABSENT && IsUndeclaredGlobal(object)) {
956 return ReferenceError("not_defined", name); 956 return ReferenceError("not_defined", name);
957 } 957 }
958 return *result; 958 return *result;
959 } 959 }
960 960
961 // Get the property. 961 // Get the property.
962 return object->GetProperty(*object, &lookup, *name, &attr); 962 return object->GetProperty(*object, &lookup, *name, &attr);
963 } 963 }
964 964
965 965
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 TRACE_IC("StoreIC", name, state, *stub); 1383 TRACE_IC("StoreIC", name, state, *stub);
1384 } 1384 }
1385 return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode); 1385 return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode);
1386 } 1386 }
1387 1387
1388 LookupResult lookup(isolate()); 1388 LookupResult lookup(isolate());
1389 if (LookupForWrite(receiver, name, &lookup)) { 1389 if (LookupForWrite(receiver, name, &lookup)) {
1390 if (FLAG_use_ic) { 1390 if (FLAG_use_ic) {
1391 UpdateStoreCaches(&lookup, state, strict_mode, receiver, name, value); 1391 UpdateStoreCaches(&lookup, state, strict_mode, receiver, name, value);
1392 } 1392 }
1393 } else if (strict_mode == kStrictMode && 1393 } else if (strict_mode == kStrictMode && IsUndeclaredGlobal(object)) {
1394 !lookup.IsFound() && 1394 // Strict mode doesn't allow setting non-existent global property.
1395 IsContextual(object)) {
1396 // Strict mode doesn't allow setting non-existent global property
1397 // or an assignment to a read only property.
1398 return ReferenceError("not_defined", name); 1395 return ReferenceError("not_defined", name);
1399 } 1396 }
1400 1397
1401 // Set the property. 1398 // Set the property.
1402 return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode); 1399 return receiver->SetProperty(*name, *value, NONE, strict_mode, store_mode);
1403 } 1400 }
1404 1401
1405 1402
1406 void StoreIC::UpdateStoreCaches(LookupResult* lookup, 1403 void StoreIC::UpdateStoreCaches(LookupResult* lookup,
1407 State state, 1404 State state,
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 #undef ADDR 2749 #undef ADDR
2753 }; 2750 };
2754 2751
2755 2752
2756 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2753 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2757 return IC_utilities[id]; 2754 return IC_utilities[id];
2758 } 2755 }
2759 2756
2760 2757
2761 } } // namespace v8::internal 2758 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698