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 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 if (target->kind() == Code::WASM_FUNCTION) { | 1614 if (target->kind() == Code::WASM_FUNCTION) { |
1615 ++wasm_count; | 1615 ++wasm_count; |
1616 code = handle(target); | 1616 code = handle(target); |
1617 } | 1617 } |
1618 } | 1618 } |
1619 DCHECK(wasm_count == 1); | 1619 DCHECK(wasm_count == 1); |
1620 return code; | 1620 return code; |
1621 } else { | 1621 } else { |
1622 // Copy the signature to avoid a raw pointer into a heap object when | 1622 // Copy the signature to avoid a raw pointer into a heap object when |
1623 // GC can happen. | 1623 // GC can happen. |
1624 Zone zone(isolate_->allocator()); | 1624 Zone zone(isolate_->allocator(), ZONE_NAME); |
1625 MachineRepresentation* reps = | 1625 MachineRepresentation* reps = |
1626 zone.NewArray<MachineRepresentation>(sig_data_size); | 1626 zone.NewArray<MachineRepresentation>(sig_data_size); |
1627 memcpy(reps, sig_data->GetDataStartAddress(), | 1627 memcpy(reps, sig_data->GetDataStartAddress(), |
1628 sizeof(MachineRepresentation) * sig_data_size); | 1628 sizeof(MachineRepresentation) * sig_data_size); |
1629 FunctionSig sig(ret_count, param_count, reps); | 1629 FunctionSig sig(ret_count, param_count, reps); |
1630 | 1630 |
1631 return compiler::CompileWasmToJSWrapper(isolate_, target, &sig, index, | 1631 return compiler::CompileWasmToJSWrapper(isolate_, target, &sig, index, |
1632 module_name, import_name); | 1632 module_name, import_name); |
1633 } | 1633 } |
1634 } | 1634 } |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 return module_obj; | 2124 return module_obj; |
2125 } | 2125 } |
2126 | 2126 |
2127 // TODO(clemensh): origin can be inferred from asm_js_script; remove it. | 2127 // TODO(clemensh): origin can be inferred from asm_js_script; remove it. |
2128 MaybeHandle<JSObject> wasm::CreateModuleObjectFromBytes( | 2128 MaybeHandle<JSObject> wasm::CreateModuleObjectFromBytes( |
2129 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, | 2129 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, |
2130 ModuleOrigin origin, Handle<Script> asm_js_script, | 2130 ModuleOrigin origin, Handle<Script> asm_js_script, |
2131 const byte* asm_js_offset_tables_start, | 2131 const byte* asm_js_offset_tables_start, |
2132 const byte* asm_js_offset_tables_end) { | 2132 const byte* asm_js_offset_tables_end) { |
2133 MaybeHandle<JSObject> nothing; | 2133 MaybeHandle<JSObject> nothing; |
2134 Zone zone(isolate->allocator()); | 2134 Zone zone(isolate->allocator(), ZONE_NAME); |
2135 ModuleResult result = | 2135 ModuleResult result = |
2136 DecodeWasmModule(isolate, &zone, start, end, false, origin); | 2136 DecodeWasmModule(isolate, &zone, start, end, false, origin); |
2137 std::unique_ptr<const WasmModule> decoded_module(result.val); | 2137 std::unique_ptr<const WasmModule> decoded_module(result.val); |
2138 if (result.failed()) { | 2138 if (result.failed()) { |
2139 thrower->CompileFailed("Wasm decoding failed", result); | 2139 thrower->CompileFailed("Wasm decoding failed", result); |
2140 return nothing; | 2140 return nothing; |
2141 } | 2141 } |
2142 MaybeHandle<WasmCompiledModule> maybe_compiled_module = | 2142 MaybeHandle<WasmCompiledModule> maybe_compiled_module = |
2143 decoded_module->CompileFunctions(isolate, thrower); | 2143 decoded_module->CompileFunctions(isolate, thrower); |
2144 if (maybe_compiled_module.is_null()) return nothing; | 2144 if (maybe_compiled_module.is_null()) return nothing; |
(...skipping 14 matching lines...) Expand all Loading... |
2159 offset_tables_len); | 2159 offset_tables_len); |
2160 compiled_module->set_asm_js_offset_tables(offset_tables); | 2160 compiled_module->set_asm_js_offset_tables(offset_tables); |
2161 } | 2161 } |
2162 | 2162 |
2163 return CreateCompiledModuleObject(isolate, compiled_module, origin); | 2163 return CreateCompiledModuleObject(isolate, compiled_module, origin); |
2164 } | 2164 } |
2165 | 2165 |
2166 bool wasm::ValidateModuleBytes(Isolate* isolate, const byte* start, | 2166 bool wasm::ValidateModuleBytes(Isolate* isolate, const byte* start, |
2167 const byte* end, ErrorThrower* thrower, | 2167 const byte* end, ErrorThrower* thrower, |
2168 ModuleOrigin origin) { | 2168 ModuleOrigin origin) { |
2169 Zone zone(isolate->allocator()); | 2169 Zone zone(isolate->allocator(), ZONE_NAME); |
2170 ModuleResult result = | 2170 ModuleResult result = |
2171 DecodeWasmModule(isolate, &zone, start, end, false, origin); | 2171 DecodeWasmModule(isolate, &zone, start, end, false, origin); |
2172 if (result.ok()) { | 2172 if (result.ok()) { |
2173 DCHECK_NOT_NULL(result.val); | 2173 DCHECK_NOT_NULL(result.val); |
2174 delete result.val; | 2174 delete result.val; |
2175 return true; | 2175 return true; |
2176 } | 2176 } |
2177 return false; | 2177 return false; |
2178 } | 2178 } |
2179 | 2179 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2294 } | 2294 } |
2295 | 2295 |
2296 void testing::ValidateOrphanedInstance(Isolate* isolate, | 2296 void testing::ValidateOrphanedInstance(Isolate* isolate, |
2297 Handle<JSObject> instance) { | 2297 Handle<JSObject> instance) { |
2298 DisallowHeapAllocation no_gc; | 2298 DisallowHeapAllocation no_gc; |
2299 CHECK(IsWasmObject(*instance)); | 2299 CHECK(IsWasmObject(*instance)); |
2300 WasmCompiledModule* compiled_module = GetCompiledModule(*instance); | 2300 WasmCompiledModule* compiled_module = GetCompiledModule(*instance); |
2301 CHECK(compiled_module->has_weak_module_object()); | 2301 CHECK(compiled_module->has_weak_module_object()); |
2302 CHECK(compiled_module->ptr_to_weak_module_object()->cleared()); | 2302 CHECK(compiled_module->ptr_to_weak_module_object()->cleared()); |
2303 } | 2303 } |
OLD | NEW |