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

Side by Side Diff: src/wasm/module-decoder.cc

Issue 1763433002: [wasm] Rework encoding of local declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/wasm/encoder.cc ('k') | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »
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/macro-assembler.h" 5 #include "src/macro-assembler.h"
6 #include "src/objects.h" 6 #include "src/objects.h"
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/wasm/decoder.h" 9 #include "src/wasm/decoder.h"
10 #include "src/wasm/module-decoder.h" 10 #include "src/wasm/module-decoder.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 error(pc_ - 1, nullptr, "required %s section missing", name); 331 error(pc_ - 1, nullptr, "required %s section missing", name);
332 } else { 332 } else {
333 error(pc_ - 1, nullptr, "%s section already present", name); 333 error(pc_ - 1, nullptr, "%s section already present", name);
334 } 334 }
335 } 335 }
336 336
337 // Decodes a single anonymous function starting at {start_}. 337 // Decodes a single anonymous function starting at {start_}.
338 FunctionResult DecodeSingleFunction(ModuleEnv* module_env, 338 FunctionResult DecodeSingleFunction(ModuleEnv* module_env,
339 WasmFunction* function) { 339 WasmFunction* function) {
340 pc_ = start_; 340 pc_ = start_;
341 function->sig = consume_sig(); // read signature 341 function->sig = consume_sig(); // read signature
342 function->name_offset = 0; // ---- name 342 function->name_offset = 0; // ---- name
343 function->code_start_offset = off(pc_ + 8); // ---- code start 343 function->code_start_offset = off(pc_); // ---- code start
344 function->code_end_offset = off(limit_); // ---- code end 344 function->code_end_offset = off(limit_); // ---- code end
345 function->local_i32_count = consume_u16(); // read u16
346 function->local_i64_count = consume_u16(); // read u16
347 function->local_f32_count = consume_u16(); // read u16
348 function->local_f64_count = consume_u16(); // read u16
349 function->exported = false; // ---- exported 345 function->exported = false; // ---- exported
350 function->external = false; // ---- external 346 function->external = false; // ---- external
351 347
352 if (ok()) VerifyFunctionBody(0, module_env, function); 348 if (ok()) VerifyFunctionBody(0, module_env, function);
353 349
354 FunctionResult result; 350 FunctionResult result;
355 result.CopyFrom(result_); // Copy error code and location. 351 result.CopyFrom(result_); // Copy error code and location.
356 result.val = function; 352 result.val = function;
357 return result; 353 return result;
358 } 354 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 462
467 // Verifies the body (code) of a given function. 463 // Verifies the body (code) of a given function.
468 void VerifyFunctionBody(uint32_t func_num, ModuleEnv* menv, 464 void VerifyFunctionBody(uint32_t func_num, ModuleEnv* menv,
469 WasmFunction* function) { 465 WasmFunction* function) {
470 if (FLAG_trace_wasm_decode_time) { 466 if (FLAG_trace_wasm_decode_time) {
471 OFStream os(stdout); 467 OFStream os(stdout);
472 os << "Verifying WASM function " << WasmFunctionName(function, menv) 468 os << "Verifying WASM function " << WasmFunctionName(function, menv)
473 << std::endl; 469 << std::endl;
474 os << std::endl; 470 os << std::endl;
475 } 471 }
476 FunctionEnv fenv; 472 FunctionBody body = {menv, function->sig, start_,
477 fenv.module = menv; 473 start_ + function->code_start_offset,
478 fenv.sig = function->sig; 474 start_ + function->code_end_offset};
479 fenv.local_i32_count = function->local_i32_count; 475 TreeResult result = VerifyWasmCode(body);
480 fenv.local_i64_count = function->local_i64_count;
481 fenv.local_f32_count = function->local_f32_count;
482 fenv.local_f64_count = function->local_f64_count;
483 fenv.SumLocals();
484
485 TreeResult result =
486 VerifyWasmCode(&fenv, start_, start_ + function->code_start_offset,
487 start_ + function->code_end_offset);
488 if (result.failed()) { 476 if (result.failed()) {
489 // Wrap the error message from the function decoder. 477 // Wrap the error message from the function decoder.
490 std::ostringstream str; 478 std::ostringstream str;
491 str << "in function " << WasmFunctionName(function, menv) << ": "; 479 str << "in function " << WasmFunctionName(function, menv) << ": ";
492 str << result; 480 str << result;
493 std::string strval = str.str(); 481 std::string strval = str.str();
494 const char* raw = strval.c_str(); 482 const char* raw = strval.c_str();
495 size_t len = strlen(raw); 483 size_t len = strlen(raw);
496 char* buffer = new char[len]; 484 char* buffer = new char[len];
497 strncpy(buffer, raw, len); 485 strncpy(buffer, raw, len);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 if (function_start > function_end) return FunctionError("start > end"); 631 if (function_start > function_end) return FunctionError("start > end");
644 if (size > kMaxFunctionSize) 632 if (size > kMaxFunctionSize)
645 return FunctionError("size > maximum function size"); 633 return FunctionError("size > maximum function size");
646 WasmFunction* function = new WasmFunction(); 634 WasmFunction* function = new WasmFunction();
647 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); 635 ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin);
648 return decoder.DecodeSingleFunction(module_env, function); 636 return decoder.DecodeSingleFunction(module_env, function);
649 } 637 }
650 } // namespace wasm 638 } // namespace wasm
651 } // namespace internal 639 } // namespace internal
652 } // namespace v8 640 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/encoder.cc ('k') | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698