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/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 | 9 |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 | 983 |
984 //-------------------------------------------------------------------------- | 984 //-------------------------------------------------------------------------- |
985 // Set up the memory for the new instance. | 985 // Set up the memory for the new instance. |
986 //-------------------------------------------------------------------------- | 986 //-------------------------------------------------------------------------- |
987 MaybeHandle<JSArrayBuffer> old_memory; | 987 MaybeHandle<JSArrayBuffer> old_memory; |
988 | 988 |
989 uint32_t min_mem_pages = module_->min_mem_pages; | 989 uint32_t min_mem_pages = module_->min_mem_pages; |
990 isolate_->counters()->wasm_min_mem_pages_count()->AddSample(min_mem_pages); | 990 isolate_->counters()->wasm_min_mem_pages_count()->AddSample(min_mem_pages); |
991 // TODO(wasm): re-enable counter for max_mem_pages when we use that field. | 991 // TODO(wasm): re-enable counter for max_mem_pages when we use that field. |
992 | 992 |
993 if (memory_.is_null() && min_mem_pages > 0) { | 993 if (!memory_.is_null()) { |
| 994 // Set externally passed ArrayBuffer non neuterable. |
| 995 memory_->set_is_neuterable(false); |
| 996 } else if (min_mem_pages > 0) { |
994 memory_ = AllocateMemory(min_mem_pages); | 997 memory_ = AllocateMemory(min_mem_pages); |
995 if (memory_.is_null()) return nothing; // failed to allocate memory | 998 if (memory_.is_null()) return nothing; // failed to allocate memory |
996 } | 999 } |
997 | 1000 |
998 if (!memory_.is_null()) { | 1001 if (!memory_.is_null()) { |
999 instance->SetInternalField(kWasmMemArrayBuffer, *memory_); | 1002 instance->SetInternalField(kWasmMemArrayBuffer, *memory_); |
1000 Address mem_start = static_cast<Address>(memory_->backing_store()); | 1003 Address mem_start = static_cast<Address>(memory_->backing_store()); |
1001 uint32_t mem_size = | 1004 uint32_t mem_size = |
1002 static_cast<uint32_t>(memory_->byte_length()->Number()); | 1005 static_cast<uint32_t>(memory_->byte_length()->Number()); |
1003 LoadDataSegments(globals, mem_start, mem_size); | 1006 LoadDataSegments(globals, mem_start, mem_size); |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 CHECK_NOT_NULL(result.val); | 1990 CHECK_NOT_NULL(result.val); |
1988 module = const_cast<WasmModule*>(result.val); | 1991 module = const_cast<WasmModule*>(result.val); |
1989 } | 1992 } |
1990 | 1993 |
1991 Handle<WasmModuleWrapper> module_wrapper = | 1994 Handle<WasmModuleWrapper> module_wrapper = |
1992 WasmModuleWrapper::New(isolate, module); | 1995 WasmModuleWrapper::New(isolate, module); |
1993 | 1996 |
1994 compiled_module->set_module_wrapper(module_wrapper); | 1997 compiled_module->set_module_wrapper(module_wrapper); |
1995 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); | 1998 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); |
1996 } | 1999 } |
OLD | NEW |