| 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/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
| 10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 template <> | 529 template <> |
| 530 HValue* CodeStubGraphBuilder<CreateWeakCellStub>::BuildCodeStub() { | 530 HValue* CodeStubGraphBuilder<CreateWeakCellStub>::BuildCodeStub() { |
| 531 // This stub is performance sensitive, the generated code must be tuned | 531 // This stub is performance sensitive, the generated code must be tuned |
| 532 // so that it doesn't build an eager frame. | 532 // so that it doesn't build an eager frame. |
| 533 info()->MarkMustNotHaveEagerFrame(); | 533 info()->MarkMustNotHaveEagerFrame(); |
| 534 | 534 |
| 535 HValue* size = Add<HConstant>(WeakCell::kSize); | 535 HValue* size = Add<HConstant>(WeakCell::kSize); |
| 536 HInstruction* object = | 536 HInstruction* object = |
| 537 Add<HAllocate>(size, HType::JSObject(), TENURED, JS_OBJECT_TYPE); | 537 Add<HAllocate>(size, HType::JSObject(), TENURED, JS_OBJECT_TYPE); |
| 538 | 538 |
| 539 Handle<Map> weak_cell_map = isolate()->factory()->weak_cell_map(); | 539 Handle<Map> weak_cell_map = isolate()->factory()->used_weak_cell_map(); |
| 540 AddStoreMapConstant(object, weak_cell_map); | 540 AddStoreMapConstant(object, weak_cell_map); |
| 541 | 541 |
| 542 HInstruction* value = GetParameter(CreateWeakCellDescriptor::kValueIndex); | 542 HInstruction* value = GetParameter(CreateWeakCellDescriptor::kValueIndex); |
| 543 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellValue(), value); | 543 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellValue(), value); |
| 544 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellNext(), | 544 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellNext(), |
| 545 graph()->GetConstantUndefined()); | 545 graph()->GetConstantUndefined()); |
| 546 | 546 |
| 547 HInstruction* feedback_vector = | 547 HInstruction* feedback_vector = |
| 548 GetParameter(CreateWeakCellDescriptor::kVectorIndex); | 548 GetParameter(CreateWeakCellDescriptor::kVectorIndex); |
| 549 HInstruction* slot = GetParameter(CreateWeakCellDescriptor::kSlotIndex); | 549 HInstruction* slot = GetParameter(CreateWeakCellDescriptor::kSlotIndex); |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 if (stub->check_global()) { | 1333 if (stub->check_global()) { |
| 1334 // Check that the map of the global has not changed: use a placeholder map | 1334 // Check that the map of the global has not changed: use a placeholder map |
| 1335 // that will be replaced later with the global object's map. | 1335 // that will be replaced later with the global object's map. |
| 1336 HParameter* proxy = GetParameter(StoreDescriptor::kReceiverIndex); | 1336 HParameter* proxy = GetParameter(StoreDescriptor::kReceiverIndex); |
| 1337 HValue* proxy_map = | 1337 HValue* proxy_map = |
| 1338 Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap()); | 1338 Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap()); |
| 1339 HValue* global = | 1339 HValue* global = |
| 1340 Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype()); | 1340 Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype()); |
| 1341 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); | 1341 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); |
| 1342 HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map)); | 1342 HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map)); |
| 1343 HValue* expected_map = | 1343 HValue* expected_map = Add<HLoadNamedField>( |
| 1344 Add<HLoadNamedField>(cell, nullptr, HObjectAccess::ForWeakCellValue()); | 1344 cell, nullptr, HObjectAccess::ForWeakCellValueComparison()); |
| 1345 HValue* map = | 1345 HValue* map = |
| 1346 Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap()); | 1346 Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap()); |
| 1347 IfBuilder map_check(this); | 1347 IfBuilder map_check(this); |
| 1348 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); | 1348 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); |
| 1349 map_check.ThenDeopt(Deoptimizer::kUnknownMap); | 1349 map_check.ThenDeopt(Deoptimizer::kUnknownMap); |
| 1350 map_check.End(); | 1350 map_check.End(); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 HValue* weak_cell = Add<HConstant>(isolate()->factory()->NewWeakCell( | 1353 HValue* weak_cell = Add<HConstant>(isolate()->factory()->NewWeakCell( |
| 1354 StoreGlobalStub::property_cell_placeholder(isolate()))); | 1354 StoreGlobalStub::property_cell_placeholder(isolate()))); |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2081 Push(heap_number_map); | 2081 Push(heap_number_map); |
| 2082 if_receiver_heap_object.End(); | 2082 if_receiver_heap_object.End(); |
| 2083 HValue* receiver_map = Pop(); | 2083 HValue* receiver_map = Pop(); |
| 2084 | 2084 |
| 2085 HValue* start = | 2085 HValue* start = |
| 2086 keyed_load ? graph()->GetConstant1() : graph()->GetConstant0(); | 2086 keyed_load ? graph()->GetConstant1() : graph()->GetConstant0(); |
| 2087 HValue* weak_cell = | 2087 HValue* weak_cell = |
| 2088 Add<HLoadKeyed>(array, start, nullptr, FAST_ELEMENTS, ALLOW_RETURN_HOLE); | 2088 Add<HLoadKeyed>(array, start, nullptr, FAST_ELEMENTS, ALLOW_RETURN_HOLE); |
| 2089 // Load the weak cell value. It may be Smi(0), or a map. Compare nonetheless | 2089 // Load the weak cell value. It may be Smi(0), or a map. Compare nonetheless |
| 2090 // against the receiver_map. | 2090 // against the receiver_map. |
| 2091 HValue* array_map = Add<HLoadNamedField>(weak_cell, nullptr, | 2091 HValue* array_map = Add<HLoadNamedField>( |
| 2092 HObjectAccess::ForWeakCellValue()); | 2092 weak_cell, nullptr, HObjectAccess::ForWeakCellValueComparison()); |
| 2093 | 2093 |
| 2094 IfBuilder if_correct_map(this); | 2094 IfBuilder if_correct_map(this); |
| 2095 if_correct_map.If<HCompareObjectEqAndBranch>(receiver_map, array_map); | 2095 if_correct_map.If<HCompareObjectEqAndBranch>(receiver_map, array_map); |
| 2096 if_correct_map.Then(); | 2096 if_correct_map.Then(); |
| 2097 { TailCallHandler(receiver, name, array, start, slot, vector); } | 2097 { TailCallHandler(receiver, name, array, start, slot, vector); } |
| 2098 if_correct_map.Else(); | 2098 if_correct_map.Else(); |
| 2099 { | 2099 { |
| 2100 // If our array has more elements, the ic is polymorphic. Look for the | 2100 // If our array has more elements, the ic is polymorphic. Look for the |
| 2101 // receiver map in the rest of the array. | 2101 // receiver map in the rest of the array. |
| 2102 HValue* length = AddLoadFixedArrayLength(array, nullptr); | 2102 HValue* length = AddLoadFixedArrayLength(array, nullptr); |
| 2103 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement, | 2103 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement, |
| 2104 constant_two); | 2104 constant_two); |
| 2105 start = keyed_load ? constant_three : constant_two; | 2105 start = keyed_load ? constant_three : constant_two; |
| 2106 HValue* key = builder.BeginBody(start, length, Token::LT); | 2106 HValue* key = builder.BeginBody(start, length, Token::LT); |
| 2107 { | 2107 { |
| 2108 HValue* weak_cell = Add<HLoadKeyed>(array, key, nullptr, FAST_ELEMENTS, | 2108 HValue* weak_cell = Add<HLoadKeyed>(array, key, nullptr, FAST_ELEMENTS, |
| 2109 ALLOW_RETURN_HOLE); | 2109 ALLOW_RETURN_HOLE); |
| 2110 HValue* array_map = Add<HLoadNamedField>( | 2110 HValue* array_map = Add<HLoadNamedField>( |
| 2111 weak_cell, nullptr, HObjectAccess::ForWeakCellValue()); | 2111 weak_cell, nullptr, HObjectAccess::ForWeakCellValueComparison()); |
| 2112 IfBuilder if_correct_poly_map(this); | 2112 IfBuilder if_correct_poly_map(this); |
| 2113 if_correct_poly_map.If<HCompareObjectEqAndBranch>(receiver_map, | 2113 if_correct_poly_map.If<HCompareObjectEqAndBranch>(receiver_map, |
| 2114 array_map); | 2114 array_map); |
| 2115 if_correct_poly_map.Then(); | 2115 if_correct_poly_map.Then(); |
| 2116 { TailCallHandler(receiver, name, array, key, slot, vector); } | 2116 { TailCallHandler(receiver, name, array, key, slot, vector); } |
| 2117 } | 2117 } |
| 2118 builder.EndBody(); | 2118 builder.EndBody(); |
| 2119 } | 2119 } |
| 2120 if_correct_map.End(); | 2120 if_correct_map.End(); |
| 2121 } | 2121 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 // megamorphic case is handled as part of the default stub. | 2248 // megamorphic case is handled as part of the default stub. |
| 2249 DCHECK(!FLAG_vector_ics); | 2249 DCHECK(!FLAG_vector_ics); |
| 2250 | 2250 |
| 2251 // Probe the stub cache. | 2251 // Probe the stub cache. |
| 2252 Add<HTailCallThroughMegamorphicCache>(receiver, name); | 2252 Add<HTailCallThroughMegamorphicCache>(receiver, name); |
| 2253 | 2253 |
| 2254 // We never continue. | 2254 // We never continue. |
| 2255 return graph()->GetConstant0(); | 2255 return graph()->GetConstant0(); |
| 2256 } | 2256 } |
| 2257 } } // namespace v8::internal | 2257 } } // namespace v8::internal |
| OLD | NEW |