| 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/handles.h" | 7 #include "src/handles.h" |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 183 |
| 184 void WasmFunctionBuilder::EmitWithVarInt(WasmOpcode opcode, | 184 void WasmFunctionBuilder::EmitWithVarInt(WasmOpcode opcode, |
| 185 uint32_t immediate) { | 185 uint32_t immediate) { |
| 186 body_.push_back(static_cast<byte>(opcode)); | 186 body_.push_back(static_cast<byte>(opcode)); |
| 187 size_t immediate_size = SizeOfVarInt(immediate); | 187 size_t immediate_size = SizeOfVarInt(immediate); |
| 188 body_.insert(body_.end(), immediate_size, 0); | 188 body_.insert(body_.end(), immediate_size, 0); |
| 189 byte* p = &body_[body_.size() - immediate_size]; | 189 byte* p = &body_[body_.size() - immediate_size]; |
| 190 EmitVarInt(&p, immediate); | 190 EmitVarInt(&p, immediate); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void WasmFunctionBuilder::EmitI32Const(int32_t value) { |
| 194 // TODO(titzer): variable-length signed and unsigned i32 constants. |
| 195 if (-128 <= value && value <= 127) { |
| 196 EmitWithU8(kExprI8Const, static_cast<byte>(value)); |
| 197 } else { |
| 198 byte code[] = {WASM_I32V_5(value)}; |
| 199 EmitCode(code, sizeof(code)); |
| 200 } |
| 201 } |
| 202 |
| 193 uint32_t WasmFunctionBuilder::EmitEditableVarIntImmediate() { | 203 uint32_t WasmFunctionBuilder::EmitEditableVarIntImmediate() { |
| 194 // Guess that the immediate will be 1 byte. If it is more, we'll have to | 204 // Guess that the immediate will be 1 byte. If it is more, we'll have to |
| 195 // shift everything down. | 205 // shift everything down. |
| 196 body_.push_back(0); | 206 body_.push_back(0); |
| 197 return static_cast<uint32_t>(body_.size()) - 1; | 207 return static_cast<uint32_t>(body_.size()) - 1; |
| 198 } | 208 } |
| 199 | 209 |
| 200 void WasmFunctionBuilder::EditVarIntImmediate(uint32_t offset, | 210 void WasmFunctionBuilder::EditVarIntImmediate(uint32_t offset, |
| 201 const uint32_t immediate) { | 211 const uint32_t immediate) { |
| 202 uint32_t immediate_size = static_cast<uint32_t>(SizeOfVarInt(immediate)); | 212 uint32_t immediate_size = static_cast<uint32_t>(SizeOfVarInt(immediate)); |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 next = next | 0x80; | 740 next = next | 0x80; |
| 731 } | 741 } |
| 732 output.push_back(next); | 742 output.push_back(next); |
| 733 shift += 7; | 743 shift += 7; |
| 734 } while ((next & 0x80) != 0); | 744 } while ((next & 0x80) != 0); |
| 735 return output; | 745 return output; |
| 736 } | 746 } |
| 737 } // namespace wasm | 747 } // namespace wasm |
| 738 } // namespace internal | 748 } // namespace internal |
| 739 } // namespace v8 | 749 } // namespace v8 |
| OLD | NEW |