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/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/execution.h" | 10 #include "src/execution.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 buffer.start, buffer.end); | 114 buffer.start, buffer.end); |
115 } | 115 } |
116 | 116 |
117 if (result.failed()) { | 117 if (result.failed()) { |
118 thrower.Failed("", result); | 118 thrower.Failed("", result); |
119 } | 119 } |
120 | 120 |
121 if (result.val) delete result.val; | 121 if (result.val) delete result.val; |
122 } | 122 } |
123 | 123 |
124 v8::internal::wasm::WasmModuleIndex* TranslateAsmModule( | 124 v8::internal::wasm::ZoneBuffer* TranslateAsmModule( |
125 i::ParseInfo* info, ErrorThrower* thrower, | 125 i::ParseInfo* info, ErrorThrower* thrower, |
126 i::Handle<i::FixedArray>* foreign_args) { | 126 i::Handle<i::FixedArray>* foreign_args) { |
127 info->set_global(); | 127 info->set_global(); |
128 info->set_lazy(false); | 128 info->set_lazy(false); |
129 info->set_allow_lazy_parsing(false); | 129 info->set_allow_lazy_parsing(false); |
130 info->set_toplevel(true); | 130 info->set_toplevel(true); |
131 | 131 |
132 if (!i::Compiler::ParseAndAnalyze(info)) { | 132 if (!i::Compiler::ParseAndAnalyze(info)) { |
133 return nullptr; | 133 return nullptr; |
134 } | 134 } |
(...skipping 12 matching lines...) Expand all Loading... |
147 typer.set_allow_simd(true); | 147 typer.set_allow_simd(true); |
148 } | 148 } |
149 if (!typer.Validate()) { | 149 if (!typer.Validate()) { |
150 thrower->Error("Asm.js validation failed: %s", typer.error_message()); | 150 thrower->Error("Asm.js validation failed: %s", typer.error_message()); |
151 return nullptr; | 151 return nullptr; |
152 } | 152 } |
153 | 153 |
154 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(), | 154 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(), |
155 info->literal(), &typer); | 155 info->literal(), &typer); |
156 | 156 |
157 auto module = builder.Run(foreign_args); | 157 return builder.Run(foreign_args); |
158 | |
159 return module; | |
160 } | 158 } |
161 | 159 |
162 i::MaybeHandle<i::JSObject> InstantiateModuleCommon( | 160 i::MaybeHandle<i::JSObject> InstantiateModuleCommon( |
163 const v8::FunctionCallbackInfo<v8::Value>& args, const byte* start, | 161 const v8::FunctionCallbackInfo<v8::Value>& args, const byte* start, |
164 const byte* end, ErrorThrower* thrower, | 162 const byte* end, ErrorThrower* thrower, |
165 internal::wasm::ModuleOrigin origin) { | 163 internal::wasm::ModuleOrigin origin) { |
166 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); | 164 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate()); |
167 | 165 |
168 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); | 166 i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null(); |
169 if (args.Length() > 2 && args[2]->IsArrayBuffer()) { | 167 if (args.Length() > 2 && args[2]->IsArrayBuffer()) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 foreign = v8::Utils::OpenHandle(*local_foreign); | 222 foreign = v8::Utils::OpenHandle(*local_foreign); |
225 } | 223 } |
226 | 224 |
227 i::Handle<i::FixedArray> foreign_args; | 225 i::Handle<i::FixedArray> foreign_args; |
228 auto module = TranslateAsmModule(&info, &thrower, &foreign_args); | 226 auto module = TranslateAsmModule(&info, &thrower, &foreign_args); |
229 if (module == nullptr) { | 227 if (module == nullptr) { |
230 return; | 228 return; |
231 } | 229 } |
232 | 230 |
233 i::MaybeHandle<i::Object> maybe_module_object = | 231 i::MaybeHandle<i::Object> maybe_module_object = |
234 InstantiateModuleCommon(args, module->Begin(), module->End(), &thrower, | 232 InstantiateModuleCommon(args, module->begin(), module->end(), &thrower, |
235 internal::wasm::kAsmJsOrigin); | 233 internal::wasm::kAsmJsOrigin); |
236 if (maybe_module_object.is_null()) { | 234 if (maybe_module_object.is_null()) { |
237 return; | 235 return; |
238 } | 236 } |
239 | 237 |
240 i::Handle<i::Name> name = | 238 i::Handle<i::Name> name = |
241 factory->NewStringFromStaticChars("__foreign_init__"); | 239 factory->NewStringFromStaticChars("__foreign_init__"); |
242 | 240 |
243 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); | 241 i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked(); |
244 i::MaybeHandle<i::Object> maybe_init = | 242 i::MaybeHandle<i::Object> maybe_init = |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 int unused_property_fields = in_object_properties - pre_allocated; | 363 int unused_property_fields = in_object_properties - pre_allocated; |
366 Handle<Map> map = Map::CopyInitialMap( | 364 Handle<Map> map = Map::CopyInitialMap( |
367 prev_map, instance_size, in_object_properties, unused_property_fields); | 365 prev_map, instance_size, in_object_properties, unused_property_fields); |
368 | 366 |
369 context->set_wasm_function_map(*map); | 367 context->set_wasm_function_map(*map); |
370 } | 368 } |
371 } | 369 } |
372 | 370 |
373 } // namespace internal | 371 } // namespace internal |
374 } // namespace v8 | 372 } // namespace v8 |
OLD | NEW |