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

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

Issue 2544793002: [stubs] Cleanup storing of maps to objects. (Closed)
Patch Set: Created 4 years 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/code-stub-assembler.cc ('k') | src/compiler/code-assembler.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 <sstream> 7 #include <sstream>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 471 }
472 472
473 void StoreMapStub::GenerateAssembly(compiler::CodeAssemblerState* state) const { 473 void StoreMapStub::GenerateAssembly(compiler::CodeAssemblerState* state) const {
474 typedef compiler::Node Node; 474 typedef compiler::Node Node;
475 CodeStubAssembler assembler(state); 475 CodeStubAssembler assembler(state);
476 476
477 Node* receiver = assembler.Parameter(Descriptor::kReceiver); 477 Node* receiver = assembler.Parameter(Descriptor::kReceiver);
478 Node* map = assembler.Parameter(Descriptor::kMap); 478 Node* map = assembler.Parameter(Descriptor::kMap);
479 Node* value = assembler.Parameter(Descriptor::kValue); 479 Node* value = assembler.Parameter(Descriptor::kValue);
480 480
481 assembler.StoreObjectField(receiver, JSObject::kMapOffset, map); 481 assembler.StoreMap(receiver, map);
482 assembler.Return(value); 482 assembler.Return(value);
483 } 483 }
484 484
485 void StoreTransitionStub::GenerateAssembly( 485 void StoreTransitionStub::GenerateAssembly(
486 compiler::CodeAssemblerState* state) const { 486 compiler::CodeAssemblerState* state) const {
487 typedef CodeStubAssembler::Label Label; 487 typedef CodeStubAssembler::Label Label;
488 typedef compiler::Node Node; 488 typedef compiler::Node Node;
489 CodeStubAssembler assembler(state); 489 CodeStubAssembler assembler(state);
490 490
491 Node* receiver = assembler.Parameter(Descriptor::kReceiver); 491 Node* receiver = assembler.Parameter(Descriptor::kReceiver);
(...skipping 22 matching lines...) Expand all
514 DCHECK(store_mode() == StoreTransitionStub::StoreMapAndValue); 514 DCHECK(store_mode() == StoreTransitionStub::StoreMapAndValue);
515 } 515 }
516 516
517 // Store the new value into the "extended" object. 517 // Store the new value into the "extended" object.
518 assembler.Comment("Store value"); 518 assembler.Comment("Store value");
519 assembler.StoreNamedField(receiver, offset, is_inobject(), representation, 519 assembler.StoreNamedField(receiver, offset, is_inobject(), representation,
520 prepared_value, true); 520 prepared_value, true);
521 521
522 // And finally update the map. 522 // And finally update the map.
523 assembler.Comment("Store map"); 523 assembler.Comment("Store map");
524 assembler.StoreObjectField(receiver, JSObject::kMapOffset, map); 524 assembler.StoreMap(receiver, map);
525 assembler.Return(value); 525 assembler.Return(value);
526 526
527 // Only store to tagged field never bails out. 527 // Only store to tagged field never bails out.
528 if (!representation.IsTagged()) { 528 if (!representation.IsTagged()) {
529 assembler.Bind(&miss); 529 assembler.Bind(&miss);
530 { 530 {
531 assembler.Comment("Miss"); 531 assembler.Comment("Miss");
532 assembler.TailCallRuntime(Runtime::kStoreIC_Miss, context, value, slot, 532 assembler.TailCallRuntime(Runtime::kStoreIC_Miss, context, value, slot,
533 vector, receiver, name); 533 vector, receiver, name);
534 } 534 }
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 { 2226 {
2227 offset.Bind(assembler->IntPtrAdd(offset.value(), 2227 offset.Bind(assembler->IntPtrAdd(offset.value(),
2228 assembler->IntPtrConstant(kPointerSize))); 2228 assembler->IntPtrConstant(kPointerSize)));
2229 assembler->GotoUnless( 2229 assembler->GotoUnless(
2230 assembler->IntPtrGreaterThanOrEqual(offset.value(), end_offset), 2230 assembler->IntPtrGreaterThanOrEqual(offset.value(), end_offset),
2231 &loop_body); 2231 &loop_body);
2232 } 2232 }
2233 2233
2234 if (FLAG_allocation_site_pretenuring) { 2234 if (FLAG_allocation_site_pretenuring) {
2235 Node* memento = assembler->InnerAllocate(copy, object_size); 2235 Node* memento = assembler->InnerAllocate(copy, object_size);
2236 assembler->StoreObjectFieldNoWriteBarrier( 2236 assembler->StoreMapNoWriteBarrier(memento,
2237 memento, HeapObject::kMapOffset, 2237 Heap::kAllocationMementoMapRootIndex);
2238 assembler->LoadRoot(Heap::kAllocationMementoMapRootIndex));
2239 assembler->StoreObjectFieldNoWriteBarrier( 2238 assembler->StoreObjectFieldNoWriteBarrier(
2240 memento, AllocationMemento::kAllocationSiteOffset, allocation_site); 2239 memento, AllocationMemento::kAllocationSiteOffset, allocation_site);
2241 Node* memento_create_count = assembler->LoadObjectField( 2240 Node* memento_create_count = assembler->LoadObjectField(
2242 allocation_site, AllocationSite::kPretenureCreateCountOffset); 2241 allocation_site, AllocationSite::kPretenureCreateCountOffset);
2243 memento_create_count = assembler->SmiAdd( 2242 memento_create_count = assembler->SmiAdd(
2244 memento_create_count, assembler->SmiConstant(Smi::FromInt(1))); 2243 memento_create_count, assembler->SmiConstant(Smi::FromInt(1)));
2245 assembler->StoreObjectFieldNoWriteBarrier( 2244 assembler->StoreObjectFieldNoWriteBarrier(
2246 allocation_site, AllocationSite::kPretenureCreateCountOffset, 2245 allocation_site, AllocationSite::kPretenureCreateCountOffset,
2247 memento_create_count); 2246 memento_create_count);
2248 } 2247 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 Node* min_context_slots = 2594 Node* min_context_slots =
2596 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); 2595 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS);
2597 Node* length = assembler->Int32Add(slots, min_context_slots); 2596 Node* length = assembler->Int32Add(slots, min_context_slots);
2598 Node* size = assembler->Int32Add( 2597 Node* size = assembler->Int32Add(
2599 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)), 2598 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)),
2600 assembler->Int32Constant(FixedArray::kHeaderSize)); 2599 assembler->Int32Constant(FixedArray::kHeaderSize));
2601 2600
2602 // Create a new closure from the given function info in new space 2601 // Create a new closure from the given function info in new space
2603 Node* function_context = assembler->Allocate(size); 2602 Node* function_context = assembler->Allocate(size);
2604 2603
2605 Isolate* isolate = assembler->isolate(); 2604 assembler->StoreMapNoWriteBarrier(function_context,
2606 assembler->StoreMapNoWriteBarrier( 2605 Heap::kFunctionContextMapRootIndex);
2607 function_context,
2608 assembler->HeapConstant(isolate->factory()->function_context_map()));
2609 assembler->StoreObjectFieldNoWriteBarrier(function_context, 2606 assembler->StoreObjectFieldNoWriteBarrier(function_context,
2610 Context::kLengthOffset, 2607 Context::kLengthOffset,
2611 assembler->SmiFromWord32(length)); 2608 assembler->SmiFromWord32(length));
2612 2609
2613 // Set up the fixed slots. 2610 // Set up the fixed slots.
2614 assembler->StoreFixedArrayElement(function_context, Context::CLOSURE_INDEX, 2611 assembler->StoreFixedArrayElement(function_context, Context::CLOSURE_INDEX,
2615 function, SKIP_WRITE_BARRIER); 2612 function, SKIP_WRITE_BARRIER);
2616 assembler->StoreFixedArrayElement(function_context, Context::PREVIOUS_INDEX, 2613 assembler->StoreFixedArrayElement(function_context, Context::PREVIOUS_INDEX,
2617 context, SKIP_WRITE_BARRIER); 2614 context, SKIP_WRITE_BARRIER);
2618 assembler->StoreFixedArrayElement(function_context, Context::EXTENSION_INDEX, 2615 assembler->StoreFixedArrayElement(function_context, Context::EXTENSION_INDEX,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 capacity = assembler->SmiUntag(capacity); 2724 capacity = assembler->SmiUntag(capacity);
2728 param_mode = CodeStubAssembler::INTEGER_PARAMETERS; 2725 param_mode = CodeStubAssembler::INTEGER_PARAMETERS;
2729 } 2726 }
2730 2727
2731 Node *array, *elements; 2728 Node *array, *elements;
2732 std::tie(array, elements) = 2729 std::tie(array, elements) =
2733 assembler->AllocateUninitializedJSArrayWithElements( 2730 assembler->AllocateUninitializedJSArrayWithElements(
2734 kind, boilerplate_map, length, allocation_site, capacity, param_mode); 2731 kind, boilerplate_map, length, allocation_site, capacity, param_mode);
2735 2732
2736 assembler->Comment("copy elements header"); 2733 assembler->Comment("copy elements header");
2737 for (int offset = 0; offset < FixedArrayBase::kHeaderSize; 2734 // Header consists of map and length.
2738 offset += kPointerSize) { 2735 STATIC_ASSERT(FixedArrayBase::kHeaderSize == 2 * kPointerSize);
2739 Node* value = assembler->LoadObjectField(boilerplate_elements, offset); 2736 assembler->StoreMap(elements, assembler->LoadMap(boilerplate_elements));
2740 assembler->StoreObjectField(elements, offset, value); 2737 {
2738 int offset = FixedArrayBase::kLengthOffset;
2739 assembler->StoreObjectFieldNoWriteBarrier(
2740 elements, offset,
2741 assembler->LoadObjectField(boilerplate_elements, offset));
2741 } 2742 }
2742 2743
2743 if (assembler->Is64()) { 2744 if (assembler->Is64()) {
2744 length = assembler->SmiUntag(length); 2745 length = assembler->SmiUntag(length);
2745 } 2746 }
2746 2747
2747 assembler->Comment("copy boilerplate elements"); 2748 assembler->Comment("copy boilerplate elements");
2748 assembler->CopyFixedArrayElements(kind, boilerplate_elements, elements, 2749 assembler->CopyFixedArrayElements(kind, boilerplate_elements, elements,
2749 length, SKIP_WRITE_BARRIER, param_mode); 2750 length, SKIP_WRITE_BARRIER, param_mode);
2750 assembler->IncrementCounter( 2751 assembler->IncrementCounter(
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
3202 } 3203 }
3203 3204
3204 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) 3205 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate)
3205 : PlatformCodeStub(isolate) {} 3206 : PlatformCodeStub(isolate) {}
3206 3207
3207 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) 3208 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate)
3208 : PlatformCodeStub(isolate) {} 3209 : PlatformCodeStub(isolate) {}
3209 3210
3210 } // namespace internal 3211 } // namespace internal
3211 } // namespace v8 3212 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.cc ('k') | src/compiler/code-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698