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/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 | 10 |
(...skipping 2741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 } | 2752 } |
2753 return mem_buffer_; | 2753 return mem_buffer_; |
2754 } else { | 2754 } else { |
2755 return jsgraph()->RelocatableIntPtrConstant( | 2755 return jsgraph()->RelocatableIntPtrConstant( |
2756 reinterpret_cast<uintptr_t>(module_->instance->mem_start + offset), | 2756 reinterpret_cast<uintptr_t>(module_->instance->mem_start + offset), |
2757 RelocInfo::WASM_MEMORY_REFERENCE); | 2757 RelocInfo::WASM_MEMORY_REFERENCE); |
2758 } | 2758 } |
2759 } | 2759 } |
2760 | 2760 |
2761 Node* WasmGraphBuilder::CurrentMemoryPages() { | 2761 Node* WasmGraphBuilder::CurrentMemoryPages() { |
2762 Runtime::FunctionId function_id = Runtime::kWasmMemorySize; | 2762 return graph()->NewNode(jsgraph()->machine()->Word32Shr(), MemSize(0), |
2763 const Runtime::Function* function = Runtime::FunctionForId(function_id); | 2763 jsgraph()->Int32Constant(16)); |
2764 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( | |
2765 jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow, | |
2766 CallDescriptor::kNoFlags); | |
2767 wasm::ModuleEnv* module = module_; | |
2768 Node* inputs[] = { | |
2769 jsgraph()->CEntryStubConstant(function->result_size), // C entry | |
2770 jsgraph()->ExternalConstant( | |
2771 ExternalReference(function_id, jsgraph()->isolate())), // ref | |
2772 jsgraph()->Int32Constant(function->nargs), // arity | |
2773 jsgraph()->HeapConstant(module->instance->context), // context | |
2774 *effect_, | |
2775 *control_}; | |
2776 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), | |
2777 static_cast<int>(arraysize(inputs)), inputs); | |
2778 | |
2779 Node* result = BuildChangeSmiToInt32(call); | |
2780 | |
2781 *effect_ = call; | |
2782 return result; | |
2783 } | 2764 } |
2784 | 2765 |
2785 Node* WasmGraphBuilder::MemSize(uint32_t offset) { | 2766 Node* WasmGraphBuilder::MemSize(uint32_t offset) { |
2786 DCHECK(module_ && module_->instance); | 2767 DCHECK(module_ && module_->instance); |
2787 uint32_t size = static_cast<uint32_t>(module_->instance->mem_size); | 2768 uint32_t size = static_cast<uint32_t>(module_->instance->mem_size); |
2788 if (offset == 0) { | 2769 if (offset == 0) { |
2789 if (!mem_size_) | 2770 if (!mem_size_) |
2790 mem_size_ = jsgraph()->RelocatableInt32Constant( | 2771 mem_size_ = jsgraph()->RelocatableInt32Constant( |
2791 size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE); | 2772 size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE); |
2792 return mem_size_; | 2773 return mem_size_; |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 function_->code_start_offset), | 3383 function_->code_start_offset), |
3403 compile_ms); | 3384 compile_ms); |
3404 } | 3385 } |
3405 | 3386 |
3406 return code; | 3387 return code; |
3407 } | 3388 } |
3408 | 3389 |
3409 } // namespace compiler | 3390 } // namespace compiler |
3410 } // namespace internal | 3391 } // namespace internal |
3411 } // namespace v8 | 3392 } // namespace v8 |
OLD | NEW |