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 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 | 1303 |
1304 | 1304 |
1305 Handle<Code> ToBooleanStub::GenerateCode() { | 1305 Handle<Code> ToBooleanStub::GenerateCode() { |
1306 return DoGenerateCode(this); | 1306 return DoGenerateCode(this); |
1307 } | 1307 } |
1308 | 1308 |
1309 | 1309 |
1310 template <> | 1310 template <> |
1311 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { | 1311 HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { |
1312 StoreGlobalStub* stub = casted_stub(); | 1312 StoreGlobalStub* stub = casted_stub(); |
1313 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); | |
1314 Handle<PropertyCell> placeholder_cell = | |
1315 isolate()->factory()->NewPropertyCell(placeholer_value); | |
1316 HParameter* value = GetParameter(StoreDescriptor::kValueIndex); | 1313 HParameter* value = GetParameter(StoreDescriptor::kValueIndex); |
1317 if (stub->check_global()) { | 1314 if (stub->check_global()) { |
1318 // Check that the map of the global has not changed: use a placeholder map | 1315 // Check that the map of the global has not changed: use a placeholder map |
1319 // that will be replaced later with the global object's map. | 1316 // that will be replaced later with the global object's map. |
1320 HParameter* proxy = GetParameter(StoreDescriptor::kReceiverIndex); | 1317 HParameter* proxy = GetParameter(StoreDescriptor::kReceiverIndex); |
1321 HValue* proxy_map = | 1318 HValue* proxy_map = |
1322 Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap()); | 1319 Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap()); |
1323 HValue* global = | 1320 HValue* global = |
1324 Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype()); | 1321 Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype()); |
1325 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); | 1322 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); |
1326 HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map)); | 1323 HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map)); |
1327 HValue* expected_map = | 1324 HValue* expected_map = |
1328 Add<HLoadNamedField>(cell, nullptr, HObjectAccess::ForWeakCellValue()); | 1325 Add<HLoadNamedField>(cell, nullptr, HObjectAccess::ForWeakCellValue()); |
1329 HValue* map = | 1326 HValue* map = |
1330 Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap()); | 1327 Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap()); |
1331 IfBuilder map_check(this); | 1328 IfBuilder map_check(this); |
1332 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); | 1329 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); |
1333 map_check.ThenDeopt("Unknown map"); | 1330 map_check.ThenDeopt("Unknown map"); |
1334 map_check.End(); | 1331 map_check.End(); |
1335 } | 1332 } |
1336 | 1333 |
1337 HValue* cell = Add<HConstant>(placeholder_cell); | 1334 HValue* weak_cell = Add<HConstant>(isolate()->factory()->NewWeakCell( |
| 1335 StoreGlobalStub::property_cell_placeholder(isolate()))); |
| 1336 HValue* cell = Add<HLoadNamedField>(weak_cell, nullptr, |
| 1337 HObjectAccess::ForWeakCellValue()); |
1338 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); | 1338 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); |
1339 HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access); | 1339 HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access); |
1340 | 1340 |
1341 if (stub->is_constant()) { | 1341 if (stub->is_constant()) { |
1342 IfBuilder builder(this); | 1342 IfBuilder builder(this); |
1343 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); | 1343 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); |
1344 builder.Then(); | 1344 builder.Then(); |
1345 builder.ElseDeopt("Unexpected cell contents in constant global store"); | 1345 builder.ElseDeopt("Unexpected cell contents in constant global store"); |
1346 builder.End(); | 1346 builder.End(); |
1347 } else { | 1347 } else { |
1348 // Load the payload of the global parameter cell. A hole indicates that the | 1348 // Load the payload of the global parameter cell. A hole indicates that the |
1349 // property has been deleted and that the store must be handled by the | 1349 // property has been deleted and that the store must be handled by the |
1350 // runtime. | 1350 // runtime. |
1351 IfBuilder builder(this); | 1351 IfBuilder builder(this); |
1352 HValue* hole_value = graph()->GetConstantHole(); | 1352 HValue* hole_value = graph()->GetConstantHole(); |
1353 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); | 1353 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
1354 builder.Then(); | 1354 builder.Then(); |
1355 builder.Deopt("Unexpected cell contents in global store"); | 1355 builder.Deopt("Unexpected cell contents in global store"); |
1356 builder.Else(); | 1356 builder.Else(); |
1357 Add<HStoreNamedField>(cell, access, value); | 1357 HStoreNamedField* store = Add<HStoreNamedField>(cell, access, value); |
| 1358 store->MarkReceiverAsCell(); |
1358 builder.End(); | 1359 builder.End(); |
1359 } | 1360 } |
1360 | 1361 |
1361 return value; | 1362 return value; |
1362 } | 1363 } |
1363 | 1364 |
1364 | 1365 |
1365 Handle<Code> StoreGlobalStub::GenerateCode() { | 1366 Handle<Code> StoreGlobalStub::GenerateCode() { |
1366 return DoGenerateCode(this); | 1367 return DoGenerateCode(this); |
1367 } | 1368 } |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 // megamorphic case is handled as part of the default stub. | 2226 // megamorphic case is handled as part of the default stub. |
2226 DCHECK(!FLAG_vector_ics); | 2227 DCHECK(!FLAG_vector_ics); |
2227 | 2228 |
2228 // Probe the stub cache. | 2229 // Probe the stub cache. |
2229 Add<HTailCallThroughMegamorphicCache>(receiver, name); | 2230 Add<HTailCallThroughMegamorphicCache>(receiver, name); |
2230 | 2231 |
2231 // We never continue. | 2232 // We never continue. |
2232 return graph()->GetConstant0(); | 2233 return graph()->GetConstant0(); |
2233 } | 2234 } |
2234 } } // namespace v8::internal | 2235 } } // namespace v8::internal |
OLD | NEW |