Chromium Code Reviews| 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 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1317 StoreGlobalStub* stub = casted_stub(); | 1317 StoreGlobalStub* stub = casted_stub(); |
| 1318 HParameter* value = GetParameter(StoreDescriptor::kValueIndex); | 1318 HParameter* value = GetParameter(StoreDescriptor::kValueIndex); |
| 1319 if (stub->check_global()) { | 1319 if (stub->check_global()) { |
| 1320 // Check that the map of the global has not changed: use a placeholder map | 1320 // Check that the map of the global has not changed: use a placeholder map |
| 1321 // that will be replaced later with the global object's map. | 1321 // that will be replaced later with the global object's map. |
| 1322 HParameter* proxy = GetParameter(StoreDescriptor::kReceiverIndex); | 1322 HParameter* proxy = GetParameter(StoreDescriptor::kReceiverIndex); |
| 1323 HValue* proxy_map = | 1323 HValue* proxy_map = |
| 1324 Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap()); | 1324 Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap()); |
| 1325 HValue* global = | 1325 HValue* global = |
| 1326 Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype()); | 1326 Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype()); |
| 1327 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); | 1327 HValue* map_cell = Add<HConstant>(isolate()->factory()->NewWeakCell( |
| 1328 HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map)); | 1328 StoreGlobalStub::global_map_placeholder(isolate()))); |
| 1329 HValue* expected_map = | 1329 HValue* expected_map = Add<HLoadNamedField>( |
| 1330 Add<HLoadNamedField>(cell, nullptr, HObjectAccess::ForWeakCellValue()); | 1330 map_cell, nullptr, HObjectAccess::ForWeakCellValue()); |
| 1331 HValue* map = | 1331 HValue* map = |
| 1332 Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap()); | 1332 Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap()); |
| 1333 IfBuilder map_check(this); | 1333 IfBuilder map_check(this); |
| 1334 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); | 1334 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); |
| 1335 map_check.ThenDeopt(Deoptimizer::kUnknownMap); | 1335 map_check.ThenDeopt(Deoptimizer::kUnknownMap); |
| 1336 map_check.End(); | 1336 map_check.End(); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 HValue* weak_cell = Add<HConstant>(isolate()->factory()->NewWeakCell( | 1339 HValue* weak_cell = Add<HConstant>(isolate()->factory()->NewWeakCell( |
| 1340 StoreGlobalStub::property_cell_placeholder(isolate()))); | 1340 StoreGlobalStub::property_cell_placeholder(isolate()))); |
| 1341 HValue* cell = Add<HLoadNamedField>(weak_cell, nullptr, | 1341 HValue* cell = Add<HLoadNamedField>(weak_cell, nullptr, |
| 1342 HObjectAccess::ForWeakCellValue()); | 1342 HObjectAccess::ForWeakCellValue()); |
| 1343 Add<HCheckHeapObject>(cell); | 1343 Add<HCheckHeapObject>(cell); |
| 1344 HObjectAccess access = HObjectAccess::ForPropertyCellValue(); | 1344 HObjectAccess access = HObjectAccess::ForPropertyCellValue(); |
| 1345 // Load the payload of the global parameter cell. A hole indicates that the | |
| 1346 // cell has been invalidated and that the store must be handled by the | |
| 1347 // runtime. | |
| 1345 HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access); | 1348 HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access); |
| 1346 | 1349 |
| 1347 if (stub->is_constant()) { | 1350 auto cell_type = stub->cell_type(); |
| 1351 if (cell_type == PropertyCellType::kConstant || | |
| 1352 cell_type == PropertyCellType::kUndefined) { | |
| 1353 // This is always valid for all states a cell can be in. | |
| 1348 IfBuilder builder(this); | 1354 IfBuilder builder(this); |
| 1349 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); | 1355 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); |
| 1350 builder.Then(); | 1356 builder.Then(); |
| 1351 builder.ElseDeopt( | 1357 builder.ElseDeopt( |
| 1352 Deoptimizer::kUnexpectedCellContentsInConstantGlobalStore); | 1358 Deoptimizer::kUnexpectedCellContentsInConstantGlobalStore); |
| 1353 builder.End(); | 1359 builder.End(); |
| 1354 } else { | 1360 } else { |
| 1355 // Load the payload of the global parameter cell. A hole indicates that the | |
| 1356 // property has been deleted and that the store must be handled by the | |
| 1357 // runtime. | |
| 1358 IfBuilder builder(this); | 1361 IfBuilder builder(this); |
| 1359 HValue* hole_value = graph()->GetConstantHole(); | 1362 HValue* hole_value = graph()->GetConstantHole(); |
| 1360 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); | 1363 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
| 1361 builder.Then(); | 1364 builder.Then(); |
| 1362 builder.Deopt(Deoptimizer::kUnexpectedCellContentsInGlobalStore); | 1365 builder.Deopt(Deoptimizer::kUnexpectedCellContentsInGlobalStore); |
| 1363 builder.Else(); | 1366 builder.Else(); |
| 1364 Add<HStoreNamedField>(cell, access, value); | 1367 // When dealing with constant types, the type may be allowed to change, as |
| 1368 // long as optimized code remains valid. | |
| 1369 StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE; | |
| 1370 if (cell_type == PropertyCellType::kConstantType) { | |
| 1371 // store_mode = STORE_TO_INITIALIZED_ENTRY; | |
|
dcarney
2015/04/21 07:20:07
i had to comment these out because there was some
| |
| 1372 switch (stub->constant_type()) { | |
| 1373 case PropertyCellConstantType::kSmi: | |
| 1374 Add<HCheckSmi>(value); | |
|
Toon Verwaest
2015/04/21 08:06:23
This shouldn't be necessary; there'll be (should b
| |
| 1375 access = access.WithRepresentation(Representation::Smi()); | |
|
dcarney
2015/04/21 07:20:07
here i have a smi check and a withrepresentation.
| |
| 1376 break; | |
| 1377 case PropertyCellConstantType::kStableMap: { | |
| 1378 // It is sufficient here to check that the value and cell contents | |
| 1379 // have identical maps, no matter if they are stable or not or if they | |
| 1380 // are the maps that were originally in the cell or not. If optimized | |
| 1381 // code will deopt when a cell has a unstable map and if it has a | |
| 1382 // dependency on a stable map, it will deopt if the map destabilizes. | |
| 1383 Add<HCheckHeapObject>(value); | |
|
Toon Verwaest
2015/04/21 08:06:23
This OTOH is necessary since there's no such thing
| |
| 1384 Add<HCheckHeapObject>(cell_contents); | |
| 1385 HValue* expected_map = Add<HLoadNamedField>(cell_contents, nullptr, | |
| 1386 HObjectAccess::ForMap()); | |
| 1387 HValue* map = | |
| 1388 Add<HLoadNamedField>(value, nullptr, HObjectAccess::ForMap()); | |
| 1389 IfBuilder map_check(this); | |
| 1390 map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); | |
| 1391 map_check.ThenDeopt(Deoptimizer::kUnknownMap); | |
| 1392 map_check.End(); | |
| 1393 access = access.WithRepresentation(Representation::HeapObject()); | |
| 1394 break; | |
| 1395 } | |
| 1396 } | |
| 1397 } | |
| 1398 Add<HStoreNamedField>(cell, access, value, store_mode); | |
| 1365 builder.End(); | 1399 builder.End(); |
| 1366 } | 1400 } |
| 1367 | 1401 |
| 1368 return value; | 1402 return value; |
| 1369 } | 1403 } |
| 1370 | 1404 |
| 1371 | 1405 |
| 1372 Handle<Code> StoreGlobalStub::GenerateCode() { | 1406 Handle<Code> StoreGlobalStub::GenerateCode() { |
| 1373 return DoGenerateCode(this); | 1407 return DoGenerateCode(this); |
| 1374 } | 1408 } |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2033 // need. | 2067 // need. |
| 2034 info()->MarkMustNotHaveEagerFrame(); | 2068 info()->MarkMustNotHaveEagerFrame(); |
| 2035 | 2069 |
| 2036 // Probe the stub cache. | 2070 // Probe the stub cache. |
| 2037 Add<HTailCallThroughMegamorphicCache>(receiver, name); | 2071 Add<HTailCallThroughMegamorphicCache>(receiver, name); |
| 2038 | 2072 |
| 2039 // We never continue. | 2073 // We never continue. |
| 2040 return graph()->GetConstant0(); | 2074 return graph()->GetConstant0(); |
| 2041 } | 2075 } |
| 2042 } } // namespace v8::internal | 2076 } } // namespace v8::internal |
| OLD | NEW |