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/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 return isolate->builtins()->KeyedLoadIC_Initialize(); | 930 return isolate->builtins()->KeyedLoadIC_Initialize(); |
931 case MEGAMORPHIC: | 931 case MEGAMORPHIC: |
932 return isolate->builtins()->KeyedLoadIC_Megamorphic(); | 932 return isolate->builtins()->KeyedLoadIC_Megamorphic(); |
933 default: | 933 default: |
934 UNREACHABLE(); | 934 UNREACHABLE(); |
935 } | 935 } |
936 return Handle<Code>(); | 936 return Handle<Code>(); |
937 } | 937 } |
938 | 938 |
939 | 939 |
940 Handle<Code> KeyedStoreIC::initialize_stub(Isolate* isolate, | 940 static Handle<Code> KeyedStoreICInitializeStubHelper( |
941 LanguageMode language_mode, | 941 Isolate* isolate, LanguageMode language_mode, |
942 State initialization_state) { | 942 InlineCacheState initialization_state) { |
943 switch (initialization_state) { | 943 switch (initialization_state) { |
944 case UNINITIALIZED: | 944 case UNINITIALIZED: |
945 return is_strict(language_mode) | 945 return is_strict(language_mode) |
946 ? isolate->builtins()->KeyedStoreIC_Initialize_Strict() | 946 ? isolate->builtins()->KeyedStoreIC_Initialize_Strict() |
947 : isolate->builtins()->KeyedStoreIC_Initialize(); | 947 : isolate->builtins()->KeyedStoreIC_Initialize(); |
948 case PREMONOMORPHIC: | 948 case PREMONOMORPHIC: |
949 return is_strict(language_mode) | 949 return is_strict(language_mode) |
950 ? isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict() | 950 ? isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict() |
951 : isolate->builtins()->KeyedStoreIC_PreMonomorphic(); | 951 : isolate->builtins()->KeyedStoreIC_PreMonomorphic(); |
952 case MEGAMORPHIC: | 952 case MEGAMORPHIC: |
953 return is_strict(language_mode) | 953 return is_strict(language_mode) |
954 ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict() | 954 ? isolate->builtins()->KeyedStoreIC_Megamorphic_Strict() |
955 : isolate->builtins()->KeyedStoreIC_Megamorphic(); | 955 : isolate->builtins()->KeyedStoreIC_Megamorphic(); |
956 default: | 956 default: |
957 UNREACHABLE(); | 957 UNREACHABLE(); |
958 } | 958 } |
959 return Handle<Code>(); | 959 return Handle<Code>(); |
960 } | 960 } |
961 | 961 |
962 | 962 |
| 963 Handle<Code> KeyedStoreIC::initialize_stub(Isolate* isolate, |
| 964 LanguageMode language_mode, |
| 965 State initialization_state) { |
| 966 if (FLAG_vector_stores) { |
| 967 VectorKeyedStoreICTrampolineStub stub(isolate, StoreICState(language_mode)); |
| 968 return stub.GetCode(); |
| 969 } |
| 970 |
| 971 return KeyedStoreICInitializeStubHelper(isolate, language_mode, |
| 972 initialization_state); |
| 973 } |
| 974 |
| 975 |
| 976 Handle<Code> KeyedStoreIC::initialize_stub_in_optimized_code( |
| 977 Isolate* isolate, LanguageMode language_mode, State initialization_state) { |
| 978 if (FLAG_vector_stores && initialization_state != MEGAMORPHIC) { |
| 979 VectorKeyedStoreICStub stub(isolate, StoreICState(language_mode)); |
| 980 return stub.GetCode(); |
| 981 } |
| 982 |
| 983 return KeyedStoreICInitializeStubHelper(isolate, language_mode, |
| 984 initialization_state); |
| 985 } |
| 986 |
| 987 |
963 Handle<Code> LoadIC::megamorphic_stub() { | 988 Handle<Code> LoadIC::megamorphic_stub() { |
964 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); | 989 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); |
965 return KeyedLoadIC::ChooseMegamorphicStub(isolate()); | 990 return KeyedLoadIC::ChooseMegamorphicStub(isolate()); |
966 } | 991 } |
967 | 992 |
968 | 993 |
969 Handle<Code> LoadIC::SimpleFieldLoad(FieldIndex index) { | 994 Handle<Code> LoadIC::SimpleFieldLoad(FieldIndex index) { |
970 LoadFieldStub stub(isolate(), index); | 995 LoadFieldStub stub(isolate(), index); |
971 return stub.GetCode(); | 996 return stub.GetCode(); |
972 } | 997 } |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 Object); | 1341 Object); |
1317 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { | 1342 } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { |
1318 if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { | 1343 if (object->IsJSObject() || (object->IsString() && key->IsNumber())) { |
1319 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); | 1344 Handle<HeapObject> receiver = Handle<HeapObject>::cast(object); |
1320 if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) { | 1345 if (object->IsString() || !Object::ToSmi(isolate(), key).is_null()) { |
1321 stub = LoadElementStub(receiver); | 1346 stub = LoadElementStub(receiver); |
1322 } | 1347 } |
1323 } | 1348 } |
1324 } | 1349 } |
1325 | 1350 |
1326 if (!UseVector()) { | 1351 DCHECK(UseVector()); |
1327 if (!is_target_set()) { | 1352 if (!is_vector_set() || stub.is_null()) { |
1328 Code* generic = *megamorphic_stub(); | 1353 Code* generic = *megamorphic_stub(); |
1329 if (*stub == generic) { | 1354 if (!stub.is_null() && *stub == generic) { |
1330 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); | 1355 ConfigureVectorState(MEGAMORPHIC); |
1331 } | 1356 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); |
| 1357 } |
1332 | 1358 |
1333 set_target(*stub); | 1359 TRACE_IC("LoadIC", key); |
1334 TRACE_IC("LoadIC", key); | |
1335 } | |
1336 } else { | |
1337 if (!is_vector_set() || stub.is_null()) { | |
1338 Code* generic = *megamorphic_stub(); | |
1339 if (!stub.is_null() && *stub == generic) { | |
1340 ConfigureVectorState(MEGAMORPHIC); | |
1341 TRACE_GENERIC_IC(isolate(), "KeyedLoadIC", "set generic"); | |
1342 } | |
1343 | |
1344 TRACE_IC("LoadIC", key); | |
1345 } | |
1346 } | 1360 } |
1347 | 1361 |
1348 if (!load_handle.is_null()) return load_handle; | 1362 if (!load_handle.is_null()) return load_handle; |
1349 Handle<Object> result; | 1363 Handle<Object> result; |
1350 ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, | 1364 ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, |
1351 Runtime::GetObjectProperty(isolate(), object, key), | 1365 Runtime::GetObjectProperty(isolate(), object, key), |
1352 Object); | 1366 Object); |
1353 return result; | 1367 return result; |
1354 } | 1368 } |
1355 | 1369 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 | 1530 |
1517 | 1531 |
1518 Handle<Code> CallIC::initialize_stub_in_optimized_code( | 1532 Handle<Code> CallIC::initialize_stub_in_optimized_code( |
1519 Isolate* isolate, int argc, CallICState::CallType call_type) { | 1533 Isolate* isolate, int argc, CallICState::CallType call_type) { |
1520 CallICStub stub(isolate, CallICState(argc, call_type)); | 1534 CallICStub stub(isolate, CallICState(argc, call_type)); |
1521 Handle<Code> code = stub.GetCode(); | 1535 Handle<Code> code = stub.GetCode(); |
1522 return code; | 1536 return code; |
1523 } | 1537 } |
1524 | 1538 |
1525 | 1539 |
| 1540 static Handle<Code> StoreICInitializeStubHelper( |
| 1541 Isolate* isolate, ExtraICState extra_state, |
| 1542 InlineCacheState initialization_state) { |
| 1543 Handle<Code> ic = PropertyICCompiler::ComputeStore( |
| 1544 isolate, initialization_state, extra_state); |
| 1545 return ic; |
| 1546 } |
| 1547 |
| 1548 |
1526 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, | 1549 Handle<Code> StoreIC::initialize_stub(Isolate* isolate, |
1527 LanguageMode language_mode, | 1550 LanguageMode language_mode, |
1528 State initialization_state) { | 1551 State initialization_state) { |
1529 DCHECK(initialization_state == UNINITIALIZED || | 1552 DCHECK(initialization_state == UNINITIALIZED || |
1530 initialization_state == PREMONOMORPHIC || | 1553 initialization_state == PREMONOMORPHIC || |
1531 initialization_state == MEGAMORPHIC); | 1554 initialization_state == MEGAMORPHIC); |
1532 ExtraICState extra_state = ComputeExtraICState(language_mode); | 1555 if (FLAG_vector_stores) { |
1533 Handle<Code> ic = PropertyICCompiler::ComputeStore( | 1556 VectorStoreICTrampolineStub stub(isolate, StoreICState(language_mode)); |
1534 isolate, initialization_state, extra_state); | 1557 return stub.GetCode(); |
1535 return ic; | 1558 } |
| 1559 |
| 1560 return StoreICInitializeStubHelper( |
| 1561 isolate, ComputeExtraICState(language_mode), initialization_state); |
1536 } | 1562 } |
1537 | 1563 |
1538 | 1564 |
| 1565 Handle<Code> StoreIC::initialize_stub_in_optimized_code( |
| 1566 Isolate* isolate, LanguageMode language_mode, State initialization_state) { |
| 1567 DCHECK(initialization_state == UNINITIALIZED || |
| 1568 initialization_state == PREMONOMORPHIC || |
| 1569 initialization_state == MEGAMORPHIC); |
| 1570 if (FLAG_vector_stores && initialization_state != MEGAMORPHIC) { |
| 1571 VectorStoreICStub stub(isolate, StoreICState(language_mode)); |
| 1572 return stub.GetCode(); |
| 1573 } |
| 1574 |
| 1575 return StoreICInitializeStubHelper( |
| 1576 isolate, ComputeExtraICState(language_mode), initialization_state); |
| 1577 } |
| 1578 |
| 1579 |
1539 Handle<Code> StoreIC::megamorphic_stub() { | 1580 Handle<Code> StoreIC::megamorphic_stub() { |
1540 if (kind() == Code::STORE_IC) { | 1581 if (kind() == Code::STORE_IC) { |
1541 return PropertyICCompiler::ComputeStore(isolate(), MEGAMORPHIC, | 1582 return PropertyICCompiler::ComputeStore(isolate(), MEGAMORPHIC, |
1542 extra_ic_state()); | 1583 extra_ic_state()); |
1543 } else { | 1584 } else { |
1544 DCHECK(kind() == Code::KEYED_STORE_IC); | 1585 DCHECK(kind() == Code::KEYED_STORE_IC); |
1545 if (is_strict(language_mode())) { | 1586 if (is_strict(language_mode())) { |
1546 return isolate()->builtins()->KeyedStoreIC_Megamorphic_Strict(); | 1587 return isolate()->builtins()->KeyedStoreIC_Megamorphic_Strict(); |
1547 } else { | 1588 } else { |
1548 return isolate()->builtins()->KeyedStoreIC_Megamorphic(); | 1589 return isolate()->builtins()->KeyedStoreIC_Megamorphic(); |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 static const Address IC_utilities[] = { | 2938 static const Address IC_utilities[] = { |
2898 #define ADDR(name) FUNCTION_ADDR(name), | 2939 #define ADDR(name) FUNCTION_ADDR(name), |
2899 IC_UTIL_LIST(ADDR) NULL | 2940 IC_UTIL_LIST(ADDR) NULL |
2900 #undef ADDR | 2941 #undef ADDR |
2901 }; | 2942 }; |
2902 | 2943 |
2903 | 2944 |
2904 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 2945 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
2905 } // namespace internal | 2946 } // namespace internal |
2906 } // namespace v8 | 2947 } // namespace v8 |
OLD | NEW |