OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // Otherwise, it will fail in the lookup step. | 402 // Otherwise, it will fail in the lookup step. |
403 } | 403 } |
404 | 404 |
405 // Lookup the property in the object. | 405 // Lookup the property in the object. |
406 LookupResult lookup; | 406 LookupResult lookup; |
407 LookupForRead(*object, *name, &lookup); | 407 LookupForRead(*object, *name, &lookup); |
408 | 408 |
409 if (!lookup.IsValid()) { | 409 if (!lookup.IsValid()) { |
410 // If the object does not have the requested property, check which | 410 // If the object does not have the requested property, check which |
411 // exception we need to throw. | 411 // exception we need to throw. |
412 if (is_contextual()) { | 412 if (IsContextual(object)) { |
413 return ReferenceError("not_defined", name); | 413 return ReferenceError("not_defined", name); |
414 } | 414 } |
415 return TypeError("undefined_method", object, name); | 415 return TypeError("undefined_method", object, name); |
416 } | 416 } |
417 | 417 |
418 // Lookup is valid: Update inline cache and stub cache. | 418 // Lookup is valid: Update inline cache and stub cache. |
419 if (FLAG_use_ic && lookup.IsLoaded()) { | 419 if (FLAG_use_ic && lookup.IsLoaded()) { |
420 UpdateCaches(&lookup, state, object, name); | 420 UpdateCaches(&lookup, state, object, name); |
421 } | 421 } |
422 | 422 |
423 // Get the property. | 423 // Get the property. |
424 PropertyAttributes attr; | 424 PropertyAttributes attr; |
425 Object* result = object->GetProperty(*object, &lookup, *name, &attr); | 425 Object* result = object->GetProperty(*object, &lookup, *name, &attr); |
426 if (result->IsFailure()) return result; | 426 if (result->IsFailure()) return result; |
427 if (lookup.type() == INTERCEPTOR) { | 427 if (lookup.type() == INTERCEPTOR) { |
428 // If the object does not have the requested property, check which | 428 // If the object does not have the requested property, check which |
429 // exception we need to throw. | 429 // exception we need to throw. |
430 if (attr == ABSENT) { | 430 if (attr == ABSENT) { |
431 if (is_contextual()) { | 431 if (IsContextual(object)) { |
432 return ReferenceError("not_defined", name); | 432 return ReferenceError("not_defined", name); |
433 } | 433 } |
434 return TypeError("undefined_method", object, name); | 434 return TypeError("undefined_method", object, name); |
435 } | 435 } |
436 } | 436 } |
437 | 437 |
438 ASSERT(result != Heap::the_hole_value()); | 438 ASSERT(result != Heap::the_hole_value()); |
439 | 439 |
440 if (result->IsJSFunction()) { | 440 if (result->IsJSFunction()) { |
441 // Check if there is an optimized (builtin) version of the function. | 441 // Check if there is an optimized (builtin) version of the function. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 // the element if so. | 621 // the element if so. |
622 uint32_t index; | 622 uint32_t index; |
623 if (name->AsArrayIndex(&index)) return object->GetElement(index); | 623 if (name->AsArrayIndex(&index)) return object->GetElement(index); |
624 | 624 |
625 // Named lookup in the object. | 625 // Named lookup in the object. |
626 LookupResult lookup; | 626 LookupResult lookup; |
627 LookupForRead(*object, *name, &lookup); | 627 LookupForRead(*object, *name, &lookup); |
628 | 628 |
629 // If lookup is invalid, check if we need to throw an exception. | 629 // If lookup is invalid, check if we need to throw an exception. |
630 if (!lookup.IsValid()) { | 630 if (!lookup.IsValid()) { |
631 if (FLAG_strict || is_contextual()) { | 631 if (FLAG_strict || IsContextual(object)) { |
632 return ReferenceError("not_defined", name); | 632 return ReferenceError("not_defined", name); |
633 } | 633 } |
634 LOG(SuspectReadEvent(*name, *object)); | 634 LOG(SuspectReadEvent(*name, *object)); |
635 } | 635 } |
636 | 636 |
637 bool can_be_inlined = | 637 bool can_be_inlined = |
638 FLAG_use_ic && | 638 FLAG_use_ic && |
639 state == PREMONOMORPHIC && | 639 state == PREMONOMORPHIC && |
640 lookup.IsValid() && | 640 lookup.IsValid() && |
641 lookup.IsLoaded() && | 641 lookup.IsLoaded() && |
(...skipping 22 matching lines...) Expand all Loading... |
664 UpdateCaches(&lookup, state, object, name); | 664 UpdateCaches(&lookup, state, object, name); |
665 } | 665 } |
666 | 666 |
667 PropertyAttributes attr; | 667 PropertyAttributes attr; |
668 if (lookup.IsValid() && lookup.type() == INTERCEPTOR) { | 668 if (lookup.IsValid() && lookup.type() == INTERCEPTOR) { |
669 // Get the property. | 669 // Get the property. |
670 Object* result = object->GetProperty(*object, &lookup, *name, &attr); | 670 Object* result = object->GetProperty(*object, &lookup, *name, &attr); |
671 if (result->IsFailure()) return result; | 671 if (result->IsFailure()) return result; |
672 // If the property is not present, check if we need to throw an | 672 // If the property is not present, check if we need to throw an |
673 // exception. | 673 // exception. |
674 if (attr == ABSENT && is_contextual()) { | 674 if (attr == ABSENT && IsContextual(object)) { |
675 return ReferenceError("not_defined", name); | 675 return ReferenceError("not_defined", name); |
676 } | 676 } |
677 return result; | 677 return result; |
678 } | 678 } |
679 | 679 |
680 // Get the property. | 680 // Get the property. |
681 return object->GetProperty(*object, &lookup, *name, &attr); | 681 return object->GetProperty(*object, &lookup, *name, &attr); |
682 } | 682 } |
683 | 683 |
684 | 684 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 if (FLAG_use_ic) set_target(generic_stub()); | 836 if (FLAG_use_ic) set_target(generic_stub()); |
837 return Runtime::GetElementOrCharAt(object, index); | 837 return Runtime::GetElementOrCharAt(object, index); |
838 } | 838 } |
839 | 839 |
840 // Named lookup. | 840 // Named lookup. |
841 LookupResult lookup; | 841 LookupResult lookup; |
842 LookupForRead(*object, *name, &lookup); | 842 LookupForRead(*object, *name, &lookup); |
843 | 843 |
844 // If lookup is invalid, check if we need to throw an exception. | 844 // If lookup is invalid, check if we need to throw an exception. |
845 if (!lookup.IsValid()) { | 845 if (!lookup.IsValid()) { |
846 if (FLAG_strict || is_contextual()) { | 846 if (FLAG_strict || IsContextual(object)) { |
847 return ReferenceError("not_defined", name); | 847 return ReferenceError("not_defined", name); |
848 } | 848 } |
849 } | 849 } |
850 | 850 |
851 if (FLAG_use_ic && lookup.IsLoaded()) { | 851 if (FLAG_use_ic && lookup.IsLoaded()) { |
852 UpdateCaches(&lookup, state, object, name); | 852 UpdateCaches(&lookup, state, object, name); |
853 } | 853 } |
854 | 854 |
855 PropertyAttributes attr; | 855 PropertyAttributes attr; |
856 if (lookup.IsValid() && lookup.type() == INTERCEPTOR) { | 856 if (lookup.IsValid() && lookup.type() == INTERCEPTOR) { |
857 // Get the property. | 857 // Get the property. |
858 Object* result = object->GetProperty(*object, &lookup, *name, &attr); | 858 Object* result = object->GetProperty(*object, &lookup, *name, &attr); |
859 if (result->IsFailure()) return result; | 859 if (result->IsFailure()) return result; |
860 // If the property is not present, check if we need to throw an | 860 // If the property is not present, check if we need to throw an |
861 // exception. | 861 // exception. |
862 if (attr == ABSENT && is_contextual()) { | 862 if (attr == ABSENT && IsContextual(object)) { |
863 return ReferenceError("not_defined", name); | 863 return ReferenceError("not_defined", name); |
864 } | 864 } |
865 return result; | 865 return result; |
866 } | 866 } |
867 | 867 |
868 return object->GetProperty(*object, &lookup, *name, &attr); | 868 return object->GetProperty(*object, &lookup, *name, &attr); |
869 } | 869 } |
870 | 870 |
871 // Do not use ICs for objects that require access checks (including | 871 // Do not use ICs for objects that require access checks (including |
872 // the global object). | 872 // the global object). |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 #undef ADDR | 1425 #undef ADDR |
1426 }; | 1426 }; |
1427 | 1427 |
1428 | 1428 |
1429 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 1429 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
1430 return IC_utilities[id]; | 1430 return IC_utilities[id]; |
1431 } | 1431 } |
1432 | 1432 |
1433 | 1433 |
1434 } } // namespace v8::internal | 1434 } } // namespace v8::internal |
OLD | NEW |