| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 void WasmFunctionBuilder::ReturnType(LocalType type) { return_type_ = type; } | 146 void WasmFunctionBuilder::ReturnType(LocalType type) { return_type_ = type; } |
| 147 | 147 |
| 148 | 148 |
| 149 void WasmFunctionBuilder::EmitCode(const byte* code, uint32_t code_size) { | 149 void WasmFunctionBuilder::EmitCode(const byte* code, uint32_t code_size) { |
| 150 EmitCode(code, code_size, nullptr, 0); | 150 EmitCode(code, code_size, nullptr, 0); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void WasmFunctionBuilder::EmitGetLocal(uint32_t local_index) { |
| 154 local_indices_.push_back(static_cast<uint32_t>(body_.size() + 1)); |
| 155 EmitWithVarInt(kExprGetLocal, local_index); |
| 156 } |
| 157 |
| 158 void WasmFunctionBuilder::EmitSetLocal(uint32_t local_index) { |
| 159 local_indices_.push_back(static_cast<uint32_t>(body_.size() + 1)); |
| 160 EmitWithVarInt(kExprSetLocal, local_index); |
| 161 } |
| 153 | 162 |
| 154 void WasmFunctionBuilder::EmitCode(const byte* code, uint32_t code_size, | 163 void WasmFunctionBuilder::EmitCode(const byte* code, uint32_t code_size, |
| 155 const uint32_t* local_indices, | 164 const uint32_t* local_indices, |
| 156 uint32_t indices_size) { | 165 uint32_t indices_size) { |
| 157 size_t size = body_.size(); | 166 size_t size = body_.size(); |
| 158 for (size_t i = 0; i < code_size; i++) { | 167 for (size_t i = 0; i < code_size; i++) { |
| 159 body_.push_back(code[i]); | 168 body_.push_back(code[i]); |
| 160 } | 169 } |
| 161 for (size_t i = 0; i < indices_size; i++) { | 170 for (size_t i = 0; i < indices_size; i++) { |
| 162 local_indices_.push_back(local_indices[i] + static_cast<uint32_t>(size)); | 171 local_indices_.push_back(local_indices[i] + static_cast<uint32_t>(size)); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 next = next | 0x80; | 739 next = next | 0x80; |
| 731 } | 740 } |
| 732 output.push_back(next); | 741 output.push_back(next); |
| 733 shift += 7; | 742 shift += 7; |
| 734 } while ((next & 0x80) != 0); | 743 } while ((next & 0x80) != 0); |
| 735 return output; | 744 return output; |
| 736 } | 745 } |
| 737 } // namespace wasm | 746 } // namespace wasm |
| 738 } // namespace internal | 747 } // namespace internal |
| 739 } // namespace v8 | 748 } // namespace v8 |
| OLD | NEW |