Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 1899813003: [crankshaft] Fragmentation-free allocation folding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm64/macro-assembler-arm64.cc ('k') | src/crankshaft/arm/lithium-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 IfBuilder if_notundefined(this); 437 IfBuilder if_notundefined(this);
438 if_notundefined.IfNot<HCompareObjectEqAndBranch>( 438 if_notundefined.IfNot<HCompareObjectEqAndBranch>(
439 boilerplate, graph()->GetConstantUndefined()); 439 boilerplate, graph()->GetConstantUndefined());
440 if_notundefined.Then(); 440 if_notundefined.Then();
441 { 441 {
442 int result_size = 442 int result_size =
443 JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; 443 JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
444 HValue* result = 444 HValue* result =
445 Add<HAllocate>(Add<HConstant>(result_size), HType::JSObject(), 445 Add<HAllocate>(Add<HConstant>(result_size), HType::JSObject(),
446 NOT_TENURED, JS_REGEXP_TYPE); 446 NOT_TENURED, JS_REGEXP_TYPE, graph()->GetConstant0());
447 Add<HStoreNamedField>( 447 Add<HStoreNamedField>(
448 result, HObjectAccess::ForMap(), 448 result, HObjectAccess::ForMap(),
449 Add<HLoadNamedField>(boilerplate, nullptr, HObjectAccess::ForMap())); 449 Add<HLoadNamedField>(boilerplate, nullptr, HObjectAccess::ForMap()));
450 Add<HStoreNamedField>( 450 Add<HStoreNamedField>(
451 result, HObjectAccess::ForPropertiesPointer(), 451 result, HObjectAccess::ForPropertiesPointer(),
452 Add<HLoadNamedField>(boilerplate, nullptr, 452 Add<HLoadNamedField>(boilerplate, nullptr,
453 HObjectAccess::ForPropertiesPointer())); 453 HObjectAccess::ForPropertiesPointer()));
454 Add<HStoreNamedField>( 454 Add<HStoreNamedField>(
455 result, HObjectAccess::ForElementsPointer(), 455 result, HObjectAccess::ForElementsPointer(),
456 Add<HLoadNamedField>(boilerplate, nullptr, 456 Add<HLoadNamedField>(boilerplate, nullptr,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 549 }
550 550
551 551
552 template <> 552 template <>
553 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { 553 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
554 // This stub is performance sensitive, the generated code must be tuned 554 // This stub is performance sensitive, the generated code must be tuned
555 // so that it doesn't build an eager frame. 555 // so that it doesn't build an eager frame.
556 info()->MarkMustNotHaveEagerFrame(); 556 info()->MarkMustNotHaveEagerFrame();
557 557
558 HValue* size = Add<HConstant>(AllocationSite::kSize); 558 HValue* size = Add<HConstant>(AllocationSite::kSize);
559 HInstruction* object = Add<HAllocate>(size, HType::JSObject(), TENURED, 559 HInstruction* object =
560 JS_OBJECT_TYPE); 560 Add<HAllocate>(size, HType::JSObject(), TENURED, JS_OBJECT_TYPE,
561 graph()->GetConstant0());
561 562
562 // Store the map 563 // Store the map
563 Handle<Map> allocation_site_map = isolate()->factory()->allocation_site_map(); 564 Handle<Map> allocation_site_map = isolate()->factory()->allocation_site_map();
564 AddStoreMapConstant(object, allocation_site_map); 565 AddStoreMapConstant(object, allocation_site_map);
565 566
566 // Store the payload (smi elements kind) 567 // Store the payload (smi elements kind)
567 HValue* initial_elements_kind = Add<HConstant>(GetInitialFastElementsKind()); 568 HValue* initial_elements_kind = Add<HConstant>(GetInitialFastElementsKind());
568 Add<HStoreNamedField>(object, 569 Add<HStoreNamedField>(object,
569 HObjectAccess::ForAllocationSiteOffset( 570 HObjectAccess::ForAllocationSiteOffset(
570 AllocationSite::kTransitionInfoOffset), 571 AllocationSite::kTransitionInfoOffset),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 629
629 630
630 template <> 631 template <>
631 HValue* CodeStubGraphBuilder<CreateWeakCellStub>::BuildCodeStub() { 632 HValue* CodeStubGraphBuilder<CreateWeakCellStub>::BuildCodeStub() {
632 // This stub is performance sensitive, the generated code must be tuned 633 // This stub is performance sensitive, the generated code must be tuned
633 // so that it doesn't build an eager frame. 634 // so that it doesn't build an eager frame.
634 info()->MarkMustNotHaveEagerFrame(); 635 info()->MarkMustNotHaveEagerFrame();
635 636
636 HValue* size = Add<HConstant>(WeakCell::kSize); 637 HValue* size = Add<HConstant>(WeakCell::kSize);
637 HInstruction* object = 638 HInstruction* object =
638 Add<HAllocate>(size, HType::JSObject(), TENURED, JS_OBJECT_TYPE); 639 Add<HAllocate>(size, HType::JSObject(), TENURED, JS_OBJECT_TYPE,
640 graph()->GetConstant0());
639 641
640 Handle<Map> weak_cell_map = isolate()->factory()->weak_cell_map(); 642 Handle<Map> weak_cell_map = isolate()->factory()->weak_cell_map();
641 AddStoreMapConstant(object, weak_cell_map); 643 AddStoreMapConstant(object, weak_cell_map);
642 644
643 HInstruction* value = GetParameter(CreateWeakCellDescriptor::kValueIndex); 645 HInstruction* value = GetParameter(CreateWeakCellDescriptor::kValueIndex);
644 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellValue(), value); 646 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellValue(), value);
645 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellNext(), 647 Add<HStoreNamedField>(object, HObjectAccess::ForWeakCellNext(),
646 graph()->GetConstantHole()); 648 graph()->GetConstantHole());
647 649
648 HInstruction* feedback_vector = 650 HInstruction* feedback_vector =
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 HObjectAccess heap_number_access = 1162 HObjectAccess heap_number_access =
1161 access.WithRepresentation(Representation::Tagged()); 1163 access.WithRepresentation(Representation::Tagged());
1162 if (transition_to_field) { 1164 if (transition_to_field) {
1163 // The store requires a mutable HeapNumber to be allocated. 1165 // The store requires a mutable HeapNumber to be allocated.
1164 NoObservableSideEffectsScope no_side_effects(this); 1166 NoObservableSideEffectsScope no_side_effects(this);
1165 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); 1167 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize);
1166 1168
1167 // TODO(hpayer): Allocation site pretenuring support. 1169 // TODO(hpayer): Allocation site pretenuring support.
1168 HInstruction* heap_number = 1170 HInstruction* heap_number =
1169 Add<HAllocate>(heap_number_size, HType::HeapObject(), NOT_TENURED, 1171 Add<HAllocate>(heap_number_size, HType::HeapObject(), NOT_TENURED,
1170 MUTABLE_HEAP_NUMBER_TYPE); 1172 MUTABLE_HEAP_NUMBER_TYPE, graph()->GetConstant0());
1171 AddStoreMapConstant(heap_number, 1173 AddStoreMapConstant(heap_number,
1172 isolate()->factory()->mutable_heap_number_map()); 1174 isolate()->factory()->mutable_heap_number_map());
1173 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), 1175 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(),
1174 value); 1176 value);
1175 // Store the new mutable heap number into the object. 1177 // Store the new mutable heap number into the object.
1176 access = heap_number_access; 1178 access = heap_number_access;
1177 value = heap_number; 1179 value = heap_number;
1178 } else { 1180 } else {
1179 // Load the heap number. 1181 // Load the heap number.
1180 object = Add<HLoadNamedField>(object, nullptr, heap_number_access); 1182 object = Add<HLoadNamedField>(object, nullptr, heap_number_access);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 // the array because they aren't compatible with a smi array. 1374 // the array because they aren't compatible with a smi array.
1373 // If it's a double array, no problem, and if it's fast then no 1375 // If it's a double array, no problem, and if it's fast then no
1374 // problem either because doubles are boxed. 1376 // problem either because doubles are boxed.
1375 // 1377 //
1376 // TODO(mvstanton): consider an instruction to memset fill the array 1378 // TODO(mvstanton): consider an instruction to memset fill the array
1377 // with zero in this case instead. 1379 // with zero in this case instead.
1378 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind) 1380 JSArrayBuilder::FillMode fill_mode = IsFastSmiElementsKind(kind)
1379 ? JSArrayBuilder::FILL_WITH_HOLE 1381 ? JSArrayBuilder::FILL_WITH_HOLE
1380 : JSArrayBuilder::DONT_FILL_WITH_HOLE; 1382 : JSArrayBuilder::DONT_FILL_WITH_HOLE;
1381 HValue* new_object = array_builder->AllocateArray(checked_length, 1383 HValue* new_object = array_builder->AllocateArray(checked_length,
1382 max_alloc_length,
1383 checked_length, 1384 checked_length,
1384 fill_mode); 1385 fill_mode);
1385 HValue* elements = array_builder->GetElementsLocation(); 1386 HValue* elements = array_builder->GetElementsLocation();
1386 DCHECK(elements != NULL); 1387 DCHECK(elements != NULL);
1387 1388
1388 // Now populate the elements correctly. 1389 // Now populate the elements correctly.
1389 LoopBuilder builder(this, 1390 LoopBuilder builder(this,
1390 context(), 1391 context(),
1391 LoopBuilder::kPostIncrement); 1392 LoopBuilder::kPostIncrement);
1392 HValue* start = graph()->GetConstant0(); 1393 HValue* start = graph()->GetConstant0();
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 Factory* factory = isolate()->factory(); 1890 Factory* factory = isolate()->factory();
1890 HInstruction* empty_fixed_array = 1891 HInstruction* empty_fixed_array =
1891 Add<HConstant>(factory->empty_fixed_array()); 1892 Add<HConstant>(factory->empty_fixed_array());
1892 HValue* shared_info = GetParameter(0); 1893 HValue* shared_info = GetParameter(0);
1893 1894
1894 AddIncrementCounter(counters->fast_new_closure_total()); 1895 AddIncrementCounter(counters->fast_new_closure_total());
1895 1896
1896 // Create a new closure from the given function info in new space 1897 // Create a new closure from the given function info in new space
1897 HValue* size = Add<HConstant>(JSFunction::kSize); 1898 HValue* size = Add<HConstant>(JSFunction::kSize);
1898 HInstruction* js_function = 1899 HInstruction* js_function =
1899 Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE); 1900 Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE,
1901 graph()->GetConstant0());
1900 1902
1901 int map_index = Context::FunctionMapIndex(casted_stub()->language_mode(), 1903 int map_index = Context::FunctionMapIndex(casted_stub()->language_mode(),
1902 casted_stub()->kind()); 1904 casted_stub()->kind());
1903 1905
1904 // Compute the function map in the current native context and set that 1906 // Compute the function map in the current native context and set that
1905 // as the map of the allocated object. 1907 // as the map of the allocated object.
1906 HInstruction* native_context = BuildGetNativeContext(); 1908 HInstruction* native_context = BuildGetNativeContext();
1907 HInstruction* map_slot_value = Add<HLoadNamedField>( 1909 HInstruction* map_slot_value = Add<HLoadNamedField>(
1908 native_context, nullptr, HObjectAccess::ForContextSlot(map_index)); 1910 native_context, nullptr, HObjectAccess::ForContextSlot(map_index));
1909 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value); 1911 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 template<> 1944 template<>
1943 HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() { 1945 HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() {
1944 int length = casted_stub()->slots() + Context::MIN_CONTEXT_SLOTS; 1946 int length = casted_stub()->slots() + Context::MIN_CONTEXT_SLOTS;
1945 1947
1946 // Get the function. 1948 // Get the function.
1947 HParameter* function = GetParameter(FastNewContextStub::kFunction); 1949 HParameter* function = GetParameter(FastNewContextStub::kFunction);
1948 1950
1949 // Allocate the context in new space. 1951 // Allocate the context in new space.
1950 HAllocate* function_context = Add<HAllocate>( 1952 HAllocate* function_context = Add<HAllocate>(
1951 Add<HConstant>(length * kPointerSize + FixedArray::kHeaderSize), 1953 Add<HConstant>(length * kPointerSize + FixedArray::kHeaderSize),
1952 HType::HeapObject(), NOT_TENURED, FIXED_ARRAY_TYPE); 1954 HType::HeapObject(), NOT_TENURED, FIXED_ARRAY_TYPE,
1955 graph()->GetConstant0());
1953 1956
1954 // Set up the object header. 1957 // Set up the object header.
1955 AddStoreMapConstant(function_context, 1958 AddStoreMapConstant(function_context,
1956 isolate()->factory()->function_context_map()); 1959 isolate()->factory()->function_context_map());
1957 Add<HStoreNamedField>(function_context, 1960 Add<HStoreNamedField>(function_context,
1958 HObjectAccess::ForFixedArrayLength(), 1961 HObjectAccess::ForFixedArrayLength(),
1959 Add<HConstant>(length)); 1962 Add<HConstant>(length));
1960 1963
1961 // Set up the fixed slots. 1964 // Set up the fixed slots.
1962 Add<HStoreNamedField>(function_context, 1965 Add<HStoreNamedField>(function_context,
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 return Pop(); 2274 return Pop();
2272 } 2275 }
2273 2276
2274 2277
2275 Handle<Code> KeyedLoadGenericStub::GenerateCode() { 2278 Handle<Code> KeyedLoadGenericStub::GenerateCode() {
2276 return DoGenerateCode(this); 2279 return DoGenerateCode(this);
2277 } 2280 }
2278 2281
2279 } // namespace internal 2282 } // namespace internal
2280 } // namespace v8 2283 } // namespace v8
OLDNEW
« no previous file with comments | « src/arm64/macro-assembler-arm64.cc ('k') | src/crankshaft/arm/lithium-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698