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.h" | 5 #include "src/api.h" |
6 #include "src/api-natives.h" | 6 #include "src/api-natives.h" |
7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 info->set_allow_lazy_parsing(false); | 132 info->set_allow_lazy_parsing(false); |
133 info->set_toplevel(true); | 133 info->set_toplevel(true); |
134 | 134 |
135 CHECK(i::Compiler::ParseAndAnalyze(info)); | 135 CHECK(i::Compiler::ParseAndAnalyze(info)); |
136 info->set_literal( | 136 info->set_literal( |
137 info->scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); | 137 info->scope()->declarations()->at(0)->AsFunctionDeclaration()->fun()); |
138 | 138 |
139 v8::internal::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), | 139 v8::internal::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), |
140 info->literal()); | 140 info->literal()); |
141 if (!typer.Validate()) { | 141 if (!typer.Validate()) { |
142 return NULL; | 142 return nullptr; |
143 } | 143 } |
144 | 144 |
145 auto module = v8::internal::wasm::AsmWasmBuilder( | 145 auto module = v8::internal::wasm::AsmWasmBuilder( |
146 info->isolate(), info->zone(), info->literal()) | 146 info->isolate(), info->zone(), info->literal()) |
147 .Run(); | 147 .Run(); |
148 return module; | 148 return module; |
149 } | 149 } |
150 | 150 |
151 | 151 |
152 void AsmCompileRun(const v8::FunctionCallbackInfo<v8::Value>& args) { | 152 void AsmCompileRun(const v8::FunctionCallbackInfo<v8::Value>& args) { |
(...skipping 10 matching lines...) Expand all Loading... |
163 return; | 163 return; |
164 } | 164 } |
165 | 165 |
166 i::Factory* factory = isolate->factory(); | 166 i::Factory* factory = isolate->factory(); |
167 i::Zone zone; | 167 i::Zone zone; |
168 Local<String> source = Local<String>::Cast(args[0]); | 168 Local<String> source = Local<String>::Cast(args[0]); |
169 i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source)); | 169 i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source)); |
170 i::ParseInfo info(&zone, script); | 170 i::ParseInfo info(&zone, script); |
171 | 171 |
172 auto module = TranslateAsmModule(&info); | 172 auto module = TranslateAsmModule(&info); |
173 if (module == NULL) { | 173 if (module == nullptr) { |
174 thrower.Error("Asm.js validation failed"); | 174 thrower.Error("Asm.js validation failed"); |
175 return; | 175 return; |
176 } | 176 } |
177 | 177 |
178 int32_t result = v8::internal::wasm::CompileAndRunWasmModule( | 178 int32_t result = v8::internal::wasm::CompileAndRunWasmModule( |
179 isolate, module->Begin(), module->End(), true); | 179 isolate, module->Begin(), module->End(), true); |
180 args.GetReturnValue().Set(result); | 180 args.GetReturnValue().Set(result); |
181 } | 181 } |
182 | 182 |
183 | 183 |
(...skipping 12 matching lines...) Expand all Loading... |
196 return; | 196 return; |
197 } | 197 } |
198 | 198 |
199 i::Factory* factory = isolate->factory(); | 199 i::Factory* factory = isolate->factory(); |
200 i::Zone zone; | 200 i::Zone zone; |
201 Local<String> source = Local<String>::Cast(args[0]); | 201 Local<String> source = Local<String>::Cast(args[0]); |
202 i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source)); | 202 i::Handle<i::Script> script = factory->NewScript(Utils::OpenHandle(*source)); |
203 i::ParseInfo info(&zone, script); | 203 i::ParseInfo info(&zone, script); |
204 | 204 |
205 auto module = TranslateAsmModule(&info); | 205 auto module = TranslateAsmModule(&info); |
206 if (module == NULL) { | 206 if (module == nullptr) { |
207 thrower.Error("Asm.js validation failed"); | 207 thrower.Error("Asm.js validation failed"); |
208 return; | 208 return; |
209 } | 209 } |
210 | 210 |
211 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); | 211 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); |
212 internal::wasm::ModuleResult result = internal::wasm::DecodeWasmModule( | 212 internal::wasm::ModuleResult result = internal::wasm::DecodeWasmModule( |
213 isolate, &zone, module->Begin(), module->End(), false, false); | 213 isolate, &zone, module->Begin(), module->End(), false, false); |
214 | 214 |
215 if (result.failed()) { | 215 if (result.failed()) { |
216 thrower.Failed("", result); | 216 thrower.Failed("", result); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule); | 325 InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule); |
326 InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule); | 326 InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule); |
327 InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction); | 327 InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction); |
328 InstallFunc(isolate, wasm_object, "compileRun", CompileRun); | 328 InstallFunc(isolate, wasm_object, "compileRun", CompileRun); |
329 InstallFunc(isolate, wasm_object, "asmCompileRun", AsmCompileRun); | 329 InstallFunc(isolate, wasm_object, "asmCompileRun", AsmCompileRun); |
330 InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm", | 330 InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm", |
331 InstantiateModuleFromAsm); | 331 InstantiateModuleFromAsm); |
332 } | 332 } |
333 } // namespace internal | 333 } // namespace internal |
334 } // namespace v8 | 334 } // namespace v8 |
OLD | NEW |