Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: src/asmjs/asm-js.cc

Issue 2398023002: [wasm] asm.js - Parse and convert asm.js to wasm a function at a time. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/asmjs/asm-typer.h » ('j') | src/asmjs/asm-typer.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #undef STDLIB_MATH_CONST 145 #undef STDLIB_MATH_CONST
146 default: { UNREACHABLE(); } 146 default: { UNREACHABLE(); }
147 } 147 }
148 return false; 148 return false;
149 } 149 }
150 150
151 } // namespace 151 } // namespace
152 152
153 MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) { 153 MaybeHandle<FixedArray> AsmJs::ConvertAsmToWasm(ParseInfo* info) {
154 ErrorThrower thrower(info->isolate(), "Asm.js -> WebAssembly conversion"); 154 ErrorThrower thrower(info->isolate(), "Asm.js -> WebAssembly conversion");
155 wasm::AsmTyper typer(info->isolate(), info->zone(), *(info->script()), 155 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(),
156 info->literal()); 156 *info->script(), info->literal());
157 if (!typer.Validate()) { 157 i::Handle<i::FixedArray> foreign_globals;
158 auto module = builder.Run(&foreign_globals);
159 if (module == nullptr) {
158 DCHECK(!info->isolate()->has_pending_exception()); 160 DCHECK(!info->isolate()->has_pending_exception());
159 PrintF("Validation of asm.js module failed: %s", typer.error_message()); 161 PrintF("Validation of asm.js module failed: %s",
162 builder.typer()->error_message());
160 return MaybeHandle<FixedArray>(); 163 return MaybeHandle<FixedArray>();
161 } 164 }
162 v8::internal::wasm::AsmWasmBuilder builder(info->isolate(), info->zone(),
163 info->literal(), &typer);
164 i::Handle<i::FixedArray> foreign_globals;
165 auto module = builder.Run(&foreign_globals);
166 165
167 i::MaybeHandle<i::JSObject> compiled = wasm::CreateModuleObjectFromBytes( 166 i::MaybeHandle<i::JSObject> compiled = wasm::CreateModuleObjectFromBytes(
168 info->isolate(), module->begin(), module->end(), &thrower, 167 info->isolate(), module->begin(), module->end(), &thrower,
169 internal::wasm::kAsmJsOrigin); 168 internal::wasm::kAsmJsOrigin);
170 DCHECK(!compiled.is_null()); 169 DCHECK(!compiled.is_null());
171 170
172 wasm::AsmTyper::StdlibSet uses = typer.StdlibUses(); 171 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses();
173 Handle<FixedArray> uses_array = 172 Handle<FixedArray> uses_array =
174 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); 173 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size()));
175 int count = 0; 174 int count = 0;
176 for (auto i : uses) { 175 for (auto i : uses) {
177 uses_array->set(count++, Smi::FromInt(i)); 176 uses_array->set(count++, Smi::FromInt(i));
178 } 177 }
179 178
180 Handle<FixedArray> result = info->isolate()->factory()->NewFixedArray(3); 179 Handle<FixedArray> result = info->isolate()->factory()->NewFixedArray(3);
181 result->set(0, *compiled.ToHandleChecked()); 180 result->set(0, *compiled.ToHandleChecked());
182 result->set(1, *foreign_globals); 181 result->set(1, *foreign_globals);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 i::Object::GetProperty(module_object, single_function_name); 251 i::Object::GetProperty(module_object, single_function_name);
253 if (!single_function.is_null() && 252 if (!single_function.is_null() &&
254 !single_function.ToHandleChecked()->IsUndefined(isolate)) { 253 !single_function.ToHandleChecked()->IsUndefined(isolate)) {
255 return single_function; 254 return single_function;
256 } 255 }
257 return module_object; 256 return module_object;
258 } 257 }
259 258
260 } // namespace internal 259 } // namespace internal
261 } // namespace v8 260 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/asmjs/asm-typer.h » ('j') | src/asmjs/asm-typer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698