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

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

Issue 2563613003: Revert of [wasm] Fix location for error in asm.js ToNumber conversion (Closed)
Patch Set: Created 4 years 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/module-decoder.h ('k') | src/wasm/wasm-module.cc » ('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/wasm/module-decoder.h" 5 #include "src/wasm/module-decoder.h"
6 6
7 #include "src/base/functional.h" 7 #include "src/base/functional.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 Decoder decoder(tables_start, tables_end); 1197 Decoder decoder(tables_start, tables_end);
1198 uint32_t functions_count = decoder.consume_u32v("functions count"); 1198 uint32_t functions_count = decoder.consume_u32v("functions count");
1199 // Reserve space for the entries, taking care of invalid input. 1199 // Reserve space for the entries, taking care of invalid input.
1200 if (functions_count < static_cast<unsigned>(tables_end - tables_start)) { 1200 if (functions_count < static_cast<unsigned>(tables_end - tables_start)) {
1201 table.reserve(functions_count); 1201 table.reserve(functions_count);
1202 } 1202 }
1203 1203
1204 for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) { 1204 for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) {
1205 uint32_t size = decoder.consume_u32v("table size"); 1205 uint32_t size = decoder.consume_u32v("table size");
1206 if (size == 0) { 1206 if (size == 0) {
1207 table.push_back(std::vector<AsmJsOffsetEntry>()); 1207 table.push_back(std::vector<std::pair<int, int>>());
1208 continue; 1208 continue;
1209 } 1209 }
1210 if (!decoder.checkAvailable(size)) { 1210 if (!decoder.checkAvailable(size)) {
1211 decoder.error("illegal asm function offset table size"); 1211 decoder.error("illegal asm function offset table size");
1212 } 1212 }
1213 const byte* table_end = decoder.pc() + size; 1213 const byte* table_end = decoder.pc() + size;
1214 uint32_t locals_size = decoder.consume_u32("locals size"); 1214 uint32_t locals_size = decoder.consume_u32("locals size");
1215 int last_byte_offset = locals_size; 1215 int last_byte_offset = locals_size;
1216 int last_asm_position = 0; 1216 int last_asm_position = 0;
1217 std::vector<AsmJsOffsetEntry> func_asm_offsets; 1217 std::vector<std::pair<int, int>> func_asm_offsets;
1218 func_asm_offsets.reserve(size / 4); // conservative estimation 1218 func_asm_offsets.reserve(size / 4); // conservative estimation
1219 while (decoder.ok() && decoder.pc() < table_end) { 1219 while (decoder.ok() && decoder.pc() < table_end) {
1220 last_byte_offset += decoder.consume_u32v("byte offset delta"); 1220 last_byte_offset += decoder.consume_u32v("byte offset delta");
1221 int call_position = 1221 last_asm_position += decoder.consume_i32v("asm position delta");
1222 last_asm_position + decoder.consume_i32v("call position delta"); 1222 func_asm_offsets.push_back({last_byte_offset, last_asm_position});
1223 int to_number_position =
1224 call_position + decoder.consume_i32v("to_number position delta");
1225 last_asm_position = to_number_position;
1226 func_asm_offsets.push_back(
1227 {last_byte_offset, call_position, to_number_position});
1228 } 1223 }
1229 if (decoder.pc() != table_end) { 1224 if (decoder.pc() != table_end) {
1230 decoder.error("broken asm offset table"); 1225 decoder.error("broken asm offset table");
1231 } 1226 }
1232 table.push_back(std::move(func_asm_offsets)); 1227 table.push_back(std::move(func_asm_offsets));
1233 } 1228 }
1234 if (decoder.more()) decoder.error("unexpected additional bytes"); 1229 if (decoder.more()) decoder.error("unexpected additional bytes");
1235 1230
1236 return decoder.toResult(std::move(table)); 1231 return decoder.toResult(std::move(table));
1237 } 1232 }
1238 1233
1239 } // namespace wasm 1234 } // namespace wasm
1240 } // namespace internal 1235 } // namespace internal
1241 } // namespace v8 1236 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.h ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698