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

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 2256603002: [wasm] Add stack checks at the beginning of each function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/compiler/wasm-compiler.h ('k') | src/messages.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/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 367 }
368 368
369 Node* WasmGraphBuilder::Int32Constant(int32_t value) { 369 Node* WasmGraphBuilder::Int32Constant(int32_t value) {
370 return jsgraph()->Int32Constant(value); 370 return jsgraph()->Int32Constant(value);
371 } 371 }
372 372
373 Node* WasmGraphBuilder::Int64Constant(int64_t value) { 373 Node* WasmGraphBuilder::Int64Constant(int64_t value) {
374 return jsgraph()->Int64Constant(value); 374 return jsgraph()->Int64Constant(value);
375 } 375 }
376 376
377 void WasmGraphBuilder::InitStackCheck(wasm::WasmCodePosition position) {
378 Node* limit = graph()->NewNode(
379 jsgraph()->machine()->Load(MachineType::Pointer()),
380 jsgraph()->ExternalConstant(
381 ExternalReference::address_of_stack_limit(jsgraph()->isolate())),
382 jsgraph()->IntPtrConstant(0), *effect_, *control_);
383 Node* pointer = graph()->NewNode(jsgraph()->machine()->LoadStackPointer());
384
385 Node* check =
386 graph()->NewNode(jsgraph()->machine()->UintLessThan(), limit, pointer);
387 trap_->AddTrapIfFalse(wasm::kTrapStackOverflow, check, position);
titzer 2016/08/17 08:23:28 We'll need to use the regular JS machinery here an
ahaas 2016/08/17 09:18:43 Done.
388 }
389
377 Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right, 390 Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
378 wasm::WasmCodePosition position) { 391 wasm::WasmCodePosition position) {
379 const Operator* op; 392 const Operator* op;
380 MachineOperatorBuilder* m = jsgraph()->machine(); 393 MachineOperatorBuilder* m = jsgraph()->machine();
381 switch (opcode) { 394 switch (opcode) {
382 case wasm::kExprI32Add: 395 case wasm::kExprI32Add:
383 op = m->Int32Add(); 396 op = m->Int32Add();
384 break; 397 break;
385 case wasm::kExprI32Sub: 398 case wasm::kExprI32Sub:
386 op = m->Int32Sub(); 399 op = m->Int32Sub();
(...skipping 2840 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 function_->code_start_offset), 3240 function_->code_start_offset),
3228 compile_ms); 3241 compile_ms);
3229 } 3242 }
3230 3243
3231 return code; 3244 return code;
3232 } 3245 }
3233 3246
3234 } // namespace compiler 3247 } // namespace compiler
3235 } // namespace internal 3248 } // namespace internal
3236 } // namespace v8 3249 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698