| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
| 8 #include "src/base/atomic-utils.h" | 8 #include "src/base/atomic-utils.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compiler/wasm-compiler.h" | 10 #include "src/compiler/wasm-compiler.h" |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } // namespace | 808 } // namespace |
| 809 | 809 |
| 810 Handle<JSArrayBuffer> wasm::SetupArrayBuffer(Isolate* isolate, | 810 Handle<JSArrayBuffer> wasm::SetupArrayBuffer(Isolate* isolate, |
| 811 void* backing_store, size_t size, | 811 void* backing_store, size_t size, |
| 812 bool is_external, | 812 bool is_external, |
| 813 bool enable_guard_regions) { | 813 bool enable_guard_regions) { |
| 814 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); | 814 Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); |
| 815 JSArrayBuffer::Setup(buffer, isolate, is_external, backing_store, | 815 JSArrayBuffer::Setup(buffer, isolate, is_external, backing_store, |
| 816 static_cast<int>(size)); | 816 static_cast<int>(size)); |
| 817 buffer->set_is_neuterable(false); | 817 buffer->set_is_neuterable(false); |
| 818 buffer->set_is_wasm_buffer(true); |
| 818 buffer->set_has_guard_region(enable_guard_regions); | 819 buffer->set_has_guard_region(enable_guard_regions); |
| 819 | 820 |
| 820 if (is_external) { | 821 if (is_external) { |
| 821 // We mark the buffer as external if we allocated it here with guard | 822 // We mark the buffer as external if we allocated it here with guard |
| 822 // pages. That means we need to arrange for it to be freed. | 823 // pages. That means we need to arrange for it to be freed. |
| 823 | 824 |
| 824 // TODO(eholk): Finalizers may not run when the main thread is shutting | 825 // TODO(eholk): Finalizers may not run when the main thread is shutting |
| 825 // down, which means we may leak memory here. | 826 // down, which means we may leak memory here. |
| 826 Handle<Object> global_handle = isolate->global_handles()->Create(*buffer); | 827 Handle<Object> global_handle = isolate->global_handles()->Create(*buffer); |
| 827 GlobalHandles::MakeWeak(global_handle.location(), global_handle.location(), | 828 GlobalHandles::MakeWeak(global_handle.location(), global_handle.location(), |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 // Set up the memory for the new instance. | 1216 // Set up the memory for the new instance. |
| 1216 //-------------------------------------------------------------------------- | 1217 //-------------------------------------------------------------------------- |
| 1217 uint32_t min_mem_pages = module_->min_mem_pages; | 1218 uint32_t min_mem_pages = module_->min_mem_pages; |
| 1218 (module_->is_wasm() ? isolate_->counters()->wasm_wasm_min_mem_pages_count() | 1219 (module_->is_wasm() ? isolate_->counters()->wasm_wasm_min_mem_pages_count() |
| 1219 : isolate_->counters()->wasm_asm_min_mem_pages_count()) | 1220 : isolate_->counters()->wasm_asm_min_mem_pages_count()) |
| 1220 ->AddSample(min_mem_pages); | 1221 ->AddSample(min_mem_pages); |
| 1221 | 1222 |
| 1222 if (!memory_.is_null()) { | 1223 if (!memory_.is_null()) { |
| 1223 // Set externally passed ArrayBuffer non neuterable. | 1224 // Set externally passed ArrayBuffer non neuterable. |
| 1224 memory_->set_is_neuterable(false); | 1225 memory_->set_is_neuterable(false); |
| 1226 memory_->set_is_wasm_buffer(true); |
| 1225 | 1227 |
| 1226 DCHECK_IMPLIES(EnableGuardRegions(), | 1228 DCHECK_IMPLIES(EnableGuardRegions(), |
| 1227 module_->is_asm_js() || memory_->has_guard_region()); | 1229 module_->is_asm_js() || memory_->has_guard_region()); |
| 1228 } else if (min_mem_pages > 0) { | 1230 } else if (min_mem_pages > 0) { |
| 1229 memory_ = AllocateMemory(min_mem_pages); | 1231 memory_ = AllocateMemory(min_mem_pages); |
| 1230 if (memory_.is_null()) return {}; // failed to allocate memory | 1232 if (memory_.is_null()) return {}; // failed to allocate memory |
| 1231 } | 1233 } |
| 1232 | 1234 |
| 1233 //-------------------------------------------------------------------------- | 1235 //-------------------------------------------------------------------------- |
| 1234 // Check that indirect function table segments are within bounds. | 1236 // Check that indirect function table segments are within bounds. |
| (...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3308 callee_compiled->instruction_start()); | 3310 callee_compiled->instruction_start()); |
| 3309 } | 3311 } |
| 3310 DCHECK_EQ(non_compiled_functions.size(), idx); | 3312 DCHECK_EQ(non_compiled_functions.size(), idx); |
| 3311 } | 3313 } |
| 3312 | 3314 |
| 3313 Code* ret = | 3315 Code* ret = |
| 3314 Code::cast(compiled_module->code_table()->get(func_to_return_idx)); | 3316 Code::cast(compiled_module->code_table()->get(func_to_return_idx)); |
| 3315 DCHECK_EQ(Code::WASM_FUNCTION, ret->kind()); | 3317 DCHECK_EQ(Code::WASM_FUNCTION, ret->kind()); |
| 3316 return handle(ret, isolate); | 3318 return handle(ret, isolate); |
| 3317 } | 3319 } |
| OLD | NEW |