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

Side by Side Diff: src/wasm/asm-wasm-builder.cc

Issue 1760363003: Revert of [wasm] Update {i32,i64}.const to use signed leb128 (Closed) Base URL: http://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | src/wasm/ast-decoder.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/v8.h" 5 #include "src/v8.h"
6 6
7 // Required to get M_E etc. in MSVC. 7 // Required to get M_E etc. in MSVC.
8 #if defined(_WIN32) 8 #if defined(_WIN32)
9 #define _USE_MATH_DEFINES 9 #define _USE_MATH_DEFINES
10 #endif 10 #endif
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (!in_function_) { 230 if (!in_function_) {
231 marking_exported = false; 231 marking_exported = false;
232 } 232 }
233 } 233 }
234 234
235 void VisitWithStatement(WithStatement* stmt) { UNREACHABLE(); } 235 void VisitWithStatement(WithStatement* stmt) { UNREACHABLE(); }
236 236
237 void SetLocalTo(uint16_t index, int value) { 237 void SetLocalTo(uint16_t index, int value) {
238 current_function_builder_->Emit(kExprSetLocal); 238 current_function_builder_->Emit(kExprSetLocal);
239 AddLeb128(index, true); 239 AddLeb128(index, true);
240 // TODO(bradnelson): variable size 240 byte code[] = {WASM_I32(value)};
241 byte code[] = {WASM_I32V(value)};
242 current_function_builder_->EmitCode(code, sizeof(code)); 241 current_function_builder_->EmitCode(code, sizeof(code));
243 block_size_++; 242 block_size_++;
244 } 243 }
245 244
246 void CompileCase(CaseClause* clause, uint16_t fall_through, 245 void CompileCase(CaseClause* clause, uint16_t fall_through,
247 VariableProxy* tag) { 246 VariableProxy* tag) {
248 Literal* label = clause->label()->AsLiteral(); 247 Literal* label = clause->label()->AsLiteral();
249 DCHECK_NOT_NULL(label); 248 DCHECK_NOT_NULL(label);
250 block_size_++; 249 block_size_++;
251 current_function_builder_->Emit(kExprIf); 250 current_function_builder_->Emit(kExprIf);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 458 }
460 } 459 }
461 460
462 void VisitLiteral(Literal* expr) { 461 void VisitLiteral(Literal* expr) {
463 if (in_function_) { 462 if (in_function_) {
464 if (expr->raw_value()->IsNumber()) { 463 if (expr->raw_value()->IsNumber()) {
465 LocalType type = TypeOf(expr); 464 LocalType type = TypeOf(expr);
466 switch (type) { 465 switch (type) {
467 case kAstI32: { 466 case kAstI32: {
468 int val = static_cast<int>(expr->raw_value()->AsNumber()); 467 int val = static_cast<int>(expr->raw_value()->AsNumber());
469 // TODO(bradnelson): variable size 468 byte code[] = {WASM_I32(val)};
470 byte code[] = {WASM_I32V(val)};
471 current_function_builder_->EmitCode(code, sizeof(code)); 469 current_function_builder_->EmitCode(code, sizeof(code));
472 break; 470 break;
473 } 471 }
474 case kAstF32: { 472 case kAstF32: {
475 float val = static_cast<float>(expr->raw_value()->AsNumber()); 473 float val = static_cast<float>(expr->raw_value()->AsNumber());
476 byte code[] = {WASM_F32(val)}; 474 byte code[] = {WASM_F32(val)};
477 current_function_builder_->EmitCode(code, sizeof(code)); 475 current_function_builder_->EmitCode(code, sizeof(code));
478 break; 476 break;
479 } 477 }
480 case kAstF64: { 478 case kAstF64: {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 return; 735 return;
738 } 736 }
739 } 737 }
740 } else { 738 } else {
741 MaybeHandle<Object> maybe_nvalue = 739 MaybeHandle<Object> maybe_nvalue =
742 i::Object::ToInt32(isolate_, value); 740 i::Object::ToInt32(isolate_, value);
743 if (!maybe_nvalue.is_null()) { 741 if (!maybe_nvalue.is_null()) {
744 Handle<Object> nvalue = maybe_nvalue.ToHandleChecked(); 742 Handle<Object> nvalue = maybe_nvalue.ToHandleChecked();
745 if (nvalue->IsNumber()) { 743 if (nvalue->IsNumber()) {
746 int32_t val = static_cast<int32_t>(nvalue->Number()); 744 int32_t val = static_cast<int32_t>(nvalue->Number());
747 // TODO(bradnelson): variable size 745 byte code[] = {WASM_I32(val)};
748 byte code[] = {WASM_I32V(val)};
749 current_function_builder_->EmitCode(code, sizeof(code)); 746 current_function_builder_->EmitCode(code, sizeof(code));
750 return; 747 return;
751 } 748 }
752 } 749 }
753 } 750 }
754 } 751 }
755 } 752 }
756 if (is_float) { 753 if (is_float) {
757 byte code[] = {WASM_F64(std::numeric_limits<double>::quiet_NaN())}; 754 byte code[] = {WASM_F64(std::numeric_limits<double>::quiet_NaN())};
758 current_function_builder_->EmitCode(code, sizeof(code)); 755 current_function_builder_->EmitCode(code, sizeof(code));
759 } else { 756 } else {
760 byte code[] = {WASM_I32V_1(0)}; 757 byte code[] = {WASM_I32(0)};
761 current_function_builder_->EmitCode(code, sizeof(code)); 758 current_function_builder_->EmitCode(code, sizeof(code));
762 } 759 }
763 } 760 }
764 761
765 void VisitProperty(Property* expr) { 762 void VisitProperty(Property* expr) {
766 Expression* obj = expr->obj(); 763 Expression* obj = expr->obj();
767 DCHECK_EQ(obj->bounds().lower, obj->bounds().upper); 764 DCHECK_EQ(obj->bounds().lower, obj->bounds().upper);
768 Type* type = obj->bounds().lower; 765 Type* type = obj->bounds().lower;
769 MachineType mtype; 766 MachineType mtype;
770 int size; 767 int size;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 // Early versions of Emscripten emit HEAP8[HEAP32[..]|0] in 805 // Early versions of Emscripten emit HEAP8[HEAP32[..]|0] in
809 // places that strictly should be HEAP8[HEAP32[..]>>0]. 806 // places that strictly should be HEAP8[HEAP32[..]>>0].
810 RECURSE(Visit(expr->key())); 807 RECURSE(Visit(expr->key()));
811 return; 808 return;
812 } else { 809 } else {
813 Literal* value = expr->key()->AsLiteral(); 810 Literal* value = expr->key()->AsLiteral();
814 if (value) { 811 if (value) {
815 DCHECK(value->raw_value()->IsNumber()); 812 DCHECK(value->raw_value()->IsNumber());
816 DCHECK_EQ(kAstI32, TypeOf(value)); 813 DCHECK_EQ(kAstI32, TypeOf(value));
817 int val = static_cast<int>(value->raw_value()->AsNumber()); 814 int val = static_cast<int>(value->raw_value()->AsNumber());
818 // TODO(bradnelson): variable size 815 byte code[] = {WASM_I32(val * size)};
819 byte code[] = {WASM_I32V(val * size)};
820 current_function_builder_->EmitCode(code, sizeof(code)); 816 current_function_builder_->EmitCode(code, sizeof(code));
821 return; 817 return;
822 } 818 }
823 BinaryOperation* binop = expr->key()->AsBinaryOperation(); 819 BinaryOperation* binop = expr->key()->AsBinaryOperation();
824 if (binop) { 820 if (binop) {
825 DCHECK_EQ(Token::SAR, binop->op()); 821 DCHECK_EQ(Token::SAR, binop->op());
826 DCHECK(binop->right()->AsLiteral()->raw_value()->IsNumber()); 822 DCHECK(binop->right()->AsLiteral()->raw_value()->IsNumber());
827 DCHECK(kAstI32 == TypeOf(binop->right()->AsLiteral())); 823 DCHECK(kAstI32 == TypeOf(binop->right()->AsLiteral()));
828 DCHECK_EQ(size, 824 DCHECK_EQ(size,
829 1 << static_cast<int>( 825 1 << static_cast<int>(
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 case Call::KEYED_PROPERTY_CALL: { 1050 case Call::KEYED_PROPERTY_CALL: {
1055 DCHECK(in_function_); 1051 DCHECK(in_function_);
1056 Property* p = expr->expression()->AsProperty(); 1052 Property* p = expr->expression()->AsProperty();
1057 DCHECK_NOT_NULL(p); 1053 DCHECK_NOT_NULL(p);
1058 VariableProxy* var = p->obj()->AsVariableProxy(); 1054 VariableProxy* var = p->obj()->AsVariableProxy();
1059 DCHECK_NOT_NULL(var); 1055 DCHECK_NOT_NULL(var);
1060 FunctionTableIndices* indices = LookupFunctionTable(var->var()); 1056 FunctionTableIndices* indices = LookupFunctionTable(var->var());
1061 current_function_builder_->EmitWithU8(kExprCallIndirect, 1057 current_function_builder_->EmitWithU8(kExprCallIndirect,
1062 indices->signature_index); 1058 indices->signature_index);
1063 current_function_builder_->Emit(kExprI32Add); 1059 current_function_builder_->Emit(kExprI32Add);
1064 // TODO(bradnelson): variable size 1060 byte code[] = {WASM_I32(indices->start_index)};
1065 byte code[] = {WASM_I32V(indices->start_index)};
1066 current_function_builder_->EmitCode(code, sizeof(code)); 1061 current_function_builder_->EmitCode(code, sizeof(code));
1067 RECURSE(Visit(p->key())); 1062 RECURSE(Visit(p->key()));
1068 break; 1063 break;
1069 } 1064 }
1070 default: 1065 default:
1071 UNREACHABLE(); 1066 UNREACHABLE();
1072 } 1067 }
1073 VisitCallArgs(expr); 1068 VisitCallArgs(expr);
1074 } 1069 }
1075 1070
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 // that zone in constructor may be thrown away once wasm module is written. 1512 // that zone in constructor may be thrown away once wasm module is written.
1518 WasmModuleIndex* AsmWasmBuilder::Run() { 1513 WasmModuleIndex* AsmWasmBuilder::Run() {
1519 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, foreign_, typer_); 1514 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, foreign_, typer_);
1520 impl.Compile(); 1515 impl.Compile();
1521 WasmModuleWriter* writer = impl.builder_->Build(zone_); 1516 WasmModuleWriter* writer = impl.builder_->Build(zone_);
1522 return writer->WriteTo(zone_); 1517 return writer->WriteTo(zone_);
1523 } 1518 }
1524 } // namespace wasm 1519 } // namespace wasm
1525 } // namespace internal 1520 } // namespace internal
1526 } // namespace v8 1521 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/ast-decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698