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

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

Issue 1875583003: Separate CodeAssembler and CodeStubAssembler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix gn build Created 4 years, 8 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-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"
11 #include "src/compiler/instruction-selector.h" 11 #include "src/compiler/instruction-selector.h"
12 #include "src/compiler/linkage.h" 12 #include "src/compiler/linkage.h"
13 #include "src/compiler/pipeline.h" 13 #include "src/compiler/pipeline.h"
14 #include "src/compiler/raw-machine-assembler.h" 14 #include "src/compiler/raw-machine-assembler.h"
15 #include "src/compiler/schedule.h" 15 #include "src/compiler/schedule.h"
16 #include "src/frames.h" 16 #include "src/frames.h"
17 #include "src/interface-descriptors.h" 17 #include "src/interface-descriptors.h"
18 #include "src/interpreter/bytecodes.h" 18 #include "src/interpreter/bytecodes.h"
19 #include "src/machine-type.h" 19 #include "src/machine-type.h"
20 #include "src/macro-assembler.h" 20 #include "src/macro-assembler.h"
21 #include "src/zone.h" 21 #include "src/zone.h"
22 22
23 namespace v8 { 23 namespace v8 {
24 namespace internal { 24 namespace internal {
25 namespace compiler { 25 namespace compiler {
26 26
27 CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, 27 CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone,
28 const CallInterfaceDescriptor& descriptor, 28 const CallInterfaceDescriptor& descriptor,
29 Code::Flags flags, const char* name, 29 Code::Flags flags, const char* name,
30 size_t result_size) 30 size_t result_size)
31 : CodeStubAssembler( 31 : CodeAssembler(
32 isolate, zone, 32 isolate, 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, name) {} 37 flags, name) {}
38 38
39 CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, 39 CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone, int parameter_count,
40 int parameter_count, Code::Flags flags, 40 Code::Flags flags, const char* name)
41 const char* name) 41 : CodeAssembler(isolate, zone,
42 : CodeStubAssembler(isolate, zone, Linkage::GetJSCallDescriptor( 42 Linkage::GetJSCallDescriptor(zone, false, parameter_count,
43 zone, false, parameter_count, 43 CallDescriptor::kNoFlags),
44 CallDescriptor::kNoFlags), 44 flags, name) {}
45 flags, name) {}
46 45
47 CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, 46 CodeAssembler::CodeAssembler(Isolate* isolate, Zone* zone,
48 CallDescriptor* call_descriptor, 47 CallDescriptor* call_descriptor, Code::Flags flags,
49 Code::Flags flags, const char* name) 48 const char* name)
50 : raw_assembler_(new RawMachineAssembler( 49 : raw_assembler_(new RawMachineAssembler(
51 isolate, new (zone) Graph(zone), call_descriptor, 50 isolate, new (zone) Graph(zone), call_descriptor,
52 MachineType::PointerRepresentation(), 51 MachineType::PointerRepresentation(),
53 InstructionSelector::SupportedMachineOperatorFlags())), 52 InstructionSelector::SupportedMachineOperatorFlags())),
54 flags_(flags), 53 flags_(flags),
55 name_(name), 54 name_(name),
56 code_generated_(false), 55 code_generated_(false),
57 variables_(zone) {} 56 variables_(zone) {}
58 57
59 CodeStubAssembler::~CodeStubAssembler() {} 58 CodeAssembler::~CodeAssembler() {}
60 59
61 void CodeStubAssembler::CallPrologue() {} 60 void CodeAssembler::CallPrologue() {}
62 61
63 void CodeStubAssembler::CallEpilogue() {} 62 void CodeAssembler::CallEpilogue() {}
64 63
65 Handle<Code> CodeStubAssembler::GenerateCode() { 64 Handle<Code> CodeAssembler::GenerateCode() {
66 DCHECK(!code_generated_); 65 DCHECK(!code_generated_);
67 66
68 Schedule* schedule = raw_assembler_->Export(); 67 Schedule* schedule = raw_assembler_->Export();
69 Handle<Code> code = Pipeline::GenerateCodeForCodeStub( 68 Handle<Code> code = Pipeline::GenerateCodeForCodeStub(
70 isolate(), raw_assembler_->call_descriptor(), graph(), schedule, flags_, 69 isolate(), raw_assembler_->call_descriptor(), graph(), schedule, flags_,
71 name_); 70 name_);
72 71
73 code_generated_ = true; 72 code_generated_ = true;
74 return code; 73 return code;
75 } 74 }
76 75
76 bool CodeAssembler::Is64() { return raw_assembler_->machine()->Is64(); }
77 77
78 Node* CodeStubAssembler::Int32Constant(int value) { 78 Node* CodeAssembler::Int32Constant(int value) {
79 return raw_assembler_->Int32Constant(value); 79 return raw_assembler_->Int32Constant(value);
80 } 80 }
81 81
82 82 Node* CodeAssembler::IntPtrConstant(intptr_t value) {
83 Node* CodeStubAssembler::IntPtrConstant(intptr_t value) {
84 return raw_assembler_->IntPtrConstant(value); 83 return raw_assembler_->IntPtrConstant(value);
85 } 84 }
86 85
87 86 Node* CodeAssembler::NumberConstant(double value) {
88 Node* CodeStubAssembler::NumberConstant(double value) {
89 return raw_assembler_->NumberConstant(value); 87 return raw_assembler_->NumberConstant(value);
90 } 88 }
91 89
92 Node* CodeStubAssembler::SmiConstant(Smi* value) { 90 Node* CodeAssembler::SmiConstant(Smi* value) {
93 return IntPtrConstant(bit_cast<intptr_t>(value)); 91 return IntPtrConstant(bit_cast<intptr_t>(value));
94 } 92 }
95 93
96 Node* CodeStubAssembler::HeapConstant(Handle<HeapObject> object) { 94 Node* CodeAssembler::HeapConstant(Handle<HeapObject> object) {
97 return raw_assembler_->HeapConstant(object); 95 return raw_assembler_->HeapConstant(object);
98 } 96 }
99 97
100 98 Node* CodeAssembler::BooleanConstant(bool value) {
101 Node* CodeStubAssembler::BooleanConstant(bool value) {
102 return raw_assembler_->BooleanConstant(value); 99 return raw_assembler_->BooleanConstant(value);
103 } 100 }
104 101
105 Node* CodeStubAssembler::ExternalConstant(ExternalReference address) { 102 Node* CodeAssembler::ExternalConstant(ExternalReference address) {
106 return raw_assembler_->ExternalConstant(address); 103 return raw_assembler_->ExternalConstant(address);
107 } 104 }
108 105
109 Node* CodeStubAssembler::Float64Constant(double value) { 106 Node* CodeAssembler::Float64Constant(double value) {
110 return raw_assembler_->Float64Constant(value); 107 return raw_assembler_->Float64Constant(value);
111 } 108 }
112 109
113 Node* CodeStubAssembler::BooleanMapConstant() { 110 Node* CodeAssembler::BooleanMapConstant() {
114 return HeapConstant(isolate()->factory()->boolean_map()); 111 return HeapConstant(isolate()->factory()->boolean_map());
115 } 112 }
116 113
117 Node* CodeStubAssembler::HeapNumberMapConstant() { 114 Node* CodeAssembler::HeapNumberMapConstant() {
118 return HeapConstant(isolate()->factory()->heap_number_map()); 115 return HeapConstant(isolate()->factory()->heap_number_map());
119 } 116 }
120 117
121 Node* CodeStubAssembler::NullConstant() { 118 Node* CodeAssembler::NullConstant() {
122 return LoadRoot(Heap::kNullValueRootIndex); 119 return LoadRoot(Heap::kNullValueRootIndex);
123 } 120 }
124 121
125 Node* CodeStubAssembler::UndefinedConstant() { 122 Node* CodeAssembler::UndefinedConstant() {
126 return LoadRoot(Heap::kUndefinedValueRootIndex); 123 return LoadRoot(Heap::kUndefinedValueRootIndex);
127 } 124 }
128 125
129 Node* CodeStubAssembler::Parameter(int value) { 126 Node* CodeAssembler::Parameter(int value) {
130 return raw_assembler_->Parameter(value); 127 return raw_assembler_->Parameter(value);
131 } 128 }
132 129
133 void CodeStubAssembler::Return(Node* value) { 130 void CodeAssembler::Return(Node* value) {
134 return raw_assembler_->Return(value); 131 return raw_assembler_->Return(value);
135 } 132 }
136 133
137 void CodeStubAssembler::Bind(CodeStubAssembler::Label* label) { 134 void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); }
138 return label->Bind();
139 }
140 135
141 Node* CodeStubAssembler::LoadFramePointer() { 136 Node* CodeAssembler::LoadFramePointer() {
142 return raw_assembler_->LoadFramePointer(); 137 return raw_assembler_->LoadFramePointer();
143 } 138 }
144 139
145 Node* CodeStubAssembler::LoadParentFramePointer() { 140 Node* CodeAssembler::LoadParentFramePointer() {
146 return raw_assembler_->LoadParentFramePointer(); 141 return raw_assembler_->LoadParentFramePointer();
147 } 142 }
148 143
149 Node* CodeStubAssembler::LoadStackPointer() { 144 Node* CodeAssembler::LoadStackPointer() {
150 return raw_assembler_->LoadStackPointer(); 145 return raw_assembler_->LoadStackPointer();
151 } 146 }
152 147
153 Node* CodeStubAssembler::SmiShiftBitsConstant() { 148 Node* CodeAssembler::SmiShiftBitsConstant() {
154 return IntPtrConstant(kSmiShiftSize + kSmiTagSize); 149 return IntPtrConstant(kSmiShiftSize + kSmiTagSize);
155 } 150 }
156 151
157 Node* CodeStubAssembler::Float64Round(Node* x) { 152 Node* CodeAssembler::Float64Round(Node* x) {
158 Node* one = Float64Constant(1.0); 153 Node* one = Float64Constant(1.0);
159 Node* one_half = Float64Constant(0.5); 154 Node* one_half = Float64Constant(0.5);
160 155
161 Variable var_x(this, MachineRepresentation::kFloat64); 156 Variable var_x(this, MachineRepresentation::kFloat64);
162 Label return_x(this); 157 Label return_x(this);
163 158
164 // Round up {x} towards Infinity. 159 // Round up {x} towards Infinity.
165 var_x.Bind(Float64Ceil(x)); 160 var_x.Bind(Float64Ceil(x));
166 161
167 GotoIf(Float64LessThanOrEqual(Float64Sub(var_x.value(), one_half), x), 162 GotoIf(Float64LessThanOrEqual(Float64Sub(var_x.value(), one_half), x),
168 &return_x); 163 &return_x);
169 var_x.Bind(Float64Sub(var_x.value(), one)); 164 var_x.Bind(Float64Sub(var_x.value(), one));
170 Goto(&return_x); 165 Goto(&return_x);
171 166
172 Bind(&return_x); 167 Bind(&return_x);
173 return var_x.value(); 168 return var_x.value();
174 } 169 }
175 170
176 Node* CodeStubAssembler::Float64Ceil(Node* x) { 171 Node* CodeAssembler::Float64Ceil(Node* x) {
177 if (raw_assembler_->machine()->Float64RoundUp().IsSupported()) { 172 if (raw_assembler_->machine()->Float64RoundUp().IsSupported()) {
178 return raw_assembler_->Float64RoundUp(x); 173 return raw_assembler_->Float64RoundUp(x);
179 } 174 }
180 175
181 Node* one = Float64Constant(1.0); 176 Node* one = Float64Constant(1.0);
182 Node* zero = Float64Constant(0.0); 177 Node* zero = Float64Constant(0.0);
183 Node* two_52 = Float64Constant(4503599627370496.0E0); 178 Node* two_52 = Float64Constant(4503599627370496.0E0);
184 Node* minus_two_52 = Float64Constant(-4503599627370496.0E0); 179 Node* minus_two_52 = Float64Constant(-4503599627370496.0E0);
185 180
186 Variable var_x(this, MachineRepresentation::kFloat64); 181 Variable var_x(this, MachineRepresentation::kFloat64);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 214 }
220 215
221 Bind(&return_minus_x); 216 Bind(&return_minus_x);
222 var_x.Bind(Float64Neg(var_x.value())); 217 var_x.Bind(Float64Neg(var_x.value()));
223 Goto(&return_x); 218 Goto(&return_x);
224 219
225 Bind(&return_x); 220 Bind(&return_x);
226 return var_x.value(); 221 return var_x.value();
227 } 222 }
228 223
229 Node* CodeStubAssembler::Float64Floor(Node* x) { 224 Node* CodeAssembler::Float64Floor(Node* x) {
230 if (raw_assembler_->machine()->Float64RoundDown().IsSupported()) { 225 if (raw_assembler_->machine()->Float64RoundDown().IsSupported()) {
231 return raw_assembler_->Float64RoundDown(x); 226 return raw_assembler_->Float64RoundDown(x);
232 } 227 }
233 228
234 Node* one = Float64Constant(1.0); 229 Node* one = Float64Constant(1.0);
235 Node* zero = Float64Constant(0.0); 230 Node* zero = Float64Constant(0.0);
236 Node* two_52 = Float64Constant(4503599627370496.0E0); 231 Node* two_52 = Float64Constant(4503599627370496.0E0);
237 Node* minus_two_52 = Float64Constant(-4503599627370496.0E0); 232 Node* minus_two_52 = Float64Constant(-4503599627370496.0E0);
238 233
239 Variable var_x(this, MachineRepresentation::kFloat64); 234 Variable var_x(this, MachineRepresentation::kFloat64);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 267 }
273 268
274 Bind(&return_minus_x); 269 Bind(&return_minus_x);
275 var_x.Bind(Float64Neg(var_x.value())); 270 var_x.Bind(Float64Neg(var_x.value()));
276 Goto(&return_x); 271 Goto(&return_x);
277 272
278 Bind(&return_x); 273 Bind(&return_x);
279 return var_x.value(); 274 return var_x.value();
280 } 275 }
281 276
282 Node* CodeStubAssembler::Float64Trunc(Node* x) { 277 Node* CodeAssembler::Float64Trunc(Node* x) {
283 if (raw_assembler_->machine()->Float64RoundTruncate().IsSupported()) { 278 if (raw_assembler_->machine()->Float64RoundTruncate().IsSupported()) {
284 return raw_assembler_->Float64RoundTruncate(x); 279 return raw_assembler_->Float64RoundTruncate(x);
285 } 280 }
286 281
287 Node* one = Float64Constant(1.0); 282 Node* one = Float64Constant(1.0);
288 Node* zero = Float64Constant(0.0); 283 Node* zero = Float64Constant(0.0);
289 Node* two_52 = Float64Constant(4503599627370496.0E0); 284 Node* two_52 = Float64Constant(4503599627370496.0E0);
290 Node* minus_two_52 = Float64Constant(-4503599627370496.0E0); 285 Node* minus_two_52 = Float64Constant(-4503599627370496.0E0);
291 286
292 Variable var_x(this, MachineRepresentation::kFloat64); 287 Variable var_x(this, MachineRepresentation::kFloat64);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 329 }
335 330
336 Bind(&return_minus_x); 331 Bind(&return_minus_x);
337 var_x.Bind(Float64Neg(var_x.value())); 332 var_x.Bind(Float64Neg(var_x.value()));
338 Goto(&return_x); 333 Goto(&return_x);
339 334
340 Bind(&return_x); 335 Bind(&return_x);
341 return var_x.value(); 336 return var_x.value();
342 } 337 }
343 338
344 Node* CodeStubAssembler::SmiTag(Node* value) { 339 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \
345 return raw_assembler_->WordShl(value, SmiShiftBitsConstant()); 340 Node* CodeAssembler::name(Node* a, Node* b) { \
346 } 341 return raw_assembler_->name(a, b); \
347
348 Node* CodeStubAssembler::SmiUntag(Node* value) {
349 return raw_assembler_->WordSar(value, SmiShiftBitsConstant());
350 }
351
352 Node* CodeStubAssembler::SmiToWord32(Node* value) {
353 Node* result = raw_assembler_->WordSar(value, SmiShiftBitsConstant());
354 if (raw_assembler_->machine()->Is64()) {
355 result = raw_assembler_->TruncateInt64ToInt32(result);
356 }
357 return result;
358 }
359
360 Node* CodeStubAssembler::SmiToFloat64(Node* value) {
361 return ChangeInt32ToFloat64(SmiUntag(value));
362 }
363
364 Node* CodeStubAssembler::SmiAdd(Node* a, Node* b) { return IntPtrAdd(a, b); }
365
366 Node* CodeStubAssembler::SmiAddWithOverflow(Node* a, Node* b) {
367 return IntPtrAddWithOverflow(a, b);
368 }
369
370 Node* CodeStubAssembler::SmiSub(Node* a, Node* b) { return IntPtrSub(a, b); }
371
372 Node* CodeStubAssembler::SmiSubWithOverflow(Node* a, Node* b) {
373 return IntPtrSubWithOverflow(a, b);
374 }
375
376 Node* CodeStubAssembler::SmiEqual(Node* a, Node* b) { return WordEqual(a, b); }
377
378 Node* CodeStubAssembler::SmiLessThan(Node* a, Node* b) {
379 return IntPtrLessThan(a, b);
380 }
381
382 Node* CodeStubAssembler::SmiLessThanOrEqual(Node* a, Node* b) {
383 return IntPtrLessThanOrEqual(a, b);
384 }
385
386 Node* CodeStubAssembler::SmiMin(Node* a, Node* b) {
387 // TODO(bmeurer): Consider using Select once available.
388 Variable min(this, MachineRepresentation::kTagged);
389 Label if_a(this), if_b(this), join(this);
390 BranchIfSmiLessThan(a, b, &if_a, &if_b);
391 Bind(&if_a);
392 min.Bind(a);
393 Goto(&join);
394 Bind(&if_b);
395 min.Bind(b);
396 Goto(&join);
397 Bind(&join);
398 return min.value();
399 }
400
401 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \
402 Node* CodeStubAssembler::name(Node* a, Node* b) { \
403 return raw_assembler_->name(a, b); \
404 } 342 }
405 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP) 343 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP)
406 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP 344 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP
407 345
408 Node* CodeStubAssembler::WordShl(Node* value, int shift) { 346 Node* CodeAssembler::WordShl(Node* value, int shift) {
409 return raw_assembler_->WordShl(value, IntPtrConstant(shift)); 347 return raw_assembler_->WordShl(value, IntPtrConstant(shift));
410 } 348 }
411 349
350 Node* CodeAssembler::TruncateFloat64ToInt32RoundToZero(Node* a) {
351 return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kRoundToZero,
352 a);
353 }
354
355 Node* CodeAssembler::TruncateFloat64ToInt32JavaScript(Node* a) {
356 return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kJavaScript, a);
357 }
358
412 #define DEFINE_CODE_STUB_ASSEMBER_UNARY_OP(name) \ 359 #define DEFINE_CODE_STUB_ASSEMBER_UNARY_OP(name) \
413 Node* CodeStubAssembler::name(Node* a) { return raw_assembler_->name(a); } 360 Node* CodeAssembler::name(Node* a) { return raw_assembler_->name(a); }
414 CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_UNARY_OP) 361 CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_UNARY_OP)
415 #undef DEFINE_CODE_STUB_ASSEMBER_UNARY_OP 362 #undef DEFINE_CODE_STUB_ASSEMBER_UNARY_OP
416 363
417 Node* CodeStubAssembler::WordIsSmi(Node* a) { 364 Node* CodeAssembler::SmiTag(Node* value) {
418 return WordEqual(raw_assembler_->WordAnd(a, IntPtrConstant(kSmiTagMask)), 365 return WordShl(value, SmiShiftBitsConstant());
419 IntPtrConstant(0));
420 } 366 }
421 367
422 Node* CodeStubAssembler::WordIsPositiveSmi(Node* a) { 368 Node* CodeAssembler::SmiUntag(Node* value) {
423 return WordEqual( 369 return WordSar(value, SmiShiftBitsConstant());
424 raw_assembler_->WordAnd(a, IntPtrConstant(kSmiTagMask | kSmiSignMask)),
425 IntPtrConstant(0));
426 } 370 }
427 371
428 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset, 372 Node* CodeAssembler::LoadRoot(Heap::RootListIndex root_index) {
429 MachineType rep) {
430 return raw_assembler_->Load(rep, buffer, IntPtrConstant(offset));
431 }
432
433 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset,
434 MachineType rep) {
435 return raw_assembler_->Load(rep, object,
436 IntPtrConstant(offset - kHeapObjectTag));
437 }
438
439 Node* CodeStubAssembler::LoadHeapNumberValue(Node* object) {
440 return Load(MachineType::Float64(), object,
441 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag));
442 }
443
444 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) {
445 return StoreNoWriteBarrier(
446 MachineRepresentation::kFloat64, object,
447 IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), value);
448 }
449
450 Node* CodeStubAssembler::TruncateHeapNumberValueToWord32(Node* object) {
451 Node* value = LoadHeapNumberValue(object);
452 return raw_assembler_->TruncateFloat64ToInt32(TruncationMode::kJavaScript,
453 value);
454 }
455
456 Node* CodeStubAssembler::LoadMapBitField(Node* map) {
457 return Load(MachineType::Uint8(), map,
458 IntPtrConstant(Map::kBitFieldOffset - kHeapObjectTag));
459 }
460
461 Node* CodeStubAssembler::LoadMapBitField2(Node* map) {
462 return Load(MachineType::Uint8(), map,
463 IntPtrConstant(Map::kBitField2Offset - kHeapObjectTag));
464 }
465
466 Node* CodeStubAssembler::LoadMapBitField3(Node* map) {
467 return Load(MachineType::Uint32(), map,
468 IntPtrConstant(Map::kBitField3Offset - kHeapObjectTag));
469 }
470
471 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) {
472 return Load(MachineType::Uint8(), map,
473 IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag));
474 }
475
476 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) {
477 return LoadObjectField(map, Map::kDescriptorsOffset);
478 }
479
480 Node* CodeStubAssembler::LoadNameHash(Node* name) {
481 return Load(MachineType::Uint32(), name,
482 IntPtrConstant(Name::kHashFieldOffset - kHeapObjectTag));
483 }
484
485 Node* CodeStubAssembler::LoadFixedArrayElementInt32Index(
486 Node* object, Node* int32_index, int additional_offset) {
487 Node* header_size = IntPtrConstant(additional_offset +
488 FixedArray::kHeaderSize - kHeapObjectTag);
489 Node* scaled_index = WordShl(int32_index, IntPtrConstant(kPointerSizeLog2));
490 Node* offset = IntPtrAdd(scaled_index, header_size);
491 return Load(MachineType::AnyTagged(), object, offset);
492 }
493
494 Node* CodeStubAssembler::LoadFixedArrayElementSmiIndex(Node* object,
495 Node* smi_index,
496 int additional_offset) {
497 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize;
498 Node* header_size = IntPtrConstant(additional_offset +
499 FixedArray::kHeaderSize - kHeapObjectTag);
500 Node* scaled_index =
501 (kSmiShiftBits > kPointerSizeLog2)
502 ? WordSar(smi_index, IntPtrConstant(kSmiShiftBits - kPointerSizeLog2))
503 : WordShl(smi_index,
504 IntPtrConstant(kPointerSizeLog2 - kSmiShiftBits));
505 Node* offset = IntPtrAdd(scaled_index, header_size);
506 return Load(MachineType::AnyTagged(), object, offset);
507 }
508
509 Node* CodeStubAssembler::LoadFixedArrayElementConstantIndex(Node* object,
510 int index) {
511 Node* offset = IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag +
512 index * kPointerSize);
513 return raw_assembler_->Load(MachineType::AnyTagged(), object, offset);
514 }
515
516 Node* CodeStubAssembler::StoreFixedArrayElementNoWriteBarrier(Node* object,
517 Node* index,
518 Node* value) {
519 Node* offset =
520 IntPtrAdd(WordShl(index, IntPtrConstant(kPointerSizeLog2)),
521 IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag));
522 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset,
523 value);
524 }
525
526 Node* CodeStubAssembler::LoadRoot(Heap::RootListIndex root_index) {
527 if (isolate()->heap()->RootCanBeTreatedAsConstant(root_index)) { 373 if (isolate()->heap()->RootCanBeTreatedAsConstant(root_index)) {
528 Handle<Object> root = isolate()->heap()->root_handle(root_index); 374 Handle<Object> root = isolate()->heap()->root_handle(root_index);
529 if (root->IsSmi()) { 375 if (root->IsSmi()) {
530 return SmiConstant(Smi::cast(*root)); 376 return SmiConstant(Smi::cast(*root));
531 } else { 377 } else {
532 return HeapConstant(Handle<HeapObject>::cast(root)); 378 return HeapConstant(Handle<HeapObject>::cast(root));
533 } 379 }
534 } 380 }
535 381
536 compiler::Node* roots_array_start = 382 compiler::Node* roots_array_start =
537 ExternalConstant(ExternalReference::roots_array_start(isolate())); 383 ExternalConstant(ExternalReference::roots_array_start(isolate()));
538 USE(roots_array_start); 384 USE(roots_array_start);
539 385
540 // TODO(danno): Implement thee root-access case where the root is not constant 386 // TODO(danno): Implement thee root-access case where the root is not constant
541 // and must be loaded from the root array. 387 // and must be loaded from the root array.
542 UNIMPLEMENTED(); 388 UNIMPLEMENTED();
543 return nullptr; 389 return nullptr;
544 } 390 }
545 391
546 Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes, 392 Node* CodeAssembler::AllocateRawUnaligned(Node* size_in_bytes,
547 AllocationFlags flags, 393 AllocationFlags flags,
548 Node* top_address, 394 Node* top_address,
549 Node* limit_address) { 395 Node* limit_address) {
550 Node* top = Load(MachineType::Pointer(), top_address); 396 Node* top = Load(MachineType::Pointer(), top_address);
551 Node* limit = Load(MachineType::Pointer(), limit_address); 397 Node* limit = Load(MachineType::Pointer(), limit_address);
552 398
553 // If there's not enough space, call the runtime. 399 // If there's not enough space, call the runtime.
554 RawMachineLabel runtime_call(RawMachineLabel::kDeferred), no_runtime_call, 400 RawMachineLabel runtime_call(RawMachineLabel::kDeferred), no_runtime_call,
555 merge_runtime; 401 merge_runtime;
556 raw_assembler_->Branch( 402 raw_assembler_->Branch(
557 raw_assembler_->IntPtrLessThan(IntPtrSub(limit, top), size_in_bytes), 403 raw_assembler_->IntPtrLessThan(IntPtrSub(limit, top), size_in_bytes),
558 &runtime_call, &no_runtime_call); 404 &runtime_call, &no_runtime_call);
559 405
(...skipping 16 matching lines...) Expand all
576 IntPtrAdd(top, size_in_bytes)); 422 IntPtrAdd(top, size_in_bytes));
577 no_runtime_result = 423 no_runtime_result =
578 IntPtrAdd(no_runtime_result, IntPtrConstant(kHeapObjectTag)); 424 IntPtrAdd(no_runtime_result, IntPtrConstant(kHeapObjectTag));
579 raw_assembler_->Goto(&merge_runtime); 425 raw_assembler_->Goto(&merge_runtime);
580 426
581 raw_assembler_->Bind(&merge_runtime); 427 raw_assembler_->Bind(&merge_runtime);
582 return raw_assembler_->Phi(MachineType::PointerRepresentation(), 428 return raw_assembler_->Phi(MachineType::PointerRepresentation(),
583 runtime_result, no_runtime_result); 429 runtime_result, no_runtime_result);
584 } 430 }
585 431
586 Node* CodeStubAssembler::AllocateRawAligned(Node* size_in_bytes, 432 Node* CodeAssembler::AllocateRawAligned(Node* size_in_bytes,
587 AllocationFlags flags, 433 AllocationFlags flags,
588 Node* top_address, 434 Node* top_address,
589 Node* limit_address) { 435 Node* limit_address) {
590 Node* top = Load(MachineType::Pointer(), top_address); 436 Node* top = Load(MachineType::Pointer(), top_address);
591 Node* limit = Load(MachineType::Pointer(), limit_address); 437 Node* limit = Load(MachineType::Pointer(), limit_address);
592 Node* adjusted_size = size_in_bytes; 438 Node* adjusted_size = size_in_bytes;
593 if (flags & kDoubleAlignment) { 439 if (flags & kDoubleAlignment) {
594 // TODO(epertoso): Simd128 alignment. 440 // TODO(epertoso): Simd128 alignment.
595 RawMachineLabel aligned, not_aligned, merge; 441 RawMachineLabel aligned, not_aligned, merge;
596 raw_assembler_->Branch(WordAnd(top, IntPtrConstant(kDoubleAlignmentMask)), 442 raw_assembler_->Branch(WordAnd(top, IntPtrConstant(kDoubleAlignmentMask)),
597 &not_aligned, &aligned); 443 &not_aligned, &aligned);
598 444
599 raw_assembler_->Bind(&not_aligned); 445 raw_assembler_->Bind(&not_aligned);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 477
632 raw_assembler_->Bind(&merge_address); 478 raw_assembler_->Bind(&merge_address);
633 address = raw_assembler_->Phi(MachineType::PointerRepresentation(), 479 address = raw_assembler_->Phi(MachineType::PointerRepresentation(),
634 address_with_filler, address_without_filler); 480 address_with_filler, address_without_filler);
635 // Update the top. 481 // Update the top.
636 StoreNoWriteBarrier(MachineType::PointerRepresentation(), top_address, 482 StoreNoWriteBarrier(MachineType::PointerRepresentation(), top_address,
637 IntPtrAdd(top, adjusted_size)); 483 IntPtrAdd(top, adjusted_size));
638 return address; 484 return address;
639 } 485 }
640 486
641 Node* CodeStubAssembler::Allocate(int size_in_bytes, AllocationFlags flags) { 487 Node* CodeAssembler::Allocate(int size_in_bytes, AllocationFlags flags) {
642 bool const new_space = !(flags & kPretenured); 488 bool const new_space = !(flags & kPretenured);
643 Node* top_address = ExternalConstant( 489 Node* top_address = ExternalConstant(
644 new_space 490 new_space
645 ? ExternalReference::new_space_allocation_top_address(isolate()) 491 ? ExternalReference::new_space_allocation_top_address(isolate())
646 : ExternalReference::old_space_allocation_top_address(isolate())); 492 : ExternalReference::old_space_allocation_top_address(isolate()));
647 Node* limit_address = ExternalConstant( 493 Node* limit_address = ExternalConstant(
648 new_space 494 new_space
649 ? ExternalReference::new_space_allocation_limit_address(isolate()) 495 ? ExternalReference::new_space_allocation_limit_address(isolate())
650 : ExternalReference::old_space_allocation_limit_address(isolate())); 496 : ExternalReference::old_space_allocation_limit_address(isolate()));
651 497
652 #ifdef V8_HOST_ARCH_32_BIT 498 #ifdef V8_HOST_ARCH_32_BIT
653 if (flags & kDoubleAlignment) { 499 if (flags & kDoubleAlignment) {
654 return AllocateRawAligned(IntPtrConstant(size_in_bytes), flags, top_address, 500 return AllocateRawAligned(IntPtrConstant(size_in_bytes), flags, top_address,
655 limit_address); 501 limit_address);
656 } 502 }
657 #endif 503 #endif
658 504
659 return AllocateRawUnaligned(IntPtrConstant(size_in_bytes), flags, top_address, 505 return AllocateRawUnaligned(IntPtrConstant(size_in_bytes), flags, top_address,
660 limit_address); 506 limit_address);
661 } 507 }
662 508
663 Node* CodeStubAssembler::AllocateHeapNumber() { 509 Node* CodeAssembler::Load(MachineType rep, Node* base) {
664 Node* result = Allocate(HeapNumber::kSize, kNone);
665 StoreMapNoWriteBarrier(result, HeapNumberMapConstant());
666 return result;
667 }
668
669 Node* CodeStubAssembler::AllocateHeapNumberWithValue(Node* value) {
670 Node* result = AllocateHeapNumber();
671 StoreHeapNumberValue(result, value);
672 return result;
673 }
674
675 Node* CodeStubAssembler::Load(MachineType rep, Node* base) {
676 return raw_assembler_->Load(rep, base); 510 return raw_assembler_->Load(rep, base);
677 } 511 }
678 512
679 Node* CodeStubAssembler::Load(MachineType rep, Node* base, Node* index) { 513 Node* CodeAssembler::Load(MachineType rep, Node* base, Node* index) {
680 return raw_assembler_->Load(rep, base, index); 514 return raw_assembler_->Load(rep, base, index);
681 } 515 }
682 516
683 Node* CodeStubAssembler::Store(MachineRepresentation rep, Node* base, 517 Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* value) {
684 Node* value) {
685 return raw_assembler_->Store(rep, base, value, kFullWriteBarrier); 518 return raw_assembler_->Store(rep, base, value, kFullWriteBarrier);
686 } 519 }
687 520
688 Node* CodeStubAssembler::Store(MachineRepresentation rep, Node* base, 521 Node* CodeAssembler::Store(MachineRepresentation rep, Node* base, Node* index,
689 Node* index, Node* value) { 522 Node* value) {
690 return raw_assembler_->Store(rep, base, index, value, kFullWriteBarrier); 523 return raw_assembler_->Store(rep, base, index, value, kFullWriteBarrier);
691 } 524 }
692 525
693 Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep, 526 Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base,
694 Node* base, Node* value) { 527 Node* value) {
695 return raw_assembler_->Store(rep, base, value, kNoWriteBarrier); 528 return raw_assembler_->Store(rep, base, value, kNoWriteBarrier);
696 } 529 }
697 530
698 Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep, 531 Node* CodeAssembler::StoreNoWriteBarrier(MachineRepresentation rep, Node* base,
699 Node* base, Node* index, 532 Node* index, Node* value) {
700 Node* value) {
701 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier); 533 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier);
702 } 534 }
703 535
704 Node* CodeStubAssembler::Projection(int index, Node* value) { 536 void CodeAssembler::BranchIf(Node* condition, Label* if_true, Label* if_false) {
705 return raw_assembler_->Projection(index, value);
706 }
707
708 Node* CodeStubAssembler::LoadMap(Node* object) {
709 return LoadObjectField(object, HeapObject::kMapOffset);
710 }
711
712 Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) {
713 return StoreNoWriteBarrier(
714 MachineRepresentation::kTagged, object,
715 IntPtrConstant(HeapNumber::kMapOffset - kHeapObjectTag), map);
716 }
717
718 Node* CodeStubAssembler::LoadInstanceType(Node* object) {
719 return LoadMapInstanceType(LoadMap(object));
720 }
721
722 Node* CodeStubAssembler::LoadElements(Node* object) {
723 return LoadObjectField(object, JSObject::kElementsOffset);
724 }
725
726 Node* CodeStubAssembler::LoadFixedArrayBaseLength(Node* array) {
727 return LoadObjectField(array, FixedArrayBase::kLengthOffset);
728 }
729
730 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
731 uint32_t mask) {
732 return raw_assembler_->Word32Shr(
733 raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)),
734 raw_assembler_->Int32Constant(shift));
735 }
736
737 Node* CodeStubAssembler::ChangeFloat64ToTagged(Node* value) {
738 Node* value32 = raw_assembler_->TruncateFloat64ToInt32(
739 TruncationMode::kRoundToZero, value);
740 Node* value64 = ChangeInt32ToFloat64(value32);
741
742 Label if_valueisint32(this), if_valueisheapnumber(this), if_join(this);
743
744 Label if_valueisequal(this), if_valueisnotequal(this);
745 Branch(Float64Equal(value, value64), &if_valueisequal, &if_valueisnotequal);
746 Bind(&if_valueisequal);
747 {
748 Label if_valueiszero(this), if_valueisnotzero(this);
749 Branch(Float64Equal(value, Float64Constant(0.0)), &if_valueiszero,
750 &if_valueisnotzero);
751
752 Bind(&if_valueiszero);
753 BranchIfInt32LessThan(raw_assembler_->Float64ExtractHighWord32(value),
754 Int32Constant(0), &if_valueisheapnumber,
755 &if_valueisint32);
756
757 Bind(&if_valueisnotzero);
758 Goto(&if_valueisint32);
759 }
760 Bind(&if_valueisnotequal);
761 Goto(&if_valueisheapnumber);
762
763 Variable var_result(this, MachineRepresentation::kTagged);
764 Bind(&if_valueisint32);
765 {
766 if (raw_assembler_->machine()->Is64()) {
767 Node* result = SmiTag(ChangeInt32ToInt64(value32));
768 var_result.Bind(result);
769 Goto(&if_join);
770 } else {
771 Node* pair = Int32AddWithOverflow(value32, value32);
772 Node* overflow = Projection(1, pair);
773 Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
774 Branch(overflow, &if_overflow, &if_notoverflow);
775 Bind(&if_overflow);
776 Goto(&if_valueisheapnumber);
777 Bind(&if_notoverflow);
778 {
779 Node* result = Projection(0, pair);
780 var_result.Bind(result);
781 Goto(&if_join);
782 }
783 }
784 }
785 Bind(&if_valueisheapnumber);
786 {
787 Node* result = AllocateHeapNumberWithValue(value);
788 var_result.Bind(result);
789 Goto(&if_join);
790 }
791 Bind(&if_join);
792 return var_result.value();
793 }
794
795 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) {
796 if (raw_assembler_->machine()->Is64()) {
797 return SmiTag(ChangeInt32ToInt64(value));
798 }
799 Variable var_result(this, MachineRepresentation::kTagged);
800 Node* pair = Int32AddWithOverflow(value, value);
801 Node* overflow = Projection(1, pair);
802 Label if_overflow(this, Label::kDeferred), if_notoverflow(this),
803 if_join(this);
804 Branch(overflow, &if_overflow, &if_notoverflow);
805 Bind(&if_overflow);
806 {
807 Node* value64 = ChangeInt32ToFloat64(value);
808 Node* result = AllocateHeapNumberWithValue(value64);
809 var_result.Bind(result);
810 }
811 Goto(&if_join);
812 Bind(&if_notoverflow);
813 {
814 Node* result = Projection(0, pair);
815 var_result.Bind(result);
816 }
817 Goto(&if_join);
818 Bind(&if_join);
819 return var_result.value();
820 }
821
822 Node* CodeStubAssembler::TruncateTaggedToFloat64(Node* context, Node* value) {
823 // We might need to loop once due to ToNumber conversion.
824 Variable var_value(this, MachineRepresentation::kTagged),
825 var_result(this, MachineRepresentation::kFloat64);
826 Label loop(this, &var_value), done_loop(this, &var_result);
827 var_value.Bind(value);
828 Goto(&loop);
829 Bind(&loop);
830 {
831 // Load the current {value}.
832 value = var_value.value();
833
834 // Check if the {value} is a Smi or a HeapObject.
835 Label if_valueissmi(this), if_valueisnotsmi(this);
836 Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi);
837
838 Bind(&if_valueissmi);
839 {
840 // Convert the Smi {value}.
841 var_result.Bind(SmiToFloat64(value));
842 Goto(&done_loop);
843 }
844
845 Bind(&if_valueisnotsmi);
846 {
847 // Check if {value} is a HeapNumber.
848 Label if_valueisheapnumber(this),
849 if_valueisnotheapnumber(this, Label::kDeferred);
850 Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()),
851 &if_valueisheapnumber, &if_valueisnotheapnumber);
852
853 Bind(&if_valueisheapnumber);
854 {
855 // Load the floating point value.
856 var_result.Bind(LoadHeapNumberValue(value));
857 Goto(&done_loop);
858 }
859
860 Bind(&if_valueisnotheapnumber);
861 {
862 // Convert the {value} to a Number first.
863 Callable callable = CodeFactory::NonNumberToNumber(isolate());
864 var_value.Bind(CallStub(callable, context, value));
865 Goto(&loop);
866 }
867 }
868 }
869 Bind(&done_loop);
870 return var_result.value();
871 }
872
873 Node* CodeStubAssembler::TruncateTaggedToWord32(Node* context, Node* value) {
874 // We might need to loop once due to ToNumber conversion.
875 Variable var_value(this, MachineRepresentation::kTagged),
876 var_result(this, MachineRepresentation::kWord32);
877 Label loop(this, &var_value), done_loop(this, &var_result);
878 var_value.Bind(value);
879 Goto(&loop);
880 Bind(&loop);
881 {
882 // Load the current {value}.
883 value = var_value.value();
884
885 // Check if the {value} is a Smi or a HeapObject.
886 Label if_valueissmi(this), if_valueisnotsmi(this);
887 Branch(WordIsSmi(value), &if_valueissmi, &if_valueisnotsmi);
888
889 Bind(&if_valueissmi);
890 {
891 // Convert the Smi {value}.
892 var_result.Bind(SmiToWord32(value));
893 Goto(&done_loop);
894 }
895
896 Bind(&if_valueisnotsmi);
897 {
898 // Check if {value} is a HeapNumber.
899 Label if_valueisheapnumber(this),
900 if_valueisnotheapnumber(this, Label::kDeferred);
901 Branch(WordEqual(LoadMap(value), HeapNumberMapConstant()),
902 &if_valueisheapnumber, &if_valueisnotheapnumber);
903
904 Bind(&if_valueisheapnumber);
905 {
906 // Truncate the floating point value.
907 var_result.Bind(TruncateHeapNumberValueToWord32(value));
908 Goto(&done_loop);
909 }
910
911 Bind(&if_valueisnotheapnumber);
912 {
913 // Convert the {value} to a Number first.
914 Callable callable = CodeFactory::NonNumberToNumber(isolate());
915 var_value.Bind(CallStub(callable, context, value));
916 Goto(&loop);
917 }
918 }
919 }
920 Bind(&done_loop);
921 return var_result.value();
922 }
923
924 void CodeStubAssembler::BranchIf(Node* condition, Label* if_true,
925 Label* if_false) {
926 Label if_condition_is_true(this), if_condition_is_false(this); 537 Label if_condition_is_true(this), if_condition_is_false(this);
927 Branch(condition, &if_condition_is_true, &if_condition_is_false); 538 Branch(condition, &if_condition_is_true, &if_condition_is_false);
928 Bind(&if_condition_is_true); 539 Bind(&if_condition_is_true);
929 Goto(if_true); 540 Goto(if_true);
930 Bind(&if_condition_is_false); 541 Bind(&if_condition_is_false);
931 Goto(if_false); 542 Goto(if_false);
932 } 543 }
933 544
934 Node* CodeStubAssembler::CallN(CallDescriptor* descriptor, Node* code_target, 545 Node* CodeAssembler::Projection(int index, Node* value) {
935 Node** args) { 546 return raw_assembler_->Projection(index, value);
547 }
548
549 Node* CodeAssembler::CallN(CallDescriptor* descriptor, Node* code_target,
550 Node** args) {
936 CallPrologue(); 551 CallPrologue();
937 Node* return_value = raw_assembler_->CallN(descriptor, code_target, args); 552 Node* return_value = raw_assembler_->CallN(descriptor, code_target, args);
938 CallEpilogue(); 553 CallEpilogue();
939 return return_value; 554 return return_value;
940 } 555 }
941 556
942 557 Node* CodeAssembler::TailCallN(CallDescriptor* descriptor, Node* code_target,
943 Node* CodeStubAssembler::TailCallN(CallDescriptor* descriptor, 558 Node** args) {
944 Node* code_target, Node** args) {
945 return raw_assembler_->TailCallN(descriptor, code_target, args); 559 return raw_assembler_->TailCallN(descriptor, code_target, args);
946 } 560 }
947 561
948 Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id, 562 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id,
949 Node* context) { 563 Node* context) {
950 CallPrologue(); 564 CallPrologue();
951 Node* return_value = raw_assembler_->CallRuntime0(function_id, context); 565 Node* return_value = raw_assembler_->CallRuntime0(function_id, context);
952 CallEpilogue(); 566 CallEpilogue();
953 return return_value; 567 return return_value;
954 } 568 }
955 569
956 Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id, 570 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
957 Node* context, Node* arg1) { 571 Node* arg1) {
958 CallPrologue(); 572 CallPrologue();
959 Node* return_value = raw_assembler_->CallRuntime1(function_id, arg1, context); 573 Node* return_value = raw_assembler_->CallRuntime1(function_id, arg1, context);
960 CallEpilogue(); 574 CallEpilogue();
961 return return_value; 575 return return_value;
962 } 576 }
963 577
964 Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id, 578 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
965 Node* context, Node* arg1, Node* arg2) { 579 Node* arg1, Node* arg2) {
966 CallPrologue(); 580 CallPrologue();
967 Node* return_value = 581 Node* return_value =
968 raw_assembler_->CallRuntime2(function_id, arg1, arg2, context); 582 raw_assembler_->CallRuntime2(function_id, arg1, arg2, context);
969 CallEpilogue(); 583 CallEpilogue();
970 return return_value; 584 return return_value;
971 } 585 }
972 586
973 Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id, 587 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
974 Node* context, Node* arg1, Node* arg2, 588 Node* arg1, Node* arg2, Node* arg3) {
975 Node* arg3) {
976 CallPrologue(); 589 CallPrologue();
977 Node* return_value = 590 Node* return_value =
978 raw_assembler_->CallRuntime3(function_id, arg1, arg2, arg3, context); 591 raw_assembler_->CallRuntime3(function_id, arg1, arg2, arg3, context);
979 CallEpilogue(); 592 CallEpilogue();
980 return return_value; 593 return return_value;
981 } 594 }
982 595
983 Node* CodeStubAssembler::CallRuntime(Runtime::FunctionId function_id, 596 Node* CodeAssembler::CallRuntime(Runtime::FunctionId function_id, Node* context,
984 Node* context, Node* arg1, Node* arg2, 597 Node* arg1, Node* arg2, Node* arg3,
985 Node* arg3, Node* arg4) { 598 Node* arg4) {
986 CallPrologue(); 599 CallPrologue();
987 Node* return_value = raw_assembler_->CallRuntime4(function_id, arg1, arg2, 600 Node* return_value = raw_assembler_->CallRuntime4(function_id, arg1, arg2,
988 arg3, arg4, context); 601 arg3, arg4, context);
989 CallEpilogue(); 602 CallEpilogue();
990 return return_value; 603 return return_value;
991 } 604 }
992 605
993 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, 606 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
994 Node* context) { 607 Node* context) {
995 return raw_assembler_->TailCallRuntime0(function_id, context); 608 return raw_assembler_->TailCallRuntime0(function_id, context);
996 } 609 }
997 610
998 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, 611 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
999 Node* context, Node* arg1) { 612 Node* context, Node* arg1) {
1000 return raw_assembler_->TailCallRuntime1(function_id, arg1, context); 613 return raw_assembler_->TailCallRuntime1(function_id, arg1, context);
1001 } 614 }
1002 615
1003 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, 616 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
1004 Node* context, Node* arg1, 617 Node* context, Node* arg1, Node* arg2) {
1005 Node* arg2) {
1006 return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context); 618 return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context);
1007 } 619 }
1008 620
1009 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, 621 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
1010 Node* context, Node* arg1, Node* arg2, 622 Node* context, Node* arg1, Node* arg2,
1011 Node* arg3) { 623 Node* arg3) {
1012 return raw_assembler_->TailCallRuntime3(function_id, arg1, arg2, arg3, 624 return raw_assembler_->TailCallRuntime3(function_id, arg1, arg2, arg3,
1013 context); 625 context);
1014 } 626 }
1015 627
1016 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, 628 Node* CodeAssembler::TailCallRuntime(Runtime::FunctionId function_id,
1017 Node* context, Node* arg1, Node* arg2, 629 Node* context, Node* arg1, Node* arg2,
1018 Node* arg3, Node* arg4) { 630 Node* arg3, Node* arg4) {
1019 return raw_assembler_->TailCallRuntime4(function_id, arg1, arg2, arg3, arg4, 631 return raw_assembler_->TailCallRuntime4(function_id, arg1, arg2, arg3, arg4,
1020 context); 632 context);
1021 } 633 }
1022 634
1023 Node* CodeStubAssembler::CallStub(Callable const& callable, Node* context, 635 Node* CodeAssembler::CallStub(Callable const& callable, Node* context,
1024 Node* arg1, size_t result_size) { 636 Node* arg1, size_t result_size) {
1025 Node* target = HeapConstant(callable.code()); 637 Node* target = HeapConstant(callable.code());
1026 return CallStub(callable.descriptor(), target, context, arg1, result_size); 638 return CallStub(callable.descriptor(), target, context, arg1, result_size);
1027 } 639 }
1028 640
1029 Node* CodeStubAssembler::CallStub(Callable const& callable, Node* context, 641 Node* CodeAssembler::CallStub(Callable const& callable, Node* context,
1030 Node* arg1, Node* arg2, size_t result_size) { 642 Node* arg1, Node* arg2, size_t result_size) {
1031 Node* target = HeapConstant(callable.code()); 643 Node* target = HeapConstant(callable.code());
1032 return CallStub(callable.descriptor(), target, context, arg1, arg2, 644 return CallStub(callable.descriptor(), target, context, arg1, arg2,
1033 result_size); 645 result_size);
1034 } 646 }
1035 647
1036 Node* CodeStubAssembler::CallStub(Callable const& callable, Node* context, 648 Node* CodeAssembler::CallStub(Callable const& callable, Node* context,
1037 Node* arg1, Node* arg2, Node* arg3, 649 Node* arg1, Node* arg2, Node* arg3,
1038 size_t result_size) { 650 size_t result_size) {
1039 Node* target = HeapConstant(callable.code()); 651 Node* target = HeapConstant(callable.code());
1040 return CallStub(callable.descriptor(), target, context, arg1, arg2, arg3, 652 return CallStub(callable.descriptor(), target, context, arg1, arg2, arg3,
1041 result_size); 653 result_size);
1042 } 654 }
1043 655
1044 Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor, 656 Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
1045 Node* target, Node* context, Node* arg1, 657 Node* target, Node* context, Node* arg1,
1046 size_t result_size) { 658 size_t result_size) {
1047 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 659 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1048 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), 660 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
1049 CallDescriptor::kNoFlags, Operator::kNoProperties, 661 CallDescriptor::kNoFlags, Operator::kNoProperties,
1050 MachineType::AnyTagged(), result_size); 662 MachineType::AnyTagged(), result_size);
1051 663
1052 Node** args = zone()->NewArray<Node*>(2); 664 Node** args = zone()->NewArray<Node*>(2);
1053 args[0] = arg1; 665 args[0] = arg1;
1054 args[1] = context; 666 args[1] = context;
1055 667
1056 return CallN(call_descriptor, target, args); 668 return CallN(call_descriptor, target, args);
1057 } 669 }
1058 670
1059 Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor, 671 Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
1060 Node* target, Node* context, Node* arg1, 672 Node* target, Node* context, Node* arg1,
1061 Node* arg2, size_t result_size) { 673 Node* arg2, size_t result_size) {
1062 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 674 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1063 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), 675 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
1064 CallDescriptor::kNoFlags, Operator::kNoProperties, 676 CallDescriptor::kNoFlags, Operator::kNoProperties,
1065 MachineType::AnyTagged(), result_size); 677 MachineType::AnyTagged(), result_size);
1066 678
1067 Node** args = zone()->NewArray<Node*>(3); 679 Node** args = zone()->NewArray<Node*>(3);
1068 args[0] = arg1; 680 args[0] = arg1;
1069 args[1] = arg2; 681 args[1] = arg2;
1070 args[2] = context; 682 args[2] = context;
1071 683
1072 return CallN(call_descriptor, target, args); 684 return CallN(call_descriptor, target, args);
1073 } 685 }
1074 686
1075 Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor, 687 Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
1076 Node* target, Node* context, Node* arg1, 688 Node* target, Node* context, Node* arg1,
1077 Node* arg2, Node* arg3, size_t result_size) { 689 Node* arg2, Node* arg3, size_t result_size) {
1078 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 690 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1079 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), 691 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
1080 CallDescriptor::kNoFlags, Operator::kNoProperties, 692 CallDescriptor::kNoFlags, Operator::kNoProperties,
1081 MachineType::AnyTagged(), result_size); 693 MachineType::AnyTagged(), result_size);
1082 694
1083 Node** args = zone()->NewArray<Node*>(4); 695 Node** args = zone()->NewArray<Node*>(4);
1084 args[0] = arg1; 696 args[0] = arg1;
1085 args[1] = arg2; 697 args[1] = arg2;
1086 args[2] = arg3; 698 args[2] = arg3;
1087 args[3] = context; 699 args[3] = context;
1088 700
1089 return CallN(call_descriptor, target, args); 701 return CallN(call_descriptor, target, args);
1090 } 702 }
1091 703
1092 Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor, 704 Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
1093 Node* target, Node* context, Node* arg1, 705 Node* target, Node* context, Node* arg1,
1094 Node* arg2, Node* arg3, Node* arg4, 706 Node* arg2, Node* arg3, Node* arg4,
1095 size_t result_size) { 707 size_t result_size) {
1096 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 708 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1097 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), 709 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
1098 CallDescriptor::kNoFlags, Operator::kNoProperties, 710 CallDescriptor::kNoFlags, Operator::kNoProperties,
1099 MachineType::AnyTagged(), result_size); 711 MachineType::AnyTagged(), result_size);
1100 712
1101 Node** args = zone()->NewArray<Node*>(5); 713 Node** args = zone()->NewArray<Node*>(5);
1102 args[0] = arg1; 714 args[0] = arg1;
1103 args[1] = arg2; 715 args[1] = arg2;
1104 args[2] = arg3; 716 args[2] = arg3;
1105 args[3] = arg4; 717 args[3] = arg4;
1106 args[4] = context; 718 args[4] = context;
1107 719
1108 return CallN(call_descriptor, target, args); 720 return CallN(call_descriptor, target, args);
1109 } 721 }
1110 722
1111 Node* CodeStubAssembler::CallStub(const CallInterfaceDescriptor& descriptor, 723 Node* CodeAssembler::CallStub(const CallInterfaceDescriptor& descriptor,
1112 Node* target, Node* context, Node* arg1, 724 Node* target, Node* context, Node* arg1,
1113 Node* arg2, Node* arg3, Node* arg4, 725 Node* arg2, Node* arg3, Node* arg4, Node* arg5,
1114 Node* arg5, size_t result_size) { 726 size_t result_size) {
1115 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 727 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1116 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), 728 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
1117 CallDescriptor::kNoFlags, Operator::kNoProperties, 729 CallDescriptor::kNoFlags, Operator::kNoProperties,
1118 MachineType::AnyTagged(), result_size); 730 MachineType::AnyTagged(), result_size);
1119 731
1120 Node** args = zone()->NewArray<Node*>(6); 732 Node** args = zone()->NewArray<Node*>(6);
1121 args[0] = arg1; 733 args[0] = arg1;
1122 args[1] = arg2; 734 args[1] = arg2;
1123 args[2] = arg3; 735 args[2] = arg3;
1124 args[3] = arg4; 736 args[3] = arg4;
1125 args[4] = arg5; 737 args[4] = arg5;
1126 args[5] = context; 738 args[5] = context;
1127 739
1128 return CallN(call_descriptor, target, args); 740 return CallN(call_descriptor, target, args);
1129 } 741 }
1130 742
1131 Node* CodeStubAssembler::TailCallStub(Callable const& callable, Node* context, 743 Node* CodeAssembler::TailCallStub(Callable const& callable, Node* context,
1132 Node* arg1, Node* arg2, 744 Node* arg1, Node* arg2, size_t result_size) {
1133 size_t result_size) {
1134 Node* target = HeapConstant(callable.code()); 745 Node* target = HeapConstant(callable.code());
1135 return TailCallStub(callable.descriptor(), target, context, arg1, arg2, 746 return TailCallStub(callable.descriptor(), target, context, arg1, arg2,
1136 result_size); 747 result_size);
1137 } 748 }
1138 749
1139 Node* CodeStubAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor, 750 Node* CodeAssembler::TailCallStub(const CallInterfaceDescriptor& descriptor,
1140 Node* target, Node* context, Node* arg1, 751 Node* target, Node* context, Node* arg1,
1141 Node* arg2, size_t result_size) { 752 Node* arg2, size_t result_size) {
1142 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 753 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1143 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), 754 isolate(), zone(), descriptor, descriptor.GetStackParameterCount(),
1144 CallDescriptor::kSupportsTailCalls, Operator::kNoProperties, 755 CallDescriptor::kSupportsTailCalls, Operator::kNoProperties,
1145 MachineType::AnyTagged(), result_size); 756 MachineType::AnyTagged(), result_size);
1146 757
1147 Node** args = zone()->NewArray<Node*>(3); 758 Node** args = zone()->NewArray<Node*>(3);
1148 args[0] = arg1; 759 args[0] = arg1;
1149 args[1] = arg2; 760 args[1] = arg2;
1150 args[2] = context; 761 args[2] = context;
1151 762
1152 return raw_assembler_->TailCallN(call_descriptor, target, args); 763 return raw_assembler_->TailCallN(call_descriptor, target, args);
1153 } 764 }
1154 765
1155 Node* CodeStubAssembler::TailCall( 766 Node* CodeAssembler::TailCall(
1156 const CallInterfaceDescriptor& interface_descriptor, Node* code_target, 767 const CallInterfaceDescriptor& interface_descriptor, Node* code_target,
1157 Node** args, size_t result_size) { 768 Node** args, size_t result_size) {
1158 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( 769 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
1159 isolate(), zone(), interface_descriptor, 770 isolate(), zone(), interface_descriptor,
1160 interface_descriptor.GetStackParameterCount(), 771 interface_descriptor.GetStackParameterCount(),
1161 CallDescriptor::kSupportsTailCalls, Operator::kNoProperties, 772 CallDescriptor::kSupportsTailCalls, Operator::kNoProperties,
1162 MachineType::AnyTagged(), result_size); 773 MachineType::AnyTagged(), result_size);
1163 return raw_assembler_->TailCallN(descriptor, code_target, args); 774 return raw_assembler_->TailCallN(descriptor, code_target, args);
1164 } 775 }
1165 776
1166 void CodeStubAssembler::Goto(CodeStubAssembler::Label* label) { 777 void CodeAssembler::Goto(CodeAssembler::Label* label) {
1167 label->MergeVariables(); 778 label->MergeVariables();
1168 raw_assembler_->Goto(label->label_); 779 raw_assembler_->Goto(label->label_);
1169 } 780 }
1170 781
1171 void CodeStubAssembler::GotoIf(Node* condition, Label* true_label) { 782 void CodeAssembler::GotoIf(Node* condition, Label* true_label) {
1172 Label false_label(this); 783 Label false_label(this);
1173 Branch(condition, true_label, &false_label); 784 Branch(condition, true_label, &false_label);
1174 Bind(&false_label); 785 Bind(&false_label);
1175 } 786 }
1176 787
1177 void CodeStubAssembler::GotoUnless(Node* condition, Label* false_label) { 788 void CodeAssembler::GotoUnless(Node* condition, Label* false_label) {
1178 Label true_label(this); 789 Label true_label(this);
1179 Branch(condition, &true_label, false_label); 790 Branch(condition, &true_label, false_label);
1180 Bind(&true_label); 791 Bind(&true_label);
1181 } 792 }
1182 793
1183 void CodeStubAssembler::Branch(Node* condition, 794 void CodeAssembler::Branch(Node* condition, CodeAssembler::Label* true_label,
1184 CodeStubAssembler::Label* true_label, 795 CodeAssembler::Label* false_label) {
1185 CodeStubAssembler::Label* false_label) {
1186 true_label->MergeVariables(); 796 true_label->MergeVariables();
1187 false_label->MergeVariables(); 797 false_label->MergeVariables();
1188 return raw_assembler_->Branch(condition, true_label->label_, 798 return raw_assembler_->Branch(condition, true_label->label_,
1189 false_label->label_); 799 false_label->label_);
1190 } 800 }
1191 801
1192 void CodeStubAssembler::Switch(Node* index, Label* default_label, 802 void CodeAssembler::Switch(Node* index, Label* default_label,
1193 int32_t* case_values, Label** case_labels, 803 int32_t* case_values, Label** case_labels,
1194 size_t case_count) { 804 size_t case_count) {
1195 RawMachineLabel** labels = 805 RawMachineLabel** labels =
1196 new (zone()->New(sizeof(RawMachineLabel*) * case_count)) 806 new (zone()->New(sizeof(RawMachineLabel*) * case_count))
1197 RawMachineLabel*[case_count]; 807 RawMachineLabel*[case_count];
1198 for (size_t i = 0; i < case_count; ++i) { 808 for (size_t i = 0; i < case_count; ++i) {
1199 labels[i] = case_labels[i]->label_; 809 labels[i] = case_labels[i]->label_;
1200 case_labels[i]->MergeVariables(); 810 case_labels[i]->MergeVariables();
1201 default_label->MergeVariables(); 811 default_label->MergeVariables();
1202 } 812 }
1203 return raw_assembler_->Switch(index, default_label->label_, case_values, 813 return raw_assembler_->Switch(index, default_label->label_, case_values,
1204 labels, case_count); 814 labels, case_count);
1205 } 815 }
1206 816
1207 // RawMachineAssembler delegate helpers: 817 // RawMachineAssembler delegate helpers:
1208 Isolate* CodeStubAssembler::isolate() const { 818 Isolate* CodeAssembler::isolate() const { return raw_assembler_->isolate(); }
1209 return raw_assembler_->isolate();
1210 }
1211 819
1212 Factory* CodeStubAssembler::factory() const { return isolate()->factory(); } 820 Factory* CodeAssembler::factory() const { return isolate()->factory(); }
1213 821
1214 Graph* CodeStubAssembler::graph() const { return raw_assembler_->graph(); } 822 Graph* CodeAssembler::graph() const { return raw_assembler_->graph(); }
1215 823
1216 Zone* CodeStubAssembler::zone() const { return raw_assembler_->zone(); } 824 Zone* CodeAssembler::zone() const { return raw_assembler_->zone(); }
1217 825
1218 // The core implementation of Variable is stored through an indirection so 826 // The core implementation of Variable is stored through an indirection so
1219 // that it can outlive the often block-scoped Variable declarations. This is 827 // that it can outlive the often block-scoped Variable declarations. This is
1220 // needed to ensure that variable binding and merging through phis can 828 // needed to ensure that variable binding and merging through phis can
1221 // properly be verified. 829 // properly be verified.
1222 class CodeStubAssembler::Variable::Impl : public ZoneObject { 830 class CodeAssembler::Variable::Impl : public ZoneObject {
1223 public: 831 public:
1224 explicit Impl(MachineRepresentation rep) : value_(nullptr), rep_(rep) {} 832 explicit Impl(MachineRepresentation rep) : value_(nullptr), rep_(rep) {}
1225 Node* value_; 833 Node* value_;
1226 MachineRepresentation rep_; 834 MachineRepresentation rep_;
1227 }; 835 };
1228 836
1229 CodeStubAssembler::Variable::Variable(CodeStubAssembler* assembler, 837 CodeAssembler::Variable::Variable(CodeAssembler* assembler,
1230 MachineRepresentation rep) 838 MachineRepresentation rep)
1231 : impl_(new (assembler->zone()) Impl(rep)) { 839 : impl_(new (assembler->zone()) Impl(rep)) {
1232 assembler->variables_.push_back(impl_); 840 assembler->variables_.push_back(impl_);
1233 } 841 }
1234 842
1235 void CodeStubAssembler::Variable::Bind(Node* value) { impl_->value_ = value; } 843 void CodeAssembler::Variable::Bind(Node* value) { impl_->value_ = value; }
1236 844
1237 Node* CodeStubAssembler::Variable::value() const { 845 Node* CodeAssembler::Variable::value() const {
1238 DCHECK_NOT_NULL(impl_->value_); 846 DCHECK_NOT_NULL(impl_->value_);
1239 return impl_->value_; 847 return impl_->value_;
1240 } 848 }
1241 849
1242 MachineRepresentation CodeStubAssembler::Variable::rep() const { 850 MachineRepresentation CodeAssembler::Variable::rep() const {
1243 return impl_->rep_; 851 return impl_->rep_;
1244 } 852 }
1245 853
1246 bool CodeStubAssembler::Variable::IsBound() const { 854 bool CodeAssembler::Variable::IsBound() const {
1247 return impl_->value_ != nullptr; 855 return impl_->value_ != nullptr;
1248 } 856 }
1249 857
1250 CodeStubAssembler::Label::Label(CodeStubAssembler* assembler, 858 CodeAssembler::Label::Label(CodeAssembler* assembler, int merged_value_count,
1251 int merged_value_count, 859 CodeAssembler::Variable** merged_variables,
1252 CodeStubAssembler::Variable** merged_variables, 860 CodeAssembler::Label::Type type)
1253 CodeStubAssembler::Label::Type type)
1254 : bound_(false), merge_count_(0), assembler_(assembler), label_(nullptr) { 861 : bound_(false), merge_count_(0), assembler_(assembler), label_(nullptr) {
1255 void* buffer = assembler->zone()->New(sizeof(RawMachineLabel)); 862 void* buffer = assembler->zone()->New(sizeof(RawMachineLabel));
1256 label_ = new (buffer) 863 label_ = new (buffer)
1257 RawMachineLabel(type == kDeferred ? RawMachineLabel::kDeferred 864 RawMachineLabel(type == kDeferred ? RawMachineLabel::kDeferred
1258 : RawMachineLabel::kNonDeferred); 865 : RawMachineLabel::kNonDeferred);
1259 for (int i = 0; i < merged_value_count; ++i) { 866 for (int i = 0; i < merged_value_count; ++i) {
1260 variable_phis_[merged_variables[i]->impl_] = nullptr; 867 variable_phis_[merged_variables[i]->impl_] = nullptr;
1261 } 868 }
1262 } 869 }
1263 870
1264 void CodeStubAssembler::Label::MergeVariables() { 871 void CodeAssembler::Label::MergeVariables() {
1265 ++merge_count_; 872 ++merge_count_;
1266 for (auto var : assembler_->variables_) { 873 for (auto var : assembler_->variables_) {
1267 size_t count = 0; 874 size_t count = 0;
1268 Node* node = var->value_; 875 Node* node = var->value_;
1269 if (node != nullptr) { 876 if (node != nullptr) {
1270 auto i = variable_merges_.find(var); 877 auto i = variable_merges_.find(var);
1271 if (i != variable_merges_.end()) { 878 if (i != variable_merges_.end()) {
1272 i->second.push_back(node); 879 i->second.push_back(node);
1273 count = i->second.size(); 880 count = i->second.size();
1274 } else { 881 } else {
(...skipping 25 matching lines...) Expand all
1300 // in the label's constructor's list of merged variables). 907 // in the label's constructor's list of merged variables).
1301 DCHECK(find_if(i->second.begin(), i->second.end(), 908 DCHECK(find_if(i->second.begin(), i->second.end(),
1302 [node](Node* e) -> bool { return node != e; }) == 909 [node](Node* e) -> bool { return node != e; }) ==
1303 i->second.end()); 910 i->second.end());
1304 } 911 }
1305 } 912 }
1306 } 913 }
1307 } 914 }
1308 } 915 }
1309 916
1310 void CodeStubAssembler::Label::Bind() { 917 void CodeAssembler::Label::Bind() {
1311 DCHECK(!bound_); 918 DCHECK(!bound_);
1312 assembler_->raw_assembler_->Bind(label_); 919 assembler_->raw_assembler_->Bind(label_);
1313 920
1314 // Make sure that all variables that have changed along any path up to this 921 // Make sure that all variables that have changed along any path up to this
1315 // point are marked as merge variables. 922 // point are marked as merge variables.
1316 for (auto var : assembler_->variables_) { 923 for (auto var : assembler_->variables_) {
1317 Node* shared_value = nullptr; 924 Node* shared_value = nullptr;
1318 auto i = variable_merges_.find(var); 925 auto i = variable_merges_.find(var);
1319 if (i != variable_merges_.end()) { 926 if (i != variable_merges_.end()) {
1320 for (auto value : i->second) { 927 for (auto value : i->second) {
1321 DCHECK(value != nullptr); 928 DCHECK(value != nullptr);
1322 if (value != shared_value) { 929 if (value != shared_value) {
1323 if (shared_value == nullptr) { 930 if (shared_value == nullptr) {
1324 shared_value = value; 931 shared_value = value;
1325 } else { 932 } else {
1326 variable_phis_[var] = nullptr; 933 variable_phis_[var] = nullptr;
1327 } 934 }
1328 } 935 }
1329 } 936 }
1330 } 937 }
1331 } 938 }
1332 939
1333 for (auto var : variable_phis_) { 940 for (auto var : variable_phis_) {
1334 CodeStubAssembler::Variable::Impl* var_impl = var.first; 941 CodeAssembler::Variable::Impl* var_impl = var.first;
1335 auto i = variable_merges_.find(var_impl); 942 auto i = variable_merges_.find(var_impl);
1336 // If the following assert fires, then a variable that has been marked as 943 // If the following assert fires, then a variable that has been marked as
1337 // being merged at the label--either by explicitly marking it so in the 944 // being merged at the label--either by explicitly marking it so in the
1338 // label constructor or by having seen different bound values at branches 945 // label constructor or by having seen different bound values at branches
1339 // into the label--doesn't have a bound value along all of the paths that 946 // into the label--doesn't have a bound value along all of the paths that
1340 // have been merged into the label up to this point. 947 // have been merged into the label up to this point.
1341 DCHECK(i != variable_merges_.end() && i->second.size() == merge_count_); 948 DCHECK(i != variable_merges_.end() && i->second.size() == merge_count_);
1342 Node* phi = assembler_->raw_assembler_->Phi( 949 Node* phi = assembler_->raw_assembler_->Phi(
1343 var.first->rep_, static_cast<int>(merge_count_), &(i->second[0])); 950 var.first->rep_, static_cast<int>(merge_count_), &(i->second[0]));
1344 variable_phis_[var_impl] = phi; 951 variable_phis_[var_impl] = phi;
(...skipping 14 matching lines...) Expand all
1359 } 966 }
1360 } 967 }
1361 } 968 }
1362 969
1363 bound_ = true; 970 bound_ = true;
1364 } 971 }
1365 972
1366 } // namespace compiler 973 } // namespace compiler
1367 } // namespace internal 974 } // namespace internal
1368 } // namespace v8 975 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698