| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 return chunk; | 53 return chunk; |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 class CodeStubGraphBuilderBase : public HGraphBuilder { | 57 class CodeStubGraphBuilderBase : public HGraphBuilder { |
| 58 public: | 58 public: |
| 59 CodeStubGraphBuilderBase(Isolate* isolate, HydrogenCodeStub* stub) | 59 CodeStubGraphBuilderBase(Isolate* isolate, HydrogenCodeStub* stub) |
| 60 : HGraphBuilder(&info_), info_(stub, isolate), context_(NULL) { | 60 : HGraphBuilder(&info_), info_(stub, isolate), context_(NULL) { |
| 61 int major_key = stub->MajorKey(); | 61 int major_key = stub->MajorKey(); |
| 62 descriptor_ = info_.isolate()->code_stub_interface_descriptor(major_key); | 62 descriptor_ = isolate->code_stub_interface_descriptor(major_key); |
| 63 if (descriptor_->register_param_count_ < 0) { | 63 if (descriptor_->register_param_count_ < 0) { |
| 64 stub->InitializeInterfaceDescriptor(info_.isolate(), descriptor_); | 64 stub->InitializeInterfaceDescriptor(isolate, descriptor_); |
| 65 } | 65 } |
| 66 parameters_.Reset(new HParameter*[descriptor_->register_param_count_]); | 66 parameters_.Reset(new HParameter*[descriptor_->register_param_count_]); |
| 67 } | 67 } |
| 68 virtual bool BuildGraph(); | 68 virtual bool BuildGraph(); |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 virtual void BuildCodeStub() = 0; | 71 virtual void BuildCodeStub() = 0; |
| 72 HParameter* GetParameter(int parameter) { return parameters_[parameter]; } | 72 HParameter* GetParameter(int parameter) { return parameters_[parameter]; } |
| 73 CompilationInfo* info() { return &info_; } | 73 CompilationInfo* info() { return &info_; } |
| 74 HydrogenCodeStub* stub() { return info_.code_stub(); } | 74 HydrogenCodeStub* stub() { return info_.code_stub(); } |
| 75 HContext* context() { return context_; } | 75 HContext* context() { return context_; } |
| 76 Isolate* isolate() { return info_.isolate(); } | 76 Isolate* isolate() { return info_.isolate(); } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 SmartArrayPointer<HParameter*> parameters_; | 79 SmartArrayPointer<HParameter*> parameters_; |
| 80 CompilationInfoWithZone info_; | 80 CompilationInfoWithZone info_; |
| 81 CodeStubInterfaceDescriptor* descriptor_; | 81 CodeStubInterfaceDescriptor* descriptor_; |
| 82 HContext* context_; | 82 HContext* context_; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 | 85 |
| 86 bool CodeStubGraphBuilderBase::BuildGraph() { | 86 bool CodeStubGraphBuilderBase::BuildGraph() { |
| 87 if (FLAG_trace_hydrogen) { | 87 if (FLAG_trace_hydrogen) { |
| 88 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); | 88 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); |
| 89 PrintF("-----------------------------------------------------------\n"); | 89 PrintF("-----------------------------------------------------------\n"); |
| 90 PrintF("Compiling stub %s using hydrogen\n", name); | 90 PrintF("Compiling stub %s using hydrogen\n", name); |
| 91 HTracer::Instance()->TraceCompilation(&info_); | 91 isolate()->GetHTracer()->TraceCompilation(&info_); |
| 92 } | 92 } |
| 93 | 93 |
| 94 Zone* zone = this->zone(); | 94 Zone* zone = this->zone(); |
| 95 HEnvironment* start_environment = | 95 HEnvironment* start_environment = |
| 96 new(zone) HEnvironment(zone, descriptor_->register_param_count_); | 96 new(zone) HEnvironment(zone, descriptor_->register_param_count_); |
| 97 HBasicBlock* next_block = CreateBasicBlock(start_environment); | 97 HBasicBlock* next_block = CreateBasicBlock(start_environment); |
| 98 | 98 |
| 99 current_block()->Goto(next_block); | 99 current_block()->Goto(next_block); |
| 100 next_block->SetJoinId(BailoutId::StubEntry()); | 100 next_block->SetJoinId(BailoutId::StubEntry()); |
| 101 set_current_block(next_block); | 101 set_current_block(next_block); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 357 } |
| 358 | 358 |
| 359 | 359 |
| 360 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 360 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
| 361 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); | 361 CodeStubGraphBuilder<ArrayNArgumentsConstructorStub> builder(this); |
| 362 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | 362 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
| 363 return chunk->Codegen(Code::COMPILED_STUB); | 363 return chunk->Codegen(Code::COMPILED_STUB); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } } // namespace v8::internal | 366 } } // namespace v8::internal |
| OLD | NEW |