| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 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 | 41 |
| 42 |
| 43 CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, |
| 44 int parameter_count, Code::Flags flags, |
| 45 const char* name) |
| 46 : raw_assembler_(new RawMachineAssembler( |
| 47 isolate, new (zone) Graph(zone), |
| 48 Linkage::GetJSCallDescriptor(zone, false, parameter_count, |
| 49 CallDescriptor::kNoFlags))), |
| 50 flags_(flags), |
| 51 name_(name), |
| 52 code_generated_(false), |
| 53 variables_(zone) {} |
| 54 |
| 42 CodeStubAssembler::~CodeStubAssembler() {} | 55 CodeStubAssembler::~CodeStubAssembler() {} |
| 43 | 56 |
| 44 void CodeStubAssembler::CallPrologue() {} | 57 void CodeStubAssembler::CallPrologue() {} |
| 45 | 58 |
| 46 void CodeStubAssembler::CallEpilogue() {} | 59 void CodeStubAssembler::CallEpilogue() {} |
| 47 | 60 |
| 48 Handle<Code> CodeStubAssembler::GenerateCode() { | 61 Handle<Code> CodeStubAssembler::GenerateCode() { |
| 49 DCHECK(!code_generated_); | 62 DCHECK(!code_generated_); |
| 50 | 63 |
| 51 Schedule* schedule = raw_assembler_->Export(); | 64 Schedule* schedule = raw_assembler_->Export(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); | 134 return raw_assembler_->WordSar(value, SmiShiftBitsConstant()); |
| 122 } | 135 } |
| 123 | 136 |
| 124 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \ | 137 #define DEFINE_CODE_STUB_ASSEMBER_BINARY_OP(name) \ |
| 125 Node* CodeStubAssembler::name(Node* a, Node* b) { \ | 138 Node* CodeStubAssembler::name(Node* a, Node* b) { \ |
| 126 return raw_assembler_->name(a, b); \ | 139 return raw_assembler_->name(a, b); \ |
| 127 } | 140 } |
| 128 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP) | 141 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_BINARY_OP) |
| 129 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP | 142 #undef DEFINE_CODE_STUB_ASSEMBER_BINARY_OP |
| 130 | 143 |
| 131 Node* CodeStubAssembler::ChangeInt32ToInt64(Node* value) { | |
| 132 return raw_assembler_->ChangeInt32ToInt64(value); | |
| 133 } | |
| 134 | |
| 135 Node* CodeStubAssembler::WordShl(Node* value, int shift) { | 144 Node* CodeStubAssembler::WordShl(Node* value, int shift) { |
| 136 return raw_assembler_->WordShl(value, Int32Constant(shift)); | 145 return raw_assembler_->WordShl(value, Int32Constant(shift)); |
| 137 } | 146 } |
| 138 | 147 |
| 148 |
| 149 #define DEFINE_CODE_STUB_ASSEMBER_UNARY_OP(name) \ |
| 150 Node* CodeStubAssembler::name(Node* a) { return raw_assembler_->name(a); } |
| 151 CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DEFINE_CODE_STUB_ASSEMBER_UNARY_OP) |
| 152 #undef DEFINE_CODE_STUB_ASSEMBER_UNARY_OP |
| 153 |
| 154 |
| 139 Node* CodeStubAssembler::WordIsSmi(Node* a) { | 155 Node* CodeStubAssembler::WordIsSmi(Node* a) { |
| 140 return WordEqual(raw_assembler_->WordAnd(a, Int32Constant(kSmiTagMask)), | 156 return WordEqual(raw_assembler_->WordAnd(a, Int32Constant(kSmiTagMask)), |
| 141 Int32Constant(0)); | 157 Int32Constant(0)); |
| 142 } | 158 } |
| 143 | 159 |
| 144 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset) { | 160 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset) { |
| 145 return raw_assembler_->Load(MachineType::AnyTagged(), buffer, | 161 return raw_assembler_->Load(MachineType::AnyTagged(), buffer, |
| 146 IntPtrConstant(offset)); | 162 IntPtrConstant(offset)); |
| 147 } | 163 } |
| 148 | 164 |
| 149 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset) { | 165 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset) { |
| 150 return raw_assembler_->Load(MachineType::AnyTagged(), object, | 166 return raw_assembler_->Load(MachineType::AnyTagged(), object, |
| 151 IntPtrConstant(offset - kHeapObjectTag)); | 167 IntPtrConstant(offset - kHeapObjectTag)); |
| 152 } | 168 } |
| 153 | 169 |
| 170 Node* CodeStubAssembler::LoadHeapNumber(Node* object) { |
| 171 return raw_assembler_->Load(MachineType::Float64(), object, |
| 172 IntPtrConstant(HeapNumber::kValueOffset)); |
| 173 } |
| 174 |
| 154 Node* CodeStubAssembler::LoadFixedArrayElementSmiIndex(Node* object, | 175 Node* CodeStubAssembler::LoadFixedArrayElementSmiIndex(Node* object, |
| 155 Node* smi_index, | 176 Node* smi_index, |
| 156 int additional_offset) { | 177 int additional_offset) { |
| 157 Node* header_size = raw_assembler_->Int32Constant( | 178 Node* header_size = raw_assembler_->Int32Constant( |
| 158 additional_offset + FixedArray::kHeaderSize - kHeapObjectTag); | 179 additional_offset + FixedArray::kHeaderSize - kHeapObjectTag); |
| 159 Node* scaled_index = | 180 Node* scaled_index = |
| 160 (kSmiShiftSize == 0) | 181 (kSmiShiftSize == 0) |
| 161 ? raw_assembler_->Word32Shl( | 182 ? raw_assembler_->Word32Shl( |
| 162 smi_index, Int32Constant(kPointerSizeLog2 - kSmiTagSize)) | 183 smi_index, Int32Constant(kPointerSizeLog2 - kSmiTagSize)) |
| 163 : raw_assembler_->Word32Shl(SmiUntag(smi_index), | 184 : raw_assembler_->Word32Shl(SmiUntag(smi_index), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep, | 240 Node* CodeStubAssembler::StoreNoWriteBarrier(MachineRepresentation rep, |
| 220 Node* base, Node* index, | 241 Node* base, Node* index, |
| 221 Node* value) { | 242 Node* value) { |
| 222 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier); | 243 return raw_assembler_->Store(rep, base, index, value, kNoWriteBarrier); |
| 223 } | 244 } |
| 224 | 245 |
| 225 Node* CodeStubAssembler::Projection(int index, Node* value) { | 246 Node* CodeStubAssembler::Projection(int index, Node* value) { |
| 226 return raw_assembler_->Projection(index, value); | 247 return raw_assembler_->Projection(index, value); |
| 227 } | 248 } |
| 228 | 249 |
| 250 Node* CodeStubAssembler::InstanceType(Node* object) { |
| 251 return raw_assembler_->WordAnd( |
| 252 LoadObjectField(LoadObjectField(object, HeapObject::kMapOffset), |
| 253 Map::kInstanceTypeOffset), |
| 254 raw_assembler_->Int32Constant(255)); |
| 255 } |
| 256 |
| 257 Node* CodeStubAssembler::BitFieldValue(Node* word32, uint32_t shift, |
| 258 uint32_t mask) { |
| 259 return raw_assembler_->Word32Shr( |
| 260 raw_assembler_->Word32And(word32, raw_assembler_->Int32Constant(mask)), |
| 261 raw_assembler_->Int32Constant(shift)); |
| 262 } |
| 263 |
| 229 Node* CodeStubAssembler::CallN(CallDescriptor* descriptor, Node* code_target, | 264 Node* CodeStubAssembler::CallN(CallDescriptor* descriptor, Node* code_target, |
| 230 Node** args) { | 265 Node** args) { |
| 231 CallPrologue(); | 266 CallPrologue(); |
| 232 Node* return_value = raw_assembler_->CallN(descriptor, code_target, args); | 267 Node* return_value = raw_assembler_->CallN(descriptor, code_target, args); |
| 233 CallEpilogue(); | 268 CallEpilogue(); |
| 234 return return_value; | 269 return return_value; |
| 235 } | 270 } |
| 236 | 271 |
| 237 | 272 |
| 238 Node* CodeStubAssembler::TailCallN(CallDescriptor* descriptor, | 273 Node* CodeStubAssembler::TailCallN(CallDescriptor* descriptor, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 Node* context, Node* arg1, Node* arg2, | 314 Node* context, Node* arg1, Node* arg2, |
| 280 Node* arg3, Node* arg4) { | 315 Node* arg3, Node* arg4) { |
| 281 CallPrologue(); | 316 CallPrologue(); |
| 282 Node* return_value = raw_assembler_->CallRuntime4(function_id, arg1, arg2, | 317 Node* return_value = raw_assembler_->CallRuntime4(function_id, arg1, arg2, |
| 283 arg3, arg4, context); | 318 arg3, arg4, context); |
| 284 CallEpilogue(); | 319 CallEpilogue(); |
| 285 return return_value; | 320 return return_value; |
| 286 } | 321 } |
| 287 | 322 |
| 288 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, | 323 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, |
| 324 Node* context) { |
| 325 return raw_assembler_->TailCallRuntime0(function_id, context); |
| 326 } |
| 327 |
| 328 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, |
| 289 Node* context, Node* arg1) { | 329 Node* context, Node* arg1) { |
| 290 return raw_assembler_->TailCallRuntime1(function_id, arg1, context); | 330 return raw_assembler_->TailCallRuntime1(function_id, arg1, context); |
| 291 } | 331 } |
| 292 | 332 |
| 293 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, | 333 Node* CodeStubAssembler::TailCallRuntime(Runtime::FunctionId function_id, |
| 294 Node* context, Node* arg1, | 334 Node* context, Node* arg1, |
| 295 Node* arg2) { | 335 Node* arg2) { |
| 296 return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context); | 336 return raw_assembler_->TailCallRuntime2(function_id, arg1, arg2, context); |
| 297 } | 337 } |
| 298 | 338 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 } | 642 } |
| 603 } | 643 } |
| 604 } | 644 } |
| 605 | 645 |
| 606 bound_ = true; | 646 bound_ = true; |
| 607 } | 647 } |
| 608 | 648 |
| 609 } // namespace compiler | 649 } // namespace compiler |
| 610 } // namespace internal | 650 } // namespace internal |
| 611 } // namespace v8 | 651 } // namespace v8 |
| OLD | NEW |