Chromium Code Reviews| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 #undef STDLIB_MATH_CONST | 146 #undef STDLIB_MATH_CONST |
| 147 default: { UNREACHABLE(); } | 147 default: { UNREACHABLE(); } |
| 148 } | 148 } |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) { | 154 MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) { |
| 155 ErrorThrower thrower(info->isolate(), "Asm.js -> WebAssembly conversion"); | 155 ErrorThrower thrower(info->isolate(), "Asm.js -> WebAssembly conversion"); |
| 156 wasm::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), | 156 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(), |
|
titzer
2016/11/29 14:57:37
Can you drop the v8::internal:: qualifiers?
bradn
2016/11/29 22:09:06
Done.
| |
| 157 info->literal()); | 157 info->ast_value_factory(), |
| 158 if (!typer.Validate()) { | 158 *info->script(), info->literal()); |
| 159 i::Handle<i::FixedArray> foreign_globals; | |
|
titzer
2016/11/29 14:57:37
I think you can drop the i::FixedArray qualificati
bradn
2016/11/29 22:09:06
Done.
| |
| 160 auto asm_wasm_result = builder.Run(&foreign_globals); | |
| 161 if (!asm_wasm_result.success) { | |
| 159 DCHECK(!info->isolate()->has_pending_exception()); | 162 DCHECK(!info->isolate()->has_pending_exception()); |
| 160 PrintF("Validation of asm.js module failed: %s\n", typer.error_message()); | 163 PrintF("Validation of asm.js module failed: %s\n", |
| 164 builder.typer()->error_message()); | |
| 161 return MaybeHandle<FixedArray>(); | 165 return MaybeHandle<FixedArray>(); |
| 162 } | 166 } |
| 163 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(), | |
| 164 info->literal(), &typer); | |
| 165 i::Handle<i::FixedArray> foreign_globals; | |
| 166 auto asm_wasm_result = builder.Run(&foreign_globals); | |
| 167 wasm::ZoneBuffer* module = asm_wasm_result.module_bytes; | 167 wasm::ZoneBuffer* module = asm_wasm_result.module_bytes; |
| 168 wasm::ZoneBuffer* asm_offsets = asm_wasm_result.asm_offset_table; | 168 wasm::ZoneBuffer* asm_offsets = asm_wasm_result.asm_offset_table; |
| 169 | 169 |
| 170 i::MaybeHandle<i::JSObject> compiled = wasm::CreateModuleObjectFromBytes( | 170 i::MaybeHandle<i::JSObject> compiled = wasm::CreateModuleObjectFromBytes( |
| 171 info->isolate(), module->begin(), module->end(), &thrower, | 171 info->isolate(), module->begin(), module->end(), &thrower, |
| 172 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets->begin(), | 172 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets->begin(), |
| 173 asm_offsets->end()); | 173 asm_offsets->end()); |
| 174 DCHECK(!compiled.is_null()); | 174 DCHECK(!compiled.is_null()); |
| 175 | 175 |
| 176 wasm::AsmTyper::StdlibSet uses = typer.StdlibUses(); | 176 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses(); |
| 177 Handle<FixedArray> uses_array = | 177 Handle<FixedArray> uses_array = |
| 178 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); | 178 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); |
| 179 int count = 0; | 179 int count = 0; |
| 180 for (auto i : uses) { | 180 for (auto i : uses) { |
| 181 uses_array->set(count++, Smi::FromInt(i)); | 181 uses_array->set(count++, Smi::FromInt(i)); |
| 182 } | 182 } |
| 183 | 183 |
| 184 Handle<FixedArray> result = info->isolate()->factory()->NewFixedArray(3); | 184 Handle<FixedArray> result = info->isolate()->factory()->NewFixedArray(3); |
| 185 result->set(0, *compiled.ToHandleChecked()); | 185 result->set(0, *compiled.ToHandleChecked()); |
| 186 result->set(1, *foreign_globals); | 186 result->set(1, *foreign_globals); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 i::Object::GetProperty(module_object, single_function_name); | 256 i::Object::GetProperty(module_object, single_function_name); |
| 257 if (!single_function.is_null() && | 257 if (!single_function.is_null() && |
| 258 !single_function.ToHandleChecked()->IsUndefined(isolate)) { | 258 !single_function.ToHandleChecked()->IsUndefined(isolate)) { |
| 259 return single_function; | 259 return single_function; |
| 260 } | 260 } |
| 261 return module_object; | 261 return module_object; |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace internal | 264 } // namespace internal |
| 265 } // namespace v8 | 265 } // namespace v8 |
| OLD | NEW |