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

Side by Side Diff: src/compiler/code-stub-assembler.cc

Issue 1617503003: [Atomics] code stubs for atomic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove unnecessary CSA additions Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/code-stub-assembler.h" 5 #include "src/compiler/code-stub-assembler.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 19 matching lines...) Expand all
30 size_t result_size) 30 size_t result_size)
31 : raw_assembler_(new RawMachineAssembler( 31 : raw_assembler_(new RawMachineAssembler(
32 isolate, new (zone) Graph(zone), 32 isolate, new (zone) Graph(zone),
33 Linkage::GetStubCallDescriptor( 33 Linkage::GetStubCallDescriptor(
34 isolate, zone, descriptor, descriptor.GetStackParameterCount(), 34 isolate, zone, descriptor, descriptor.GetStackParameterCount(),
35 CallDescriptor::kNoFlags, Operator::kNoProperties, 35 CallDescriptor::kNoFlags, Operator::kNoProperties,
36 MachineType::AnyTagged(), result_size))), 36 MachineType::AnyTagged(), result_size))),
37 flags_(flags), 37 flags_(flags),
38 name_(name), 38 name_(name),
39 code_generated_(false), 39 code_generated_(false),
40 variables_(zone) {} 40 variables_(zone),
41 linkage_type_(LinkageDescriptorType::kStubCall),
42 parameter_count_(descriptor.GetParameterCount()) {}
43
44
45 CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
46 int parameter_count, Code::Flags flags,
47 const char* name)
48 : raw_assembler_(new RawMachineAssembler(
49 isolate, new (zone) Graph(zone),
50 Linkage::GetJSCallDescriptor(zone, false, parameter_count,
51 CallDescriptor::kNoFlags))),
52 flags_(flags),
53 name_(name),
54 code_generated_(false),
55 variables_(zone),
56 linkage_type_(LinkageDescriptorType::kJSCall),
57 parameter_count_(parameter_count) {}
41 58
42 CodeStubAssembler::~CodeStubAssembler() {} 59 CodeStubAssembler::~CodeStubAssembler() {}
43 60
44 void CodeStubAssembler::CallPrologue() {} 61 void CodeStubAssembler::CallPrologue() {}
45 62
46 void CodeStubAssembler::CallEpilogue() {} 63 void CodeStubAssembler::CallEpilogue() {}
47 64
48 Handle<Code> CodeStubAssembler::GenerateCode() { 65 Handle<Code> CodeStubAssembler::GenerateCode() {
49 DCHECK(!code_generated_); 66 DCHECK(!code_generated_);
50 67
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); 138 return raw_assembler_->WordSar(value, SmiShiftBitsConstant());
122 } 139 }
123 140
124 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \ 141 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \
125 Node* CodeStubAssembler::name(Node* a, Node* b) { \ 142 Node* CodeStubAssembler::name(Node* a, Node* b) { \
126 return raw_assembler_->name(a, b); \ 143 return raw_assembler_->name(a, b); \
127 } 144 }
128 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP) 145 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP)
129 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP 146 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP
130 147
131 Node* CodeStubAssembler::ChangeInt32ToInt64(Node* value) {
132 return raw_assembler_->ChangeInt32ToInt64(value);
133 }
134
135 Node* CodeStubAssembler::WordShl(Node* value, int shift) { 148 Node* CodeStubAssembler::WordShl(Node* value, int shift) {
136 return raw_assembler_->WordShl(value, Int32Constant(shift)); 149 return raw_assembler_->WordShl(value, Int32Constant(shift));
137 } 150 }
138 151
152
153 #define DEFINE_CODE_STUB_ASSEMBER_UNARY_OP(name) \
154 Node* CodeStubAssembler::name(Node* a) { return raw_assembler_->name(a); }
155 CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_UNARY_OP)
156 #undef DEFINE_CODE_STUB_ASSEMBER_UNARY_OP
157
158
139 Node* CodeStubAssembler::WordIsSmi(Node* a) { 159 Node* CodeStubAssembler::WordIsSmi(Node* a) {
140 return WordEqual(raw_assembler_->WordAnd(a, Int32Constant(kSmiTagMask)), 160 return WordEqual(raw_assembler_->WordAnd(a, Int32Constant(kSmiTagMask)),
141 Int32Constant(0)); 161 Int32Constant(0));
142 } 162 }
143 163
144 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset) { 164 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset) {
145 return raw_assembler_->Load(MachineType::AnyTagged(), buffer, 165 return raw_assembler_->Load(MachineType::AnyTagged(), buffer,
146 IntPtrConstant(offset)); 166 IntPtrConstant(offset));
147 } 167 }
148 168
149 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset) { 169 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset) {
150 return raw_assembler_->Load(MachineType::AnyTagged(), object, 170 return raw_assembler_->Load(MachineType::AnyTagged(), object,
151 IntPtrConstant(offset - kHeapObjectTag)); 171 IntPtrConstant(offset - kHeapObjectTag));
152 } 172 }
153 173
174 Node* CodeStubAssembler::LoadHeapNumber(Node* object) {
175 return raw_assembler_->Load(MachineType::Float64(), object,
176 IntPtrConstant(HeapNumber::kValueOffset));
177 }
178
154 Node* CodeStubAssembler::LoadFixedArrayElementSmiIndex(Node* object, 179 Node* CodeStubAssembler::LoadFixedArrayElementSmiIndex(Node* object,
155 Node* smi_index, 180 Node* smi_index,
156 int additional_offset) { 181 int additional_offset) {
157 Node* header_size = raw_assembler_->Int32Constant( 182 Node* header_size = raw_assembler_->Int32Constant(
158 additional_offset + FixedArray::kHeaderSize - kHeapObjectTag); 183 additional_offset + FixedArray::kHeaderSize - kHeapObjectTag);
159 Node* scaled_index = 184 Node* scaled_index =
160 (kSmiShiftSize == 0) 185 (kSmiShiftSize == 0)
161 ? raw_assembler_->Word32Shl( 186 ? raw_assembler_->Word32Shl(
162 smi_index, Int32Constant(kPointerSizeLog2 - kSmiTagSize)) 187 smi_index, Int32Constant(kPointerSizeLog2 - kSmiTagSize))
163 : raw_assembler_->Word32Shl(SmiUntag(smi_index), 188 : raw_assembler_->Word32Shl(SmiUntag(smi_index),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep, 244 Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep,
220 Node* base, Node* index, 245 Node* base, Node* index,
221 Node* value) { 246 Node* value) {
222 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier); 247 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier);
223 } 248 }
224 249
225 Node* CodeStubAssembler::Projection(int index, Node* value) { 250 Node* CodeStubAssembler::Projection(int index, Node* value) {
226 return raw_assembler_->Projection(index, value); 251 return raw_assembler_->Projection(index, value);
227 } 252 }
228 253
254 Node* CodeStubAssembler::InstanceType(Node* object) {
255 return raw_assembler_->WordAnd(
256 LoadObjectField(LoadObjectField(object, HeapObject::kMapOffset),
257 Map::kInstanceTypeOffset),
258 raw_assembler_->Int32Constant(255));
259 }
260
261 Node* CodeStubAssembler::BitFieldValue(Node* word32, uint32_t shift,
262 uint32_t mask) {
263 return raw_assembler_->Word32Shr(
264 raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)),
265 raw_assembler_->Int32Constant(shift));
266 }
267
268 Node* CodeStubAssembler::Context() {
binji 2016/02/12 01:46:56 This seems a bit weird, but seems to work. Better
Benedikt Meurer 2016/02/12 05:58:38 I think we shouldn't have this helper method, it's
binji 2016/02/12 20:35:18 Done.
269 switch (linkage_type_) {
270 case LinkageDescriptorType::kStubCall:
271 return Parameter(Linkage::GetStubCallContextParamIndex(parameter_count_));
272
273 case LinkageDescriptorType::kJSCall:
274 return Parameter(Linkage::GetJSCallContextParamIndex(parameter_count_));
275 }
276 }
277
229 Node* CodeStubAssembler::CallN(CallDescriptor* descriptor, Node* code_target, 278 Node* CodeStubAssembler::CallN(CallDescriptor* descriptor, Node* code_target,
230 Node** args) { 279 Node** args) {
231 CallPrologue(); 280 CallPrologue();
232 Node* return_value = raw_assembler_->CallN(descriptor, code_target, args); 281 Node* return_value = raw_assembler_->CallN(descriptor, code_target, args);
233 CallEpilogue(); 282 CallEpilogue();
234 return return_value; 283 return return_value;
235 } 284 }
236 285
237 286
238 Node* CodeStubAssembler::TailCallN(CallDescriptor* descriptor, 287 Node* CodeStubAssembler::TailCallN(CallDescriptor* descriptor,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 Node* context, Node* arg1, Node* arg2, 328 Node* context, Node* arg1, Node* arg2,
280 Node* arg3, Node* arg4) { 329 Node* arg3, Node* arg4) {
281 CallPrologue(); 330 CallPrologue();
282 Node* return_value = raw_assembler_->CallRuntime4(function_id, arg1, arg2, 331 Node* return_value = raw_assembler_->CallRuntime4(function_id, arg1, arg2,
283 arg3, arg4, context); 332 arg3, arg4, context);
284 CallEpilogue(); 333 CallEpilogue();
285 return return_value; 334 return return_value;
286 } 335 }
287 336
288 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, 337 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
338 Node* context) {
339 return raw_assembler_->TailCallRuntime0(function_id, context);
340 }
341
342 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
289 Node* context, Node* arg1) { 343 Node* context, Node* arg1) {
290 return raw_assembler_->TailCallRuntime1(function_id, arg1, context); 344 return raw_assembler_->TailCallRuntime1(function_id, arg1, context);
291 } 345 }
292 346
293 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, 347 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id,
294 Node* context, Node* arg1, 348 Node* context, Node* arg1,
295 Node* arg2) { 349 Node* arg2) {
296 return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context); 350 return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context);
297 } 351 }
298 352
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 } 656 }
603 } 657 }
604 } 658 }
605 659
606 bound_ = true; 660 bound_ = true;
607 } 661 }
608 662
609 } // namespace compiler 663 } // namespace compiler
610 } // namespace internal 664 } // namespace internal
611 } // namespace v8 665 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698