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

Side by Side Diff: src/builtins/builtins-internal.cc

Issue 2220513002: Revert of [turbofan] Add support for copy-on-write element stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/builtins/builtins.h ('k') | src/code-factory.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins.h" 5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h" 6 #include "src/builtins/builtins-utils.h"
7 #include "src/interface-descriptors.h" 7
8 #include "src/macro-assembler.h" 8 #include "src/macro-assembler.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 BUILTIN(Illegal) { 13 BUILTIN(Illegal) {
14 UNREACHABLE(); 14 UNREACHABLE();
15 return isolate->heap()->undefined_value(); // Make compiler happy. 15 return isolate->heap()->undefined_value(); // Make compiler happy.
16 } 16 }
17 17
(...skipping 25 matching lines...) Expand all
43 // Interrupt and stack checks. 43 // Interrupt and stack checks.
44 44
45 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) { 45 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) {
46 masm->TailCallRuntime(Runtime::kInterrupt); 46 masm->TailCallRuntime(Runtime::kInterrupt);
47 } 47 }
48 48
49 void Builtins::Generate_StackCheck(MacroAssembler* masm) { 49 void Builtins::Generate_StackCheck(MacroAssembler* masm) {
50 masm->TailCallRuntime(Runtime::kStackGuard); 50 masm->TailCallRuntime(Runtime::kStackGuard);
51 } 51 }
52 52
53 // -----------------------------------------------------------------------------
54 // FixedArray helpers.
55
56 void Builtins::Generate_CopyFixedArray(CodeStubAssembler* assembler) {
57 typedef CodeStubAssembler::Label Label;
58 typedef compiler::Node Node;
59 typedef CodeStubAssembler::Variable Variable;
60 typedef CopyFixedArrayDescriptor Descriptor;
61
62 Node* source = assembler->Parameter(Descriptor::kSource);
63
64 // Load the {source} length.
65 Node* source_length_tagged =
66 assembler->LoadObjectField(source, FixedArray::kLengthOffset);
67 Node* source_length = assembler->SmiToWord(source_length_tagged);
68
69 // Compute the size of {source} in bytes.
70 Node* source_size = assembler->IntPtrAdd(
71 assembler->WordShl(source_length,
72 assembler->IntPtrConstant(kPointerSizeLog2)),
73 assembler->IntPtrConstant(FixedArray::kHeaderSize));
74
75 // Check if we can allocate in new space.
76 Label if_newspace(assembler), if_oldspace(assembler);
77 assembler->Branch(assembler->UintPtrLessThan(
78 source_size, assembler->IntPtrConstant(
79 Page::kMaxRegularHeapObjectSize)),
80 &if_newspace, &if_oldspace);
81
82 assembler->Bind(&if_newspace);
83 {
84 // Allocate the targeting FixedArray in new space.
85 Node* target = assembler->Allocate(source_size);
86 assembler->StoreMapNoWriteBarrier(
87 target, assembler->LoadRoot(Heap::kFixedArrayMapRootIndex));
88 assembler->StoreObjectFieldNoWriteBarrier(target, FixedArray::kLengthOffset,
89 source_length_tagged);
90
91 // Copy the {source} to the {target}.
92 Variable var_index(assembler, MachineType::PointerRepresentation());
93 Label loop(assembler, &var_index), done_loop(assembler);
94 var_index.Bind(
95 assembler->IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag));
96 assembler->Goto(&loop);
97 assembler->Bind(&loop);
98 {
99 // Determine the current {index}.
100 Node* index = var_index.value();
101
102 // Check if we are done.
103 assembler->GotoUnless(assembler->UintPtrLessThan(index, source_size),
104 &done_loop);
105
106 // Load the value from {source}.
107 Node* value = assembler->Load(MachineType::AnyTagged(), source, index);
108
109 // Store the {value} to the {target} without a write barrier, since we
110 // know that the {target} is allocated in new space.
111 assembler->StoreNoWriteBarrier(MachineRepresentation::kTagged, target,
112 index, value);
113
114 // Increment {index} and continue.
115 var_index.Bind(
116 assembler->IntPtrAdd(index, assembler->IntPtrConstant(kPointerSize)));
117 assembler->Goto(&loop);
118 }
119
120 assembler->Bind(&done_loop);
121 assembler->Return(target);
122 }
123
124 assembler->Bind(&if_oldspace);
125 {
126 // Allocate the targeting FixedArray in old space
127 // (maybe even in large object space).
128 Node* flags = assembler->SmiConstant(
129 Smi::FromInt(AllocateDoubleAlignFlag::encode(false) |
130 AllocateTargetSpace::encode(AllocationSpace::OLD_SPACE)));
131 Node* source_size_tagged = assembler->SmiFromWord(source_size);
132 Node* target = assembler->CallRuntime(Runtime::kAllocateInTargetSpace,
133 assembler->NoContextConstant(),
134 source_size_tagged, flags);
135 assembler->StoreMapNoWriteBarrier(
136 target, assembler->LoadRoot(Heap::kFixedArrayMapRootIndex));
137 assembler->StoreObjectFieldNoWriteBarrier(target, FixedArray::kLengthOffset,
138 source_length_tagged);
139
140 // Copy the {source} to the {target}.
141 Variable var_index(assembler, MachineType::PointerRepresentation());
142 Label loop(assembler, &var_index), done_loop(assembler);
143 var_index.Bind(
144 assembler->IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag));
145 assembler->Goto(&loop);
146 assembler->Bind(&loop);
147 {
148 // Determine the current {index}.
149 Node* index = var_index.value();
150
151 // Check if we are done.
152 assembler->GotoUnless(assembler->UintPtrLessThan(index, source_size),
153 &done_loop);
154
155 // Load the value from {source}.
156 Node* value = assembler->Load(MachineType::AnyTagged(), source, index);
157
158 // Store the {value} to the {target} with a proper write barrier.
159 assembler->Store(MachineRepresentation::kTagged, target, index, value);
160
161 // Increment {index} and continue.
162 var_index.Bind(
163 assembler->IntPtrAdd(index, assembler->IntPtrConstant(kPointerSize)));
164 assembler->Goto(&loop);
165 }
166
167 assembler->Bind(&done_loop);
168 assembler->Return(target);
169 }
170 }
171
172 } // namespace internal 53 } // namespace internal
173 } // namespace v8 54 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/code-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698