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

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

Issue 1692173002: [wasm] Add support for a start function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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-module.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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 static_cast<int>(pc_ - start_)); 173 static_cast<int>(pc_ - start_));
174 uint16_t index = consume_u16(); 174 uint16_t index = consume_u16();
175 if (index >= module->functions->size()) { 175 if (index >= module->functions->size()) {
176 error(pc_ - 2, "invalid function index"); 176 error(pc_ - 2, "invalid function index");
177 break; 177 break;
178 } 178 }
179 module->function_table->push_back(index); 179 module->function_table->push_back(index);
180 } 180 }
181 break; 181 break;
182 } 182 }
183 case kDeclStartFunction: {
184 // Declares a start function for a module.
185 CheckForPreviousSection(sections, kDeclFunctions, true);
186 if (module->start_function_index >= 0) {
187 error("start function already declared");
188 break;
189 }
190 int length;
191 const byte* before = pc_;
192 uint32_t index = consume_u32v(&length, "start function index");
193 if (index >= module->functions->size()) {
194 error(before, "invalid start function index");
195 break;
196 }
197 module->start_function_index = static_cast<int>(index);
198 FunctionSig* sig =
199 module->signatures->at(module->functions->at(index).sig_index);
200 if (sig->parameter_count() > 0) {
201 error(before, "invalid start function: non-zero parameter count");
202 break;
203 }
204 break;
205 }
183 case kDeclWLL: { 206 case kDeclWLL: {
184 // Reserved for experimentation by the Web Low-level Language project 207 // Reserved for experimentation by the Web Low-level Language project
185 // which is augmenting the binary encoding with source code meta 208 // which is augmenting the binary encoding with source code meta
186 // information. This section does not affect the semantics of the code 209 // information. This section does not affect the semantics of the code
187 // and can be ignored by the runtime. https://github.com/JSStats/wll 210 // and can be ignored by the runtime. https://github.com/JSStats/wll
188 int length = 0; 211 int length = 0;
189 uint32_t section_size = consume_u32v(&length, "section size"); 212 uint32_t section_size = consume_u32v(&length, "section size");
190 if (pc_ + section_size > limit_ || pc_ + section_size < pc_) { 213 if (pc_ + section_size > limit_ || pc_ + section_size < pc_) {
191 error(pc_ - length, "invalid section size"); 214 error(pc_ - length, "invalid section size");
192 break; 215 break;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 if (function_start > function_end) return FunctionError("start > end"); 580 if (function_start > function_end) return FunctionError("start > end");
558 if (size > kMaxFunctionSize) 581 if (size > kMaxFunctionSize)
559 return FunctionError("size > maximum function size"); 582 return FunctionError("size > maximum function size");
560 WasmFunction* function = new WasmFunction(); 583 WasmFunction* function = new WasmFunction();
561 ModuleDecoder decoder(zone, function_start, function_end, false); 584 ModuleDecoder decoder(zone, function_start, function_end, false);
562 return decoder.DecodeSingleFunction(module_env, function); 585 return decoder.DecodeSingleFunction(module_env, function);
563 } 586 }
564 } // namespace wasm 587 } // namespace wasm
565 } // namespace internal 588 } // namespace internal
566 } // namespace v8 589 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698