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

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

Issue 2646873004: Enable emplace_back for zone containers (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/wasm/wasm-interpreter.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 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 // Reserve space for the entries, taking care of invalid input. 1194 // Reserve space for the entries, taking care of invalid input.
1195 if (functions_count < static_cast<unsigned>(code_section.length()) / 2) { 1195 if (functions_count < static_cast<unsigned>(code_section.length()) / 2) {
1196 table.reserve(functions_count); 1196 table.reserve(functions_count);
1197 } 1197 }
1198 1198
1199 int section_offset = static_cast<int>(code_section.start() - module_start); 1199 int section_offset = static_cast<int>(code_section.start() - module_start);
1200 DCHECK_LE(0, section_offset); 1200 DCHECK_LE(0, section_offset);
1201 for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) { 1201 for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) {
1202 uint32_t size = decoder.consume_u32v("body size"); 1202 uint32_t size = decoder.consume_u32v("body size");
1203 int offset = static_cast<int>(section_offset + decoder.pc_offset()); 1203 int offset = static_cast<int>(section_offset + decoder.pc_offset());
1204 table.push_back(std::make_pair(offset, static_cast<int>(size))); 1204 table.emplace_back(offset, static_cast<int>(size));
1205 DCHECK(table.back().first >= 0 && table.back().second >= 0); 1205 DCHECK(table.back().first >= 0 && table.back().second >= 0);
1206 decoder.consume_bytes(size); 1206 decoder.consume_bytes(size);
1207 } 1207 }
1208 if (decoder.more()) decoder.error("unexpected additional bytes"); 1208 if (decoder.more()) decoder.error("unexpected additional bytes");
1209 1209
1210 return decoder.toResult(std::move(table)); 1210 return decoder.toResult(std::move(table));
1211 } 1211 }
1212 1212
1213 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* tables_start, 1213 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* tables_start,
1214 const byte* tables_end) { 1214 const byte* tables_end) {
1215 AsmJsOffsets table; 1215 AsmJsOffsets table;
1216 1216
1217 Decoder decoder(tables_start, tables_end); 1217 Decoder decoder(tables_start, tables_end);
1218 uint32_t functions_count = decoder.consume_u32v("functions count"); 1218 uint32_t functions_count = decoder.consume_u32v("functions count");
1219 // Reserve space for the entries, taking care of invalid input. 1219 // Reserve space for the entries, taking care of invalid input.
1220 if (functions_count < static_cast<unsigned>(tables_end - tables_start)) { 1220 if (functions_count < static_cast<unsigned>(tables_end - tables_start)) {
1221 table.reserve(functions_count); 1221 table.reserve(functions_count);
1222 } 1222 }
1223 1223
1224 for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) { 1224 for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) {
1225 uint32_t size = decoder.consume_u32v("table size"); 1225 uint32_t size = decoder.consume_u32v("table size");
1226 if (size == 0) { 1226 if (size == 0) {
1227 table.push_back(std::vector<AsmJsOffsetEntry>()); 1227 table.emplace_back();
1228 continue; 1228 continue;
1229 } 1229 }
1230 if (!decoder.checkAvailable(size)) { 1230 if (!decoder.checkAvailable(size)) {
1231 decoder.error("illegal asm function offset table size"); 1231 decoder.error("illegal asm function offset table size");
1232 } 1232 }
1233 const byte* table_end = decoder.pc() + size; 1233 const byte* table_end = decoder.pc() + size;
1234 uint32_t locals_size = decoder.consume_u32v("locals size"); 1234 uint32_t locals_size = decoder.consume_u32v("locals size");
1235 int function_start_position = decoder.consume_u32v("function start pos"); 1235 int function_start_position = decoder.consume_u32v("function start pos");
1236 int last_byte_offset = locals_size; 1236 int last_byte_offset = locals_size;
1237 int last_asm_position = function_start_position; 1237 int last_asm_position = function_start_position;
(...skipping 18 matching lines...) Expand all
1256 table.push_back(std::move(func_asm_offsets)); 1256 table.push_back(std::move(func_asm_offsets));
1257 } 1257 }
1258 if (decoder.more()) decoder.error("unexpected additional bytes"); 1258 if (decoder.more()) decoder.error("unexpected additional bytes");
1259 1259
1260 return decoder.toResult(std::move(table)); 1260 return decoder.toResult(std::move(table));
1261 } 1261 }
1262 1262
1263 } // namespace wasm 1263 } // namespace wasm
1264 } // namespace internal 1264 } // namespace internal
1265 } // namespace v8 1265 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698