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

Unified Diff: src/wasm/wasm-module-builder.cc

Issue 2609363004: [asm.js] [wasm] Store function start position for stack check (Closed)
Patch Set: It's 2017 already :) Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-module-builder.h ('k') | test/mjsunit/regress/regress-677685.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module-builder.cc
diff --git a/src/wasm/wasm-module-builder.cc b/src/wasm/wasm-module-builder.cc
index f5228439ce5b581ef943ae290c67c3b549a42883..33a346441702d5e91e7700a8d6309fe1ac7c6c98 100644
--- a/src/wasm/wasm-module-builder.cc
+++ b/src/wasm/wasm-module-builder.cc
@@ -152,7 +152,7 @@ void WasmFunctionBuilder::SetName(Vector<const char> name) {
void WasmFunctionBuilder::AddAsmWasmOffset(int call_position,
int to_number_position) {
- // We only want to emit one mapping per byte offset:
+ // We only want to emit one mapping per byte offset.
DCHECK(asm_offsets_.size() == 0 || body_.size() > last_asm_byte_offset_);
DCHECK_LE(body_.size(), kMaxUInt32);
@@ -168,6 +168,15 @@ void WasmFunctionBuilder::AddAsmWasmOffset(int call_position,
last_asm_source_position_ = to_number_position;
}
+void WasmFunctionBuilder::SetAsmFunctionStartPosition(int position) {
+ DCHECK_EQ(0, asm_func_start_source_position_);
+ DCHECK_LE(0, position);
+ // Must be called before emitting any asm.js source position.
+ DCHECK_EQ(0, asm_offsets_.size());
+ asm_func_start_source_position_ = position;
+ last_asm_source_position_ = position;
+}
+
void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const {
buffer.write_u32v(signature_index_);
}
@@ -201,14 +210,19 @@ void WasmFunctionBuilder::WriteBody(ZoneBuffer& buffer) const {
}
void WasmFunctionBuilder::WriteAsmWasmOffsetTable(ZoneBuffer& buffer) const {
- if (asm_offsets_.size() == 0) {
+ if (asm_func_start_source_position_ == 0 && asm_offsets_.size() == 0) {
buffer.write_size(0);
return;
}
- buffer.write_size(asm_offsets_.size() + kInt32Size);
+ size_t locals_enc_size = LEBHelper::sizeof_u32v(locals_.Size());
+ size_t func_start_size =
+ LEBHelper::sizeof_u32v(asm_func_start_source_position_);
+ buffer.write_size(asm_offsets_.size() + locals_enc_size + func_start_size);
// Offset of the recorded byte offsets.
DCHECK_GE(kMaxUInt32, locals_.Size());
- buffer.write_u32(static_cast<uint32_t>(locals_.Size()));
+ buffer.write_u32v(static_cast<uint32_t>(locals_.Size()));
+ // Start position of the function.
+ buffer.write_u32v(asm_func_start_source_position_);
buffer.write(asm_offsets_.begin(), asm_offsets_.size());
}
« no previous file with comments | « src/wasm/wasm-module-builder.h ('k') | test/mjsunit/regress/regress-677685.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698