Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: src/wasm/wasm-module.cc

Issue 2646713002: [wasm] Enable content policy for wasm compilation. (Closed)
Patch Set: CompileError Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/adapters.h" 8 #include "src/base/adapters.h"
9 #include "src/base/atomic-utils.h" 9 #include "src/base/atomic-utils.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 bool wasm::IsWasmInstance(Object* object) { 2176 bool wasm::IsWasmInstance(Object* object) {
2177 return WasmInstanceObject::IsWasmInstanceObject(object); 2177 return WasmInstanceObject::IsWasmInstanceObject(object);
2178 } 2178 }
2179 2179
2180 Handle<Script> wasm::GetScript(Handle<JSObject> instance) { 2180 Handle<Script> wasm::GetScript(Handle<JSObject> instance) {
2181 WasmCompiledModule* compiled_module = 2181 WasmCompiledModule* compiled_module =
2182 WasmInstanceObject::cast(*instance)->compiled_module(); 2182 WasmInstanceObject::cast(*instance)->compiled_module();
2183 return handle(compiled_module->script()); 2183 return handle(compiled_module->script());
2184 } 2184 }
2185 2185
2186 bool wasm::IsWasmCodegenAllowed(Isolate* isolate, Handle<Context> context) {
2187 return isolate->allow_code_gen_callback() == nullptr ||
2188 isolate->allow_code_gen_callback()(v8::Utils::ToLocal(context));
2189 }
2190
2186 // TODO(clemensh): origin can be inferred from asm_js_script; remove it. 2191 // TODO(clemensh): origin can be inferred from asm_js_script; remove it.
2187 MaybeHandle<WasmModuleObject> wasm::CreateModuleObjectFromBytes( 2192 MaybeHandle<WasmModuleObject> wasm::CreateModuleObjectFromBytes(
2188 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, 2193 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower,
2189 ModuleOrigin origin, Handle<Script> asm_js_script, 2194 ModuleOrigin origin, Handle<Script> asm_js_script,
2190 Vector<const byte> asm_js_offset_table_bytes) { 2195 Vector<const byte> asm_js_offset_table_bytes) {
2191 MaybeHandle<WasmModuleObject> nothing; 2196 MaybeHandle<WasmModuleObject> nothing;
2197
2198 if (!IsWasmCodegenAllowed(isolate, isolate->native_context())) {
2199 thrower->CompileError("Wasm code generation disallowed in this context");
2200 return nothing;
2201 }
2202
2192 ModuleResult result = DecodeWasmModule(isolate, start, end, false, origin); 2203 ModuleResult result = DecodeWasmModule(isolate, start, end, false, origin);
2193 if (result.failed()) { 2204 if (result.failed()) {
2194 if (result.val) delete result.val; 2205 if (result.val) delete result.val;
2195 thrower->CompileFailed("Wasm decoding failed", result); 2206 thrower->CompileFailed("Wasm decoding failed", result);
2196 return nothing; 2207 return nothing;
2197 } 2208 }
2198 2209
2199 // The {module_wrapper} will take ownership of the {WasmModule} object, 2210 // The {module_wrapper} will take ownership of the {WasmModule} object,
2200 // and it will be destroyed when the GC reclaims the wrapper object. 2211 // and it will be destroyed when the GC reclaims the wrapper object.
2201 Handle<WasmModuleWrapper> module_wrapper = 2212 Handle<WasmModuleWrapper> module_wrapper =
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 2639
2629 JSObject::AddProperty(entry, name_string, export_name.ToHandleChecked(), 2640 JSObject::AddProperty(entry, name_string, export_name.ToHandleChecked(),
2630 NONE); 2641 NONE);
2631 JSObject::AddProperty(entry, kind_string, export_kind, NONE); 2642 JSObject::AddProperty(entry, kind_string, export_kind, NONE);
2632 2643
2633 storage->set(index, *entry); 2644 storage->set(index, *entry);
2634 } 2645 }
2635 2646
2636 return array_object; 2647 return array_object;
2637 } 2648 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698