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/api-natives.h" | 5 #include "src/api-natives.h" |
6 #include "src/api.h" | 6 #include "src/api.h" |
7 #include "src/asmjs/asm-js.h" | 7 #include "src/asmjs/asm-js.h" |
8 #include "src/asmjs/asm-typer.h" | 8 #include "src/asmjs/asm-typer.h" |
9 #include "src/asmjs/asm-wasm-builder.h" | 9 #include "src/asmjs/asm-wasm-builder.h" |
10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); | 88 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); |
89 ErrorThrower thrower(isolate, "Wasm.verifyModule()"); | 89 ErrorThrower thrower(isolate, "Wasm.verifyModule()"); |
90 | 90 |
91 if (args.Length() < 1) { | 91 if (args.Length() < 1) { |
92 thrower.TypeError("Argument 0 must be a buffer source"); | 92 thrower.TypeError("Argument 0 must be a buffer source"); |
93 return; | 93 return; |
94 } | 94 } |
95 RawBuffer buffer = GetRawBufferSource(args[0], &thrower); | 95 RawBuffer buffer = GetRawBufferSource(args[0], &thrower); |
96 if (thrower.error()) return; | 96 if (thrower.error()) return; |
97 | 97 |
98 i::Zone zone(isolate->allocator()); | 98 i::Zone zone(isolate->allocator(), ZONE_NAME); |
99 internal::wasm::ModuleResult result = | 99 internal::wasm::ModuleResult result = |
100 internal::wasm::DecodeWasmModule(isolate, &zone, buffer.start, buffer.end, | 100 internal::wasm::DecodeWasmModule(isolate, &zone, buffer.start, buffer.end, |
101 true, internal::wasm::kWasmOrigin); | 101 true, internal::wasm::kWasmOrigin); |
102 | 102 |
103 if (result.failed()) { | 103 if (result.failed()) { |
104 thrower.CompileFailed("", result); | 104 thrower.CompileFailed("", result); |
105 } | 105 } |
106 | 106 |
107 if (result.val) delete result.val; | 107 if (result.val) delete result.val; |
108 } | 108 } |
109 | 109 |
110 void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) { | 110 void VerifyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) { |
111 HandleScope scope(args.GetIsolate()); | 111 HandleScope scope(args.GetIsolate()); |
112 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); | 112 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); |
113 ErrorThrower thrower(isolate, "Wasm.verifyFunction()"); | 113 ErrorThrower thrower(isolate, "Wasm.verifyFunction()"); |
114 | 114 |
115 if (args.Length() < 1) { | 115 if (args.Length() < 1) { |
116 thrower.TypeError("Argument 0 must be a buffer source"); | 116 thrower.TypeError("Argument 0 must be a buffer source"); |
117 return; | 117 return; |
118 } | 118 } |
119 RawBuffer buffer = GetRawBufferSource(args[0], &thrower); | 119 RawBuffer buffer = GetRawBufferSource(args[0], &thrower); |
120 if (thrower.error()) return; | 120 if (thrower.error()) return; |
121 | 121 |
122 internal::wasm::FunctionResult result; | 122 internal::wasm::FunctionResult result; |
123 { | 123 { |
124 // Verification of a single function shouldn't allocate. | 124 // Verification of a single function shouldn't allocate. |
125 i::DisallowHeapAllocation no_allocation; | 125 i::DisallowHeapAllocation no_allocation; |
126 i::Zone zone(isolate->allocator()); | 126 i::Zone zone(isolate->allocator(), ZONE_NAME); |
127 result = internal::wasm::DecodeWasmFunction(isolate, &zone, nullptr, | 127 result = internal::wasm::DecodeWasmFunction(isolate, &zone, nullptr, |
128 buffer.start, buffer.end); | 128 buffer.start, buffer.end); |
129 } | 129 } |
130 | 130 |
131 if (result.failed()) { | 131 if (result.failed()) { |
132 thrower.CompileFailed("", result); | 132 thrower.CompileFailed("", result); |
133 } | 133 } |
134 | 134 |
135 if (result.val) delete result.val; | 135 if (result.val) delete result.val; |
136 } | 136 } |
137 | 137 |
138 i::MaybeHandle<i::JSObject> InstantiateModule( | 138 i::MaybeHandle<i::JSObject> InstantiateModule( |
139 const v8::FunctionCallbackInfo<v8::Value>& args, const byte* start, | 139 const v8::FunctionCallbackInfo<v8::Value>& args, const byte* start, |
140 const byte* end, ErrorThrower* thrower) { | 140 const byte* end, ErrorThrower* thrower) { |
141 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); | 141 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); |
142 | 142 |
143 // Decode but avoid a redundant pass over function bodies for verification. | 143 // Decode but avoid a redundant pass over function bodies for verification. |
144 // Verification will happen during compilation. | 144 // Verification will happen during compilation. |
145 i::Zone zone(isolate->allocator()); | 145 i::Zone zone(isolate->allocator(), ZONE_NAME); |
146 i::MaybeHandle<i::JSObject> module_object = | 146 i::MaybeHandle<i::JSObject> module_object = |
147 i::wasm::CreateModuleObjectFromBytes( | 147 i::wasm::CreateModuleObjectFromBytes( |
148 isolate, start, end, thrower, i::wasm::kWasmOrigin, | 148 isolate, start, end, thrower, i::wasm::kWasmOrigin, |
149 i::Handle<i::Script>::null(), nullptr, nullptr); | 149 i::Handle<i::Script>::null(), nullptr, nullptr); |
150 i::MaybeHandle<i::JSObject> object; | 150 i::MaybeHandle<i::JSObject> object; |
151 if (!module_object.is_null()) { | 151 if (!module_object.is_null()) { |
152 // Success. Instantiate the module and return the object. | 152 // Success. Instantiate the module and return the object. |
153 i::Handle<i::JSObject> ffi = i::Handle<i::JSObject>::null(); | 153 i::Handle<i::JSObject> ffi = i::Handle<i::JSObject>::null(); |
154 if (args.Length() > 1 && args[1]->IsObject()) { | 154 if (args.Length() > 1 && args[1]->IsObject()) { |
155 Local<Object> obj = Local<Object>::Cast(args[1]); | 155 Local<Object> obj = Local<Object>::Cast(args[1]); |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 Handle<JSArrayBuffer> WasmJs::GetWasmMemoryArrayBuffer(Isolate* isolate, | 850 Handle<JSArrayBuffer> WasmJs::GetWasmMemoryArrayBuffer(Isolate* isolate, |
851 Handle<Object> value) { | 851 Handle<Object> value) { |
852 DCHECK(IsWasmMemoryObject(isolate, value)); | 852 DCHECK(IsWasmMemoryObject(isolate, value)); |
853 Handle<Object> buf( | 853 Handle<Object> buf( |
854 JSObject::cast(*value)->GetInternalField(kWasmMemoryBufferFieldIndex), | 854 JSObject::cast(*value)->GetInternalField(kWasmMemoryBufferFieldIndex), |
855 isolate); | 855 isolate); |
856 return Handle<JSArrayBuffer>::cast(buf); | 856 return Handle<JSArrayBuffer>::cast(buf); |
857 } | 857 } |
858 } // namespace internal | 858 } // namespace internal |
859 } // namespace v8 | 859 } // namespace v8 |
OLD | NEW |