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