OLD | NEW |
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/signature.h" | 5 #include "src/signature.h" |
6 | 6 |
7 #include "src/bit-vector.h" | 7 #include "src/bit-vector.h" |
8 #include "src/flags.h" | 8 #include "src/flags.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/zone-containers.h" | 10 #include "src/zone-containers.h" |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } | 394 } |
395 } | 395 } |
396 | 396 |
397 unsigned OpcodeLength(const byte* pc) { | 397 unsigned OpcodeLength(const byte* pc) { |
398 switch (static_cast<WasmOpcode>(*pc)) { | 398 switch (static_cast<WasmOpcode>(*pc)) { |
399 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: | 399 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: |
400 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) | 400 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) |
401 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) | 401 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) |
402 #undef DECLARE_OPCODE_CASE | 402 #undef DECLARE_OPCODE_CASE |
403 { | 403 { |
404 MemoryAccessOperand operand(this, pc); | 404 MemoryAccessOperand operand(this, pc, UINT32_MAX); |
405 return 1 + operand.length; | 405 return 1 + operand.length; |
406 } | 406 } |
407 case kExprBr: | 407 case kExprBr: |
408 case kExprBrIf: { | 408 case kExprBrIf: { |
409 BreakDepthOperand operand(this, pc); | 409 BreakDepthOperand operand(this, pc); |
410 return 1 + operand.length; | 410 return 1 + operand.length; |
411 } | 411 } |
412 case kExprSetGlobal: | 412 case kExprSetGlobal: |
413 case kExprGetGlobal: { | 413 case kExprGetGlobal: { |
414 GlobalIndexOperand operand(this, pc); | 414 GlobalIndexOperand operand(this, pc); |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 } | 1371 } |
1372 | 1372 |
1373 void PopControl() { | 1373 void PopControl() { |
1374 const Control& c = control_.back(); | 1374 const Control& c = control_.back(); |
1375 most_recent_finally_ = c.prev_finally; | 1375 most_recent_finally_ = c.prev_finally; |
1376 control_.pop_back(); | 1376 control_.pop_back(); |
1377 // No more accesses to (danging pointer) c | 1377 // No more accesses to (danging pointer) c |
1378 } | 1378 } |
1379 | 1379 |
1380 int DecodeLoadMem(LocalType type, MachineType mem_type) { | 1380 int DecodeLoadMem(LocalType type, MachineType mem_type) { |
1381 MemoryAccessOperand operand(this, pc_); | 1381 MemoryAccessOperand operand(this, pc_, |
| 1382 ElementSizeLog2Of(mem_type.representation())); |
| 1383 |
1382 Value index = Pop(0, kAstI32); | 1384 Value index = Pop(0, kAstI32); |
1383 TFNode* node = BUILD(LoadMem, type, mem_type, index.node, operand.offset, | 1385 TFNode* node = BUILD(LoadMem, type, mem_type, index.node, operand.offset, |
1384 operand.alignment, position()); | 1386 operand.alignment, position()); |
1385 Push(type, node); | 1387 Push(type, node); |
1386 return 1 + operand.length; | 1388 return 1 + operand.length; |
1387 } | 1389 } |
1388 | 1390 |
1389 int DecodeStoreMem(LocalType type, MachineType mem_type) { | 1391 int DecodeStoreMem(LocalType type, MachineType mem_type) { |
1390 MemoryAccessOperand operand(this, pc_); | 1392 MemoryAccessOperand operand(this, pc_, |
| 1393 ElementSizeLog2Of(mem_type.representation())); |
1391 Value val = Pop(1, type); | 1394 Value val = Pop(1, type); |
1392 Value index = Pop(0, kAstI32); | 1395 Value index = Pop(0, kAstI32); |
1393 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, | 1396 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, |
1394 val.node, position()); | 1397 val.node, position()); |
1395 Push(type, val.node); | 1398 Push(type, val.node); |
1396 return 1 + operand.length; | 1399 return 1 + operand.length; |
1397 } | 1400 } |
1398 | 1401 |
1399 void DecodeSimdOpcode(WasmOpcode opcode) { | 1402 void DecodeSimdOpcode(WasmOpcode opcode) { |
1400 FunctionSig* sig = WasmOpcodes::Signature(opcode); | 1403 FunctionSig* sig = WasmOpcodes::Signature(opcode); |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 2067 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
2065 const byte* start, const byte* end) { | 2068 const byte* start, const byte* end) { |
2066 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 2069 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
2067 WasmFullDecoder decoder(zone, nullptr, body); | 2070 WasmFullDecoder decoder(zone, nullptr, body); |
2068 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 2071 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
2069 } | 2072 } |
2070 | 2073 |
2071 } // namespace wasm | 2074 } // namespace wasm |
2072 } // namespace internal | 2075 } // namespace internal |
2073 } // namespace v8 | 2076 } // namespace v8 |
OLD | NEW |