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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include "src/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
8 #include "src/crankshaft/hydrogen.h" | 8 #include "src/crankshaft/hydrogen.h" |
9 #include "src/crankshaft/lithium.h" | 9 #include "src/crankshaft/lithium.h" |
10 #include "src/field-index.h" | 10 #include "src/field-index.h" |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 } | 1425 } |
1426 | 1426 |
1427 | 1427 |
1428 Handle<Code> StoreFastElementStub::GenerateCode() { | 1428 Handle<Code> StoreFastElementStub::GenerateCode() { |
1429 return DoGenerateCode(this); | 1429 return DoGenerateCode(this); |
1430 } | 1430 } |
1431 | 1431 |
1432 | 1432 |
1433 template <> | 1433 template <> |
1434 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { | 1434 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { |
| 1435 ElementsKind const from_kind = casted_stub()->from_kind(); |
| 1436 ElementsKind const to_kind = casted_stub()->to_kind(); |
| 1437 HValue* const object = GetParameter(0); |
| 1438 HValue* const map = GetParameter(1); |
| 1439 |
| 1440 // The {object} is known to be a JSObject (otherwise it wouldn't have elements |
| 1441 // anyways). |
| 1442 object->set_type(HType::JSObject()); |
| 1443 |
1435 info()->MarkAsSavesCallerDoubles(); | 1444 info()->MarkAsSavesCallerDoubles(); |
1436 | 1445 |
1437 BuildTransitionElementsKind(GetParameter(0), | 1446 DCHECK_IMPLIES(IsFastHoleyElementsKind(from_kind), |
1438 GetParameter(1), | 1447 IsFastHoleyElementsKind(to_kind)); |
1439 casted_stub()->from_kind(), | |
1440 casted_stub()->to_kind(), | |
1441 casted_stub()->is_js_array()); | |
1442 | 1448 |
1443 return GetParameter(0); | 1449 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { |
| 1450 Add<HTrapAllocationMemento>(object); |
| 1451 } |
| 1452 |
| 1453 if (!IsSimpleMapChangeTransition(from_kind, to_kind)) { |
| 1454 HInstruction* elements = AddLoadElements(object); |
| 1455 |
| 1456 IfBuilder if_objecthaselements(this); |
| 1457 if_objecthaselements.IfNot<HCompareObjectEqAndBranch>( |
| 1458 elements, Add<HConstant>(isolate()->factory()->empty_fixed_array())); |
| 1459 if_objecthaselements.Then(); |
| 1460 { |
| 1461 // Determine the elements capacity. |
| 1462 HInstruction* elements_length = AddLoadFixedArrayLength(elements); |
| 1463 |
| 1464 // Determine the effective (array) length. |
| 1465 IfBuilder if_objectisarray(this); |
| 1466 if_objectisarray.If<HHasInstanceTypeAndBranch>(object, JS_ARRAY_TYPE); |
| 1467 if_objectisarray.Then(); |
| 1468 { |
| 1469 // The {object} is a JSArray, load the special "length" property. |
| 1470 Push(Add<HLoadNamedField>(object, nullptr, |
| 1471 HObjectAccess::ForArrayLength(from_kind))); |
| 1472 } |
| 1473 if_objectisarray.Else(); |
| 1474 { |
| 1475 // The {object} is some other JSObject. |
| 1476 Push(elements_length); |
| 1477 } |
| 1478 if_objectisarray.End(); |
| 1479 HValue* length = Pop(); |
| 1480 |
| 1481 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, length, |
| 1482 elements_length); |
| 1483 } |
| 1484 if_objecthaselements.End(); |
| 1485 } |
| 1486 |
| 1487 Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map); |
| 1488 |
| 1489 return object; |
1444 } | 1490 } |
1445 | 1491 |
1446 | 1492 |
1447 Handle<Code> TransitionElementsKindStub::GenerateCode() { | 1493 Handle<Code> TransitionElementsKindStub::GenerateCode() { |
1448 return DoGenerateCode(this); | 1494 return DoGenerateCode(this); |
1449 } | 1495 } |
1450 | 1496 |
1451 template <> | 1497 template <> |
1452 HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() { | 1498 HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() { |
1453 BinaryOpICState state = casted_stub()->state(); | 1499 BinaryOpICState state = casted_stub()->state(); |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 return Pop(); | 2300 return Pop(); |
2255 } | 2301 } |
2256 | 2302 |
2257 | 2303 |
2258 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 2304 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
2259 return DoGenerateCode(this); | 2305 return DoGenerateCode(this); |
2260 } | 2306 } |
2261 | 2307 |
2262 } // namespace internal | 2308 } // namespace internal |
2263 } // namespace v8 | 2309 } // namespace v8 |
OLD | NEW |