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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 UNIMPLEMENTED(); | 221 UNIMPLEMENTED(); |
222 return NULL; | 222 return NULL; |
223 } | 223 } |
224 | 224 |
225 virtual HValue* BuildCodeUninitializedStub() { | 225 virtual HValue* BuildCodeUninitializedStub() { |
226 // Force a deopt that falls back to the runtime. | 226 // Force a deopt that falls back to the runtime. |
227 HValue* undefined = graph()->GetConstantUndefined(); | 227 HValue* undefined = graph()->GetConstantUndefined(); |
228 IfBuilder builder(this); | 228 IfBuilder builder(this); |
229 builder.IfNot<HCompareObjectEqAndBranch, HValue*>(undefined, undefined); | 229 builder.IfNot<HCompareObjectEqAndBranch, HValue*>(undefined, undefined); |
230 builder.Then(); | 230 builder.Then(); |
231 builder.ElseDeopt("Forced deopt to runtime"); | 231 builder.ElseDeopt(Deoptimizer::kForcedDeoptToRuntime); |
232 return undefined; | 232 return undefined; |
233 } | 233 } |
234 | 234 |
235 Stub* casted_stub() { return static_cast<Stub*>(stub()); } | 235 Stub* casted_stub() { return static_cast<Stub*>(stub()); } |
236 }; | 236 }; |
237 | 237 |
238 | 238 |
239 Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode( | 239 Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode( |
240 ExternalReference miss) { | 240 ExternalReference miss) { |
241 Factory* factory = isolate()->factory(); | 241 Factory* factory = isolate()->factory(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 if_fixed.Else(); | 363 if_fixed.Else(); |
364 Push(BuildCloneShallowArrayNonEmpty(boilerplate, | 364 Push(BuildCloneShallowArrayNonEmpty(boilerplate, |
365 allocation_site, | 365 allocation_site, |
366 alloc_site_mode, | 366 alloc_site_mode, |
367 FAST_DOUBLE_ELEMENTS)); | 367 FAST_DOUBLE_ELEMENTS)); |
368 if_fixed.End(); | 368 if_fixed.End(); |
369 if_fixed_cow.End(); | 369 if_fixed_cow.End(); |
370 zero_capacity.End(); | 370 zero_capacity.End(); |
371 | 371 |
372 checker.ElseDeopt("Uninitialized boilerplate literals"); | 372 checker.ElseDeopt(Deoptimizer::kUninitializedBoilerplateLiterals); |
373 checker.End(); | 373 checker.End(); |
374 | 374 |
375 return environment()->Pop(); | 375 return environment()->Pop(); |
376 } | 376 } |
377 | 377 |
378 | 378 |
379 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | 379 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
380 return DoGenerateCode(this); | 380 return DoGenerateCode(this); |
381 } | 381 } |
382 | 382 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 Add<HLoadNamedField>(boilerplate, nullptr, access)); | 429 Add<HLoadNamedField>(boilerplate, nullptr, access)); |
430 } | 430 } |
431 | 431 |
432 DCHECK(FLAG_allocation_site_pretenuring || (size == object_size)); | 432 DCHECK(FLAG_allocation_site_pretenuring || (size == object_size)); |
433 if (FLAG_allocation_site_pretenuring) { | 433 if (FLAG_allocation_site_pretenuring) { |
434 BuildCreateAllocationMemento( | 434 BuildCreateAllocationMemento( |
435 object, Add<HConstant>(object_size), allocation_site); | 435 object, Add<HConstant>(object_size), allocation_site); |
436 } | 436 } |
437 | 437 |
438 environment()->Push(object); | 438 environment()->Push(object); |
439 checker.ElseDeopt("Uninitialized boilerplate in fast clone"); | 439 checker.ElseDeopt(Deoptimizer::kUninitializedBoilerplateInFastClone); |
440 checker.End(); | 440 checker.End(); |
441 | 441 |
442 return environment()->Pop(); | 442 return environment()->Pop(); |
443 } | 443 } |
444 | 444 |
445 | 445 |
446 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | 446 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
447 return DoGenerateCode(this); | 447 return DoGenerateCode(this); |
448 } | 448 } |
449 | 449 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 HValue* backing_store_length = Add<HLoadNamedField>( | 628 HValue* backing_store_length = Add<HLoadNamedField>( |
629 backing_store, nullptr, HObjectAccess::ForFixedArrayLength()); | 629 backing_store, nullptr, HObjectAccess::ForFixedArrayLength()); |
630 IfBuilder in_unmapped_range(this); | 630 IfBuilder in_unmapped_range(this); |
631 in_unmapped_range.If<HCompareNumericAndBranch>(key, backing_store_length, | 631 in_unmapped_range.If<HCompareNumericAndBranch>(key, backing_store_length, |
632 Token::LT); | 632 Token::LT); |
633 in_unmapped_range.Then(); | 633 in_unmapped_range.Then(); |
634 { | 634 { |
635 result = Add<HLoadKeyed>(backing_store, key, nullptr, FAST_HOLEY_ELEMENTS, | 635 result = Add<HLoadKeyed>(backing_store, key, nullptr, FAST_HOLEY_ELEMENTS, |
636 NEVER_RETURN_HOLE); | 636 NEVER_RETURN_HOLE); |
637 } | 637 } |
638 in_unmapped_range.ElseDeopt("Outside of range"); | 638 in_unmapped_range.ElseDeopt(Deoptimizer::kOutsideOfRange); |
639 in_unmapped_range.End(); | 639 in_unmapped_range.End(); |
640 return result; | 640 return result; |
641 } | 641 } |
642 | 642 |
643 | 643 |
644 template <> | 644 template <> |
645 HValue* CodeStubGraphBuilder<KeyedLoadSloppyArgumentsStub>::BuildCodeStub() { | 645 HValue* CodeStubGraphBuilder<KeyedLoadSloppyArgumentsStub>::BuildCodeStub() { |
646 HValue* receiver = GetParameter(LoadDescriptor::kReceiverIndex); | 646 HValue* receiver = GetParameter(LoadDescriptor::kReceiverIndex); |
647 HValue* key = GetParameter(LoadDescriptor::kNameIndex); | 647 HValue* key = GetParameter(LoadDescriptor::kNameIndex); |
648 | 648 |
(...skipping 20 matching lines...) Expand all Loading... |
669 // | 669 // |
670 // Otherwise, t = elements[key + 2]. If t is the hole, then look up the value | 670 // Otherwise, t = elements[key + 2]. If t is the hole, then look up the value |
671 // in the unmapped arguments array, as described above. Otherwise, t is a Smi | 671 // in the unmapped arguments array, as described above. Otherwise, t is a Smi |
672 // index into the context array given at elements[0]. Return the value at | 672 // index into the context array given at elements[0]. Return the value at |
673 // context[t]. | 673 // context[t]. |
674 | 674 |
675 key = AddUncasted<HForceRepresentation>(key, Representation::Smi()); | 675 key = AddUncasted<HForceRepresentation>(key, Representation::Smi()); |
676 IfBuilder positive_smi(this); | 676 IfBuilder positive_smi(this); |
677 positive_smi.If<HCompareNumericAndBranch>(key, graph()->GetConstant0(), | 677 positive_smi.If<HCompareNumericAndBranch>(key, graph()->GetConstant0(), |
678 Token::LT); | 678 Token::LT); |
679 positive_smi.ThenDeopt("key is negative"); | 679 positive_smi.ThenDeopt(Deoptimizer::kKeyIsNegative); |
680 positive_smi.End(); | 680 positive_smi.End(); |
681 | 681 |
682 HValue* constant_two = Add<HConstant>(2); | 682 HValue* constant_two = Add<HConstant>(2); |
683 HValue* elements = AddLoadElements(receiver, nullptr); | 683 HValue* elements = AddLoadElements(receiver, nullptr); |
684 HValue* elements_length = Add<HLoadNamedField>( | 684 HValue* elements_length = Add<HLoadNamedField>( |
685 elements, nullptr, HObjectAccess::ForFixedArrayLength()); | 685 elements, nullptr, HObjectAccess::ForFixedArrayLength()); |
686 HValue* adjusted_length = AddUncasted<HSub>(elements_length, constant_two); | 686 HValue* adjusted_length = AddUncasted<HSub>(elements_length, constant_two); |
687 IfBuilder in_range(this); | 687 IfBuilder in_range(this); |
688 in_range.If<HCompareNumericAndBranch>(key, adjusted_length, Token::LT); | 688 in_range.If<HCompareNumericAndBranch>(key, adjusted_length, Token::LT); |
689 in_range.Then(); | 689 in_range.Then(); |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 } | 1326 } |
1327 | 1327 |
1328 HValue* cell = Add<HConstant>(placeholder_cell); | 1328 HValue* cell = Add<HConstant>(placeholder_cell); |
1329 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); | 1329 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); |
1330 HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access); | 1330 HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access); |
1331 | 1331 |
1332 if (stub->is_constant()) { | 1332 if (stub->is_constant()) { |
1333 IfBuilder builder(this); | 1333 IfBuilder builder(this); |
1334 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); | 1334 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); |
1335 builder.Then(); | 1335 builder.Then(); |
1336 builder.ElseDeopt("Unexpected cell contents in constant global store"); | 1336 builder.ElseDeopt( |
| 1337 Deoptimizer::kUnexpectedCellContentsInConstantGlobalStore); |
1337 builder.End(); | 1338 builder.End(); |
1338 } else { | 1339 } else { |
1339 // Load the payload of the global parameter cell. A hole indicates that the | 1340 // Load the payload of the global parameter cell. A hole indicates that the |
1340 // property has been deleted and that the store must be handled by the | 1341 // property has been deleted and that the store must be handled by the |
1341 // runtime. | 1342 // runtime. |
1342 IfBuilder builder(this); | 1343 IfBuilder builder(this); |
1343 HValue* hole_value = graph()->GetConstantHole(); | 1344 HValue* hole_value = graph()->GetConstantHole(); |
1344 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); | 1345 builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
1345 builder.Then(); | 1346 builder.Then(); |
1346 builder.Deopt("Unexpected cell contents in global store"); | 1347 builder.Deopt(Deoptimizer::kUnexpectedСellСontentsInGlobalStore); |
1347 builder.Else(); | 1348 builder.Else(); |
1348 Add<HStoreNamedField>(cell, access, value); | 1349 Add<HStoreNamedField>(cell, access, value); |
1349 builder.End(); | 1350 builder.End(); |
1350 } | 1351 } |
1351 | 1352 |
1352 return value; | 1353 return value; |
1353 } | 1354 } |
1354 | 1355 |
1355 | 1356 |
1356 Handle<Code> StoreGlobalStub::GenerateCode() { | 1357 Handle<Code> StoreGlobalStub::GenerateCode() { |
1357 return DoGenerateCode(this); | 1358 return DoGenerateCode(this); |
1358 } | 1359 } |
1359 | 1360 |
1360 | 1361 |
1361 template<> | 1362 template<> |
1362 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() { | 1363 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() { |
1363 HValue* value = GetParameter(ElementsTransitionAndStoreStub::kValueIndex); | 1364 HValue* value = GetParameter(ElementsTransitionAndStoreStub::kValueIndex); |
1364 HValue* map = GetParameter(ElementsTransitionAndStoreStub::kMapIndex); | 1365 HValue* map = GetParameter(ElementsTransitionAndStoreStub::kMapIndex); |
1365 HValue* key = GetParameter(ElementsTransitionAndStoreStub::kKeyIndex); | 1366 HValue* key = GetParameter(ElementsTransitionAndStoreStub::kKeyIndex); |
1366 HValue* object = GetParameter(ElementsTransitionAndStoreStub::kObjectIndex); | 1367 HValue* object = GetParameter(ElementsTransitionAndStoreStub::kObjectIndex); |
1367 | 1368 |
1368 if (FLAG_trace_elements_transitions) { | 1369 if (FLAG_trace_elements_transitions) { |
1369 // Tracing elements transitions is the job of the runtime. | 1370 // Tracing elements transitions is the job of the runtime. |
1370 Add<HDeoptimize>("Tracing elements transitions", Deoptimizer::EAGER); | 1371 Add<HDeoptimize>(Deoptimizer::kTracingElementsTransitions, |
| 1372 Deoptimizer::EAGER); |
1371 } else { | 1373 } else { |
1372 info()->MarkAsSavesCallerDoubles(); | 1374 info()->MarkAsSavesCallerDoubles(); |
1373 | 1375 |
1374 BuildTransitionElementsKind(object, map, | 1376 BuildTransitionElementsKind(object, map, |
1375 casted_stub()->from_kind(), | 1377 casted_stub()->from_kind(), |
1376 casted_stub()->to_kind(), | 1378 casted_stub()->to_kind(), |
1377 casted_stub()->is_jsarray()); | 1379 casted_stub()->is_jsarray()); |
1378 | 1380 |
1379 BuildUncheckedMonomorphicElementAccess(object, key, value, | 1381 BuildUncheckedMonomorphicElementAccess(object, key, value, |
1380 casted_stub()->is_jsarray(), | 1382 casted_stub()->is_jsarray(), |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 HValue* hash = BuildElementIndexHash(key); | 1825 HValue* hash = BuildElementIndexHash(key); |
1824 | 1826 |
1825 Push(BuildUncheckedDictionaryElementLoad(receiver, elements, key, hash)); | 1827 Push(BuildUncheckedDictionaryElementLoad(receiver, elements, key, hash)); |
1826 } | 1828 } |
1827 kind_if.Else(); | 1829 kind_if.Else(); |
1828 | 1830 |
1829 // The SLOPPY_ARGUMENTS_ELEMENTS check generates a "kind_if.Then" | 1831 // The SLOPPY_ARGUMENTS_ELEMENTS check generates a "kind_if.Then" |
1830 BuildElementsKindLimitCheck(&kind_if, bit_field2, | 1832 BuildElementsKindLimitCheck(&kind_if, bit_field2, |
1831 SLOPPY_ARGUMENTS_ELEMENTS); | 1833 SLOPPY_ARGUMENTS_ELEMENTS); |
1832 // Non-strict elements are not handled. | 1834 // Non-strict elements are not handled. |
1833 Add<HDeoptimize>("non-strict elements in KeyedLoadGenericStub", | 1835 Add<HDeoptimize>(Deoptimizer::kNonStrictElementsInKeyedLoadGenericStub, |
1834 Deoptimizer::EAGER); | 1836 Deoptimizer::EAGER); |
1835 Push(graph()->GetConstant0()); | 1837 Push(graph()->GetConstant0()); |
1836 | 1838 |
1837 kind_if.Else(); | 1839 kind_if.Else(); |
1838 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1840 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1839 EXTERNAL_INT8_ELEMENTS); | 1841 EXTERNAL_INT8_ELEMENTS); |
1840 | 1842 |
1841 kind_if.Else(); | 1843 kind_if.Else(); |
1842 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1844 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1843 EXTERNAL_UINT8_ELEMENTS); | 1845 EXTERNAL_UINT8_ELEMENTS); |
(...skipping 19 matching lines...) Expand all Loading... |
1863 EXTERNAL_FLOAT32_ELEMENTS); | 1865 EXTERNAL_FLOAT32_ELEMENTS); |
1864 | 1866 |
1865 kind_if.Else(); | 1867 kind_if.Else(); |
1866 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1868 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1867 EXTERNAL_FLOAT64_ELEMENTS); | 1869 EXTERNAL_FLOAT64_ELEMENTS); |
1868 | 1870 |
1869 kind_if.Else(); | 1871 kind_if.Else(); |
1870 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, | 1872 BuildExternalElementLoad(&kind_if, receiver, key, instance_type, bit_field2, |
1871 EXTERNAL_UINT8_CLAMPED_ELEMENTS); | 1873 EXTERNAL_UINT8_CLAMPED_ELEMENTS); |
1872 | 1874 |
1873 kind_if.ElseDeopt("ElementsKind unhandled in KeyedLoadGenericStub"); | 1875 kind_if.ElseDeopt( |
| 1876 Deoptimizer::kElementsKindUnhandledInKeyedLoadGenericStub); |
1874 | 1877 |
1875 kind_if.End(); | 1878 kind_if.End(); |
1876 } | 1879 } |
1877 index_name_split.Else(); | 1880 index_name_split.Else(); |
1878 { | 1881 { |
1879 // Key is a unique string. | 1882 // Key is a unique string. |
1880 key = Pop(); | 1883 key = Pop(); |
1881 | 1884 |
1882 int bit_field_mask = (1 << Map::kIsAccessCheckNeeded) | | 1885 int bit_field_mask = (1 << Map::kIsAccessCheckNeeded) | |
1883 (1 << Map::kHasNamedInterceptor); | 1886 (1 << Map::kHasNamedInterceptor); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 // megamorphic case is handled as part of the default stub. | 2219 // megamorphic case is handled as part of the default stub. |
2217 DCHECK(!FLAG_vector_ics); | 2220 DCHECK(!FLAG_vector_ics); |
2218 | 2221 |
2219 // Probe the stub cache. | 2222 // Probe the stub cache. |
2220 Add<HTailCallThroughMegamorphicCache>(receiver, name); | 2223 Add<HTailCallThroughMegamorphicCache>(receiver, name); |
2221 | 2224 |
2222 // We never continue. | 2225 // We never continue. |
2223 return graph()->GetConstant0(); | 2226 return graph()->GetConstant0(); |
2224 } | 2227 } |
2225 } } // namespace v8::internal | 2228 } } // namespace v8::internal |
OLD | NEW |