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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 Vector<const byte> asm_offsets_vec(asm_offsets->begin(), | 184 Vector<const byte> asm_offsets_vec(asm_offsets->begin(), |
185 static_cast<int>(asm_offsets->size())); | 185 static_cast<int>(asm_offsets->size())); |
186 | 186 |
187 base::ElapsedTimer compile_timer; | 187 base::ElapsedTimer compile_timer; |
188 compile_timer.Start(); | 188 compile_timer.Start(); |
189 MaybeHandle<JSObject> compiled = wasm::CreateModuleObjectFromBytes( | 189 MaybeHandle<JSObject> compiled = wasm::CreateModuleObjectFromBytes( |
190 info->isolate(), module->begin(), module->end(), &thrower, | 190 info->isolate(), module->begin(), module->end(), &thrower, |
191 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets_vec); | 191 internal::wasm::kAsmJsOrigin, info->script(), asm_offsets_vec); |
192 DCHECK(!compiled.is_null()); | 192 DCHECK(!compiled.is_null()); |
193 double compile_time = compile_timer.Elapsed().InMillisecondsF(); | 193 double compile_time = compile_timer.Elapsed().InMillisecondsF(); |
194 uintptr_t wasm_size = module->end() - module->begin(); | |
Mircea Trofin
2017/01/26 07:19:31
DCHECK end >= begin
bradn
2017/01/26 07:46:12
Done.
| |
194 | 195 |
195 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses(); | 196 wasm::AsmTyper::StdlibSet uses = builder.typer()->StdlibUses(); |
196 Handle<FixedArray> uses_array = | 197 Handle<FixedArray> uses_array = |
197 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); | 198 info->isolate()->factory()->NewFixedArray(static_cast<int>(uses.size())); |
198 int count = 0; | 199 int count = 0; |
199 for (auto i : uses) { | 200 for (auto i : uses) { |
200 uses_array->set(count++, Smi::FromInt(i)); | 201 uses_array->set(count++, Smi::FromInt(i)); |
201 } | 202 } |
202 | 203 |
203 Handle<FixedArray> result = | 204 Handle<FixedArray> result = |
204 info->isolate()->factory()->NewFixedArray(kWasmDataEntryCount); | 205 info->isolate()->factory()->NewFixedArray(kWasmDataEntryCount); |
205 result->set(kWasmDataCompiledModule, *compiled.ToHandleChecked()); | 206 result->set(kWasmDataCompiledModule, *compiled.ToHandleChecked()); |
206 result->set(kWasmDataForeignGlobals, *foreign_globals); | 207 result->set(kWasmDataForeignGlobals, *foreign_globals); |
207 result->set(kWasmDataUsesArray, *uses_array); | 208 result->set(kWasmDataUsesArray, *uses_array); |
208 result->set(kWasmDataScript, *info->script()); | 209 result->set(kWasmDataScript, *info->script()); |
209 result->set(kWasmDataScriptPosition, | 210 result->set(kWasmDataScriptPosition, |
210 Smi::FromInt(info->literal()->position())); | 211 Smi::FromInt(info->literal()->position())); |
211 | 212 |
212 MessageLocation location(info->script(), info->literal()->position(), | 213 MessageLocation location(info->script(), info->literal()->position(), |
213 info->literal()->position()); | 214 info->literal()->position()); |
214 char text[100]; | 215 char text[100]; |
215 int length; | 216 int length; |
216 if (FLAG_predictable) { | 217 if (FLAG_predictable) { |
217 length = base::OS::SNPrintF(text, arraysize(text), "success"); | 218 length = base::OS::SNPrintF(text, arraysize(text), "success"); |
218 } else { | 219 } else { |
219 length = | 220 length = base::OS::SNPrintF( |
220 base::OS::SNPrintF(text, arraysize(text), | 221 text, arraysize(text), |
221 "success, asm->wasm: %0.3f ms, compile: %0.3f ms", | 222 "success, asm->wasm: %0.3f ms, compile: %0.3f ms, %" PRIuPTR " bytes", |
222 asm_wasm_time, compile_time); | 223 asm_wasm_time, compile_time, wasm_size); |
223 } | 224 } |
224 DCHECK_NE(-1, length); | 225 DCHECK_NE(-1, length); |
225 USE(length); | 226 USE(length); |
226 Handle<String> stext(info->isolate()->factory()->InternalizeUtf8String(text)); | 227 Handle<String> stext(info->isolate()->factory()->InternalizeUtf8String(text)); |
227 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( | 228 Handle<JSMessageObject> message = MessageHandler::MakeMessageObject( |
228 info->isolate(), MessageTemplate::kAsmJsCompiled, &location, stext, | 229 info->isolate(), MessageTemplate::kAsmJsCompiled, &location, stext, |
229 Handle<JSArray>::null()); | 230 Handle<JSArray>::null()); |
230 message->set_error_level(v8::Isolate::kMessageInfo); | 231 message->set_error_level(v8::Isolate::kMessageInfo); |
231 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { | 232 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { |
232 MessageHandler::ReportMessage(info->isolate(), &location, message); | 233 MessageHandler::ReportMessage(info->isolate(), &location, message); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 message->set_error_level(v8::Isolate::kMessageInfo); | 344 message->set_error_level(v8::Isolate::kMessageInfo); |
344 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { | 345 if (!FLAG_suppress_asm_messages && FLAG_trace_asm_time) { |
345 MessageHandler::ReportMessage(isolate, &location, message); | 346 MessageHandler::ReportMessage(isolate, &location, message); |
346 } | 347 } |
347 | 348 |
348 return module_object; | 349 return module_object; |
349 } | 350 } |
350 | 351 |
351 } // namespace internal | 352 } // namespace internal |
352 } // namespace v8 | 353 } // namespace v8 |
OLD | NEW |