| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 551 } |
| 552 | 552 |
| 553 | 553 |
| 554 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<String> name) { | 554 MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<String> name) { |
| 555 // If the object is undefined or null it's illegal to try to get any | 555 // If the object is undefined or null it's illegal to try to get any |
| 556 // of its properties; throw a TypeError in that case. | 556 // of its properties; throw a TypeError in that case. |
| 557 if (object->IsUndefined() || object->IsNull()) { | 557 if (object->IsUndefined() || object->IsNull()) { |
| 558 return TypeError("non_object_property_load", object, name); | 558 return TypeError("non_object_property_load", object, name); |
| 559 } | 559 } |
| 560 | 560 |
| 561 if (FLAG_use_ic) { | |
| 562 // Use specialized code for getting prototype of functions. | |
| 563 if (object->IsJSFunction() && | |
| 564 String::Equals(isolate()->factory()->prototype_string(), name) && | |
| 565 Handle<JSFunction>::cast(object)->should_have_prototype()) { | |
| 566 Handle<Code> stub; | |
| 567 if (state() == UNINITIALIZED) { | |
| 568 stub = pre_monomorphic_stub(); | |
| 569 } else if (state() == PREMONOMORPHIC) { | |
| 570 FunctionPrototypeStub function_prototype_stub(isolate(), kind()); | |
| 571 stub = function_prototype_stub.GetCode(); | |
| 572 } else if (!FLAG_compiled_keyed_generic_loads && state() != MEGAMORPHIC) { | |
| 573 ASSERT(state() != GENERIC); | |
| 574 stub = megamorphic_stub(); | |
| 575 } else if (FLAG_compiled_keyed_generic_loads && state() != GENERIC) { | |
| 576 stub = generic_stub(); | |
| 577 } | |
| 578 if (!stub.is_null()) { | |
| 579 set_target(*stub); | |
| 580 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); | |
| 581 } | |
| 582 return Accessors::FunctionGetPrototype(Handle<JSFunction>::cast(object)); | |
| 583 } | |
| 584 } | |
| 585 | |
| 586 // Check if the name is trivially convertible to an index and get | 561 // Check if the name is trivially convertible to an index and get |
| 587 // the element or char if so. | 562 // the element or char if so. |
| 588 uint32_t index; | 563 uint32_t index; |
| 589 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { | 564 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { |
| 590 // Rewrite to the generic keyed load stub. | 565 // Rewrite to the generic keyed load stub. |
| 591 if (FLAG_use_ic) { | 566 if (FLAG_use_ic) { |
| 592 set_target(*generic_stub()); | 567 set_target(*generic_stub()); |
| 593 TRACE_IC("LoadIC", name); | 568 TRACE_IC("LoadIC", name); |
| 594 TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index"); | 569 TRACE_GENERIC_IC(isolate(), "LoadIC", "name as array index"); |
| 595 } | 570 } |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 String::Equals(isolate()->factory()->length_string(), name)) { | 927 String::Equals(isolate()->factory()->length_string(), name)) { |
| 953 if (kind() == Code::LOAD_IC) { | 928 if (kind() == Code::LOAD_IC) { |
| 954 StringLengthStub string_length_stub(isolate()); | 929 StringLengthStub string_length_stub(isolate()); |
| 955 return string_length_stub.GetCode(); | 930 return string_length_stub.GetCode(); |
| 956 } else { | 931 } else { |
| 957 KeyedStringLengthStub string_length_stub(isolate()); | 932 KeyedStringLengthStub string_length_stub(isolate()); |
| 958 return string_length_stub.GetCode(); | 933 return string_length_stub.GetCode(); |
| 959 } | 934 } |
| 960 } | 935 } |
| 961 | 936 |
| 937 // Use specialized code for getting prototype of functions. |
| 938 if (object->IsJSFunction() && |
| 939 String::Equals(isolate()->factory()->prototype_string(), name) && |
| 940 Handle<JSFunction>::cast(object)->should_have_prototype()) { |
| 941 Handle<Code> stub; |
| 942 FunctionPrototypeStub function_prototype_stub(isolate(), kind()); |
| 943 return function_prototype_stub.GetCode(); |
| 944 } |
| 945 |
| 946 |
| 962 Handle<HeapType> type = receiver_type(); | 947 Handle<HeapType> type = receiver_type(); |
| 963 Handle<JSObject> holder(lookup->holder()); | 948 Handle<JSObject> holder(lookup->holder()); |
| 964 bool receiver_is_holder = object.is_identical_to(holder); | 949 bool receiver_is_holder = object.is_identical_to(holder); |
| 965 LoadStubCompiler compiler(isolate(), kNoExtraICState, cache_holder, kind()); | 950 LoadStubCompiler compiler(isolate(), kNoExtraICState, cache_holder, kind()); |
| 966 | 951 |
| 967 switch (lookup->type()) { | 952 switch (lookup->type()) { |
| 968 case FIELD: { | 953 case FIELD: { |
| 969 FieldIndex field = lookup->GetFieldIndex(); | 954 FieldIndex field = lookup->GetFieldIndex(); |
| 970 if (receiver_is_holder) { | 955 if (receiver_is_holder) { |
| 971 return SimpleFieldLoad(field); | 956 return SimpleFieldLoad(field); |
| (...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 #undef ADDR | 3041 #undef ADDR |
| 3057 }; | 3042 }; |
| 3058 | 3043 |
| 3059 | 3044 |
| 3060 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3045 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3061 return IC_utilities[id]; | 3046 return IC_utilities[id]; |
| 3062 } | 3047 } |
| 3063 | 3048 |
| 3064 | 3049 |
| 3065 } } // namespace v8::internal | 3050 } } // namespace v8::internal |
| OLD | NEW |