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/asmjs/asm-js.h" | 5 #include "src/asmjs/asm-js.h" |
6 | 6 |
7 #include "src/api-natives.h" | 7 #include "src/api-natives.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/asmjs/asm-typer.h" | 9 #include "src/asmjs/asm-typer.h" |
10 #include "src/asmjs/asm-wasm-builder.h" | 10 #include "src/asmjs/asm-wasm-builder.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 wasm::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), | 155 wasm::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), |
156 info->literal()); | 156 info->literal()); |
157 if (!typer.Validate()) { | 157 if (!typer.Validate()) { |
158 DCHECK(!info->isolate()->has_pending_exception()); | 158 DCHECK(!info->isolate()->has_pending_exception()); |
159 PrintF("Validation of asm.js module failed: %s", typer.error_message()); | 159 PrintF("Validation of asm.js module failed: %s", typer.error_message()); |
160 return MaybeHandle<FixedArray>(); | 160 return MaybeHandle<FixedArray>(); |
161 } | 161 } |
162 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(), | 162 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(), |
163 info->literal(), &typer); | 163 info->literal(), &typer); |
164 i::Handle<i::FixedArray> foreign_globals; | 164 i::Handle<i::FixedArray> foreign_globals; |
165 auto module = builder.Run(&foreign_globals); | 165 auto asm_wasm_result = builder.Run(&foreign_globals); |
| 166 wasm::ZoneBuffer* module = asm_wasm_result.module_bytes; |
| 167 wasm::ZoneBuffer* asm_offsets = asm_wasm_result.asm_offset_table; |
166 | 168 |
167 i::MaybeHandle<i::JSObject> compiled = wasm::CreateModuleObjectFromBytes( | 169 i::MaybeHandle<i::JSObject> compiled = wasm::CreateModuleObjectFromBytes( |
168 info->isolate(), module->begin(), module->end(), &thrower, | 170 info->isolate(), module->begin(), module->end(), &thrower, |
169 internal::wasm::kAsmJsOrigin); | 171 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets->begin(), |
| 172 asm_offsets->end()); |
170 DCHECK(!compiled.is_null()); | 173 DCHECK(!compiled.is_null()); |
171 | 174 |
172 wasm::AsmTyper::StdlibSet uses = typer.StdlibUses(); | 175 wasm::AsmTyper::StdlibSet uses = typer.StdlibUses(); |
173 Handle<FixedArray> uses_array = | 176 Handle<FixedArray> uses_array = |
174 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); | 177 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); |
175 int count = 0; | 178 int count = 0; |
176 for (auto i : uses) { | 179 for (auto i : uses) { |
177 uses_array->set(count++, Smi::FromInt(i)); | 180 uses_array->set(count++, Smi::FromInt(i)); |
178 } | 181 } |
179 | 182 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 i::Object::GetProperty(module_object, single_function_name); | 255 i::Object::GetProperty(module_object, single_function_name); |
253 if (!single_function.is_null() && | 256 if (!single_function.is_null() && |
254 !single_function.ToHandleChecked()->IsUndefined(isolate)) { | 257 !single_function.ToHandleChecked()->IsUndefined(isolate)) { |
255 return single_function; | 258 return single_function; |
256 } | 259 } |
257 return module_object; | 260 return module_object; |
258 } | 261 } |
259 | 262 |
260 } // namespace internal | 263 } // namespace internal |
261 } // namespace v8 | 264 } // namespace v8 |
OLD | NEW |