| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
| 6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
| 7 | 7 |
| 8 #include <setjmp.h> | 8 #include <setjmp.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 // interpretation (by adding to the interpreter manually). | 510 // interpretation (by adding to the interpreter manually). |
| 511 class WasmFunctionCompiler : private GraphAndBuilders { | 511 class WasmFunctionCompiler : private GraphAndBuilders { |
| 512 public: | 512 public: |
| 513 Isolate* isolate() { return testing_module_->isolate(); } | 513 Isolate* isolate() { return testing_module_->isolate(); } |
| 514 Graph* graph() const { return main_graph_; } | 514 Graph* graph() const { return main_graph_; } |
| 515 Zone* zone() const { return graph()->zone(); } | 515 Zone* zone() const { return graph()->zone(); } |
| 516 CommonOperatorBuilder* common() { return &main_common_; } | 516 CommonOperatorBuilder* common() { return &main_common_; } |
| 517 MachineOperatorBuilder* machine() { return &main_machine_; } | 517 MachineOperatorBuilder* machine() { return &main_machine_; } |
| 518 CallDescriptor* descriptor() { | 518 CallDescriptor* descriptor() { |
| 519 if (descriptor_ == nullptr) { | 519 if (descriptor_ == nullptr) { |
| 520 descriptor_ = testing_module_->GetWasmCallDescriptor(zone(), sig); | 520 descriptor_ = compiler::GetWasmCallDescriptor(zone(), sig); |
| 521 } | 521 } |
| 522 return descriptor_; | 522 return descriptor_; |
| 523 } | 523 } |
| 524 uint32_t function_index() { return function_->func_index; } | 524 uint32_t function_index() { return function_->func_index; } |
| 525 | 525 |
| 526 void Build(const byte* start, const byte* end) { | 526 void Build(const byte* start, const byte* end) { |
| 527 size_t locals_size = local_decls.Size(); | 527 size_t locals_size = local_decls.Size(); |
| 528 size_t total_size = end - start + locals_size + 1; | 528 size_t total_size = end - start + locals_size + 1; |
| 529 byte* buffer = static_cast<byte*>(zone()->New(total_size)); | 529 byte* buffer = static_cast<byte*>(zone()->New(total_size)); |
| 530 // Prepend the local decls to the code. | 530 // Prepend the local decls to the code. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 source_position_table_(this->graph()), | 597 source_position_table_(this->graph()), |
| 598 interpreter_(module->interpreter()) { | 598 interpreter_(module->interpreter()) { |
| 599 // Get a new function from the testing module. | 599 // Get a new function from the testing module. |
| 600 int index = module->AddFunction(sig, Handle<Code>::null(), name); | 600 int index = module->AddFunction(sig, Handle<Code>::null(), name); |
| 601 function_ = testing_module_->GetFunctionAt(index); | 601 function_ = testing_module_->GetFunctionAt(index); |
| 602 } | 602 } |
| 603 | 603 |
| 604 Handle<Code> Compile() { | 604 Handle<Code> Compile() { |
| 605 CallDescriptor* desc = descriptor(); | 605 CallDescriptor* desc = descriptor(); |
| 606 if (kPointerSize == 4) { | 606 if (kPointerSize == 4) { |
| 607 desc = testing_module_->GetI32WasmCallDescriptor(this->zone(), desc); | 607 desc = compiler::GetI32WasmCallDescriptor(this->zone(), desc); |
| 608 } | 608 } |
| 609 EmbeddedVector<char, 16> comp_name; | 609 EmbeddedVector<char, 16> comp_name; |
| 610 int comp_name_len = SNPrintF(comp_name, "wasm#%u", this->function_index()); | 610 int comp_name_len = SNPrintF(comp_name, "wasm#%u", this->function_index()); |
| 611 comp_name.Truncate(comp_name_len); | 611 comp_name.Truncate(comp_name_len); |
| 612 CompilationInfo info(comp_name, this->isolate(), this->zone(), | 612 CompilationInfo info(comp_name, this->isolate(), this->zone(), |
| 613 Code::ComputeFlags(Code::WASM_FUNCTION)); | 613 Code::ComputeFlags(Code::WASM_FUNCTION)); |
| 614 std::unique_ptr<CompilationJob> job(Pipeline::NewWasmCompilationJob( | 614 std::unique_ptr<CompilationJob> job(Pipeline::NewWasmCompilationJob( |
| 615 &info, &jsgraph, desc, &source_position_table_, nullptr, false)); | 615 &info, &jsgraph, desc, &source_position_table_, nullptr, false)); |
| 616 if (job->ExecuteJob() != CompilationJob::SUCCEEDED || | 616 if (job->ExecuteJob() != CompilationJob::SUCCEEDED || |
| 617 job->FinalizeJob() != CompilationJob::SUCCEEDED) | 617 job->FinalizeJob() != CompilationJob::SUCCEEDED) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 if (trap_handler::UseTrapHandler()) { \ | 836 if (trap_handler::UseTrapHandler()) { \ |
| 837 return; \ | 837 return; \ |
| 838 } \ | 838 } \ |
| 839 RunWasm_##name(kExecuteInterpreted); \ | 839 RunWasm_##name(kExecuteInterpreted); \ |
| 840 } \ | 840 } \ |
| 841 void RunWasm_##name(WasmExecutionMode execution_mode) | 841 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 842 | 842 |
| 843 } // namespace | 843 } // namespace |
| 844 | 844 |
| 845 #endif | 845 #endif |
| OLD | NEW |