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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/wasm/asm-wasm-builder.h" | 7 #include "src/wasm/asm-wasm-builder.h" |
8 #include "src/wasm/wasm-macro-gen.h" | 8 #include "src/wasm/wasm-macro-gen.h" |
9 #include "src/wasm/wasm-opcodes.h" | 9 #include "src/wasm/wasm-opcodes.h" |
10 | 10 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 | 313 |
314 void VisitVariableProxy(VariableProxy* expr) { | 314 void VisitVariableProxy(VariableProxy* expr) { |
315 if (in_function_) { | 315 if (in_function_) { |
316 Variable* var = expr->var(); | 316 Variable* var = expr->var(); |
317 if (var->is_function()) { | 317 if (var->is_function()) { |
318 DCHECK(!is_set_op_); | 318 DCHECK(!is_set_op_); |
319 std::vector<uint8_t> index = | 319 std::vector<uint8_t> index = |
320 UnsignedLEB128From(LookupOrInsertFunction(var)); | 320 UnsignedLEB128From(LookupOrInsertFunction(var)); |
321 current_function_builder_->EmitCode( | 321 current_function_builder_->EmitCode( |
322 index.data(), static_cast<uint32_t>(index.size())); | 322 &index[0], static_cast<uint32_t>(index.size())); |
323 } else { | 323 } else { |
324 if (is_set_op_) { | 324 if (is_set_op_) { |
325 if (var->IsContextSlot()) { | 325 if (var->IsContextSlot()) { |
326 current_function_builder_->Emit(kExprStoreGlobal); | 326 current_function_builder_->Emit(kExprStoreGlobal); |
327 } else { | 327 } else { |
328 current_function_builder_->Emit(kExprSetLocal); | 328 current_function_builder_->Emit(kExprSetLocal); |
329 } | 329 } |
330 is_set_op_ = false; | 330 is_set_op_ = false; |
331 } else { | 331 } else { |
332 if (var->IsContextSlot()) { | 332 if (var->IsContextSlot()) { |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 AddLeb128(index_0, true); | 779 AddLeb128(index_0, true); |
780 current_function_builder_->Emit(kExprGetLocal); | 780 current_function_builder_->Emit(kExprGetLocal); |
781 AddLeb128(index_1, true); | 781 AddLeb128(index_1, true); |
782 } | 782 } |
783 | 783 |
784 void AddLeb128(uint32_t index, bool is_local) { | 784 void AddLeb128(uint32_t index, bool is_local) { |
785 std::vector<uint8_t> index_vec = UnsignedLEB128From(index); | 785 std::vector<uint8_t> index_vec = UnsignedLEB128From(index); |
786 if (is_local) { | 786 if (is_local) { |
787 uint32_t pos_of_index[1] = {0}; | 787 uint32_t pos_of_index[1] = {0}; |
788 current_function_builder_->EmitCode( | 788 current_function_builder_->EmitCode( |
789 index_vec.data(), static_cast<uint32_t>(index_vec.size()), | 789 &index_vec[0], static_cast<uint32_t>(index_vec.size()), pos_of_index, |
790 pos_of_index, 1); | 790 1); |
791 } else { | 791 } else { |
792 current_function_builder_->EmitCode( | 792 current_function_builder_->EmitCode( |
793 index_vec.data(), static_cast<uint32_t>(index_vec.size())); | 793 &index_vec[0], static_cast<uint32_t>(index_vec.size())); |
794 } | 794 } |
795 } | 795 } |
796 | 796 |
797 void VisitCompareOperation(CompareOperation* expr) { | 797 void VisitCompareOperation(CompareOperation* expr) { |
798 switch (expr->op()) { | 798 switch (expr->op()) { |
799 BINOP_CASE(Token::EQ, Eq, NON_SIGNED_BINOP, false); | 799 BINOP_CASE(Token::EQ, Eq, NON_SIGNED_BINOP, false); |
800 BINOP_CASE(Token::LT, Lt, SIGNED_BINOP, false); | 800 BINOP_CASE(Token::LT, Lt, SIGNED_BINOP, false); |
801 BINOP_CASE(Token::LTE, Le, SIGNED_BINOP, false); | 801 BINOP_CASE(Token::LTE, Le, SIGNED_BINOP, false); |
802 BINOP_CASE(Token::GT, Gt, SIGNED_BINOP, false); | 802 BINOP_CASE(Token::GT, Gt, SIGNED_BINOP, false); |
803 BINOP_CASE(Token::GTE, Ge, SIGNED_BINOP, false); | 803 BINOP_CASE(Token::GTE, Ge, SIGNED_BINOP, false); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 } else if (type->Is(cache_.kAsmUnsigned)) { | 849 } else if (type->Is(cache_.kAsmUnsigned)) { |
850 return kUint32; | 850 return kUint32; |
851 } else if (type->Is(cache_.kAsmInt)) { | 851 } else if (type->Is(cache_.kAsmInt)) { |
852 return kInt32; | 852 return kInt32; |
853 } else if (type->Is(cache_.kAsmFloat)) { | 853 } else if (type->Is(cache_.kAsmFloat)) { |
854 return kFloat32; | 854 return kFloat32; |
855 } else if (type->Is(cache_.kAsmDouble)) { | 855 } else if (type->Is(cache_.kAsmDouble)) { |
856 return kFloat64; | 856 return kFloat64; |
857 } else { | 857 } else { |
858 UNREACHABLE(); | 858 UNREACHABLE(); |
| 859 return kInt32; |
859 } | 860 } |
860 } | 861 } |
861 | 862 |
862 #undef CASE | 863 #undef CASE |
863 #undef NON_SIGNED_INT | 864 #undef NON_SIGNED_INT |
864 #undef SIGNED | 865 #undef SIGNED |
865 #undef NON_SIGNED | 866 #undef NON_SIGNED |
866 | 867 |
867 void VisitThisFunction(ThisFunction* expr) {} | 868 void VisitThisFunction(ThisFunction* expr) {} |
868 | 869 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 // that zone in constructor may be thrown away once wasm module is written. | 993 // that zone in constructor may be thrown away once wasm module is written. |
993 WasmModuleIndex* AsmWasmBuilder::Run() { | 994 WasmModuleIndex* AsmWasmBuilder::Run() { |
994 AsmWasmBuilderImpl impl(isolate_, zone_, literal_); | 995 AsmWasmBuilderImpl impl(isolate_, zone_, literal_); |
995 impl.Compile(); | 996 impl.Compile(); |
996 WasmModuleWriter* writer = impl.builder_->Build(zone_); | 997 WasmModuleWriter* writer = impl.builder_->Build(zone_); |
997 return writer->WriteTo(zone_); | 998 return writer->WriteTo(zone_); |
998 } | 999 } |
999 } // namespace wasm | 1000 } // namespace wasm |
1000 } // namespace internal | 1001 } // namespace internal |
1001 } // namespace v8 | 1002 } // namespace v8 |
OLD | NEW |