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

Side by Side Diff: src/mips/full-codegen-mips.cc

Issue 1255613002: Reduce duplicate code in full-codegen across platforms. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix mips Created 5 years, 5 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 | « src/ia32/full-codegen-ia32.cc ('k') | src/mips64/full-codegen-mips64.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #if V8_TARGET_ARCH_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 int no_frame_start = masm_->pc_offset(); 497 int no_frame_start = masm_->pc_offset();
498 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit())); 498 masm_->MultiPop(static_cast<RegList>(fp.bit() | ra.bit()));
499 masm_->Addu(sp, sp, Operand(sp_delta)); 499 masm_->Addu(sp, sp, Operand(sp_delta));
500 masm_->Jump(ra); 500 masm_->Jump(ra);
501 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); 501 info_->AddNoFrameRange(no_frame_start, masm_->pc_offset());
502 } 502 }
503 } 503 }
504 } 504 }
505 505
506 506
507 void FullCodeGenerator::EffectContext::Plug(Variable* var) const {
508 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
509 }
510
511
512 void FullCodeGenerator::AccumulatorValueContext::Plug(Variable* var) const {
513 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
514 codegen()->GetVar(result_register(), var);
515 }
516
517
518 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { 507 void FullCodeGenerator::StackValueContext::Plug(Variable* var) const {
519 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 508 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
520 codegen()->GetVar(result_register(), var); 509 codegen()->GetVar(result_register(), var);
521 __ push(result_register()); 510 __ push(result_register());
522 } 511 }
523 512
524 513
525 void FullCodeGenerator::TestContext::Plug(Variable* var) const {
526 // For simplicity we always test the accumulator register.
527 codegen()->GetVar(result_register(), var);
528 codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL);
529 codegen()->DoTest(this);
530 }
531
532
533 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { 514 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {
534 } 515 }
535 516
536 517
537 void FullCodeGenerator::AccumulatorValueContext::Plug( 518 void FullCodeGenerator::AccumulatorValueContext::Plug(
538 Heap::RootListIndex index) const { 519 Heap::RootListIndex index) const {
539 __ LoadRoot(result_register(), index); 520 __ LoadRoot(result_register(), index);
540 } 521 }
541 522
542 523
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 664 }
684 665
685 666
686 void FullCodeGenerator::TestContext::Plug(Label* materialize_true, 667 void FullCodeGenerator::TestContext::Plug(Label* materialize_true,
687 Label* materialize_false) const { 668 Label* materialize_false) const {
688 DCHECK(materialize_true == true_label_); 669 DCHECK(materialize_true == true_label_);
689 DCHECK(materialize_false == false_label_); 670 DCHECK(materialize_false == false_label_);
690 } 671 }
691 672
692 673
693 void FullCodeGenerator::EffectContext::Plug(bool flag) const {
694 }
695
696
697 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { 674 void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const {
698 Heap::RootListIndex value_root_index = 675 Heap::RootListIndex value_root_index =
699 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; 676 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
700 __ LoadRoot(result_register(), value_root_index); 677 __ LoadRoot(result_register(), value_root_index);
701 } 678 }
702 679
703 680
704 void FullCodeGenerator::StackValueContext::Plug(bool flag) const { 681 void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
705 Heap::RootListIndex value_root_index = 682 Heap::RootListIndex value_root_index =
706 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; 683 flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 __ Push(cp, a2, a1); 936 __ Push(cp, a2, a1);
960 // Push initial value for function declaration. 937 // Push initial value for function declaration.
961 VisitForStackValue(declaration->fun()); 938 VisitForStackValue(declaration->fun());
962 __ CallRuntime(Runtime::kDeclareLookupSlot, 4); 939 __ CallRuntime(Runtime::kDeclareLookupSlot, 4);
963 break; 940 break;
964 } 941 }
965 } 942 }
966 } 943 }
967 944
968 945
969 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) {
970 VariableProxy* proxy = declaration->proxy();
971 Variable* variable = proxy->var();
972 switch (variable->location()) {
973 case VariableLocation::GLOBAL:
974 case VariableLocation::UNALLOCATED:
975 // TODO(rossberg)
976 break;
977
978 case VariableLocation::CONTEXT: {
979 Comment cmnt(masm_, "[ ImportDeclaration");
980 EmitDebugCheckDeclarationContext(variable);
981 // TODO(rossberg)
982 break;
983 }
984
985 case VariableLocation::PARAMETER:
986 case VariableLocation::LOCAL:
987 case VariableLocation::LOOKUP:
988 UNREACHABLE();
989 }
990 }
991
992
993 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) {
994 // TODO(rossberg)
995 }
996
997
998 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { 946 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
999 // Call the runtime to declare the globals. 947 // Call the runtime to declare the globals.
1000 // The context is the first argument. 948 // The context is the first argument.
1001 __ li(a1, Operand(pairs)); 949 __ li(a1, Operand(pairs));
1002 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); 950 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags())));
1003 __ Push(cp, a1, a0); 951 __ Push(cp, a1, a0);
1004 __ CallRuntime(Runtime::kDeclareGlobals, 3); 952 __ CallRuntime(Runtime::kDeclareGlobals, 3);
1005 // Return value is ignored. 953 // Return value is ignored.
1006 } 954 }
1007 955
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 __ li(a0, Operand(info)); 1261 __ li(a0, Operand(info));
1314 __ LoadRoot(a1, pretenure ? Heap::kTrueValueRootIndex 1262 __ LoadRoot(a1, pretenure ? Heap::kTrueValueRootIndex
1315 : Heap::kFalseValueRootIndex); 1263 : Heap::kFalseValueRootIndex);
1316 __ Push(cp, a0, a1); 1264 __ Push(cp, a0, a1);
1317 __ CallRuntime(Runtime::kNewClosure, 3); 1265 __ CallRuntime(Runtime::kNewClosure, 3);
1318 } 1266 }
1319 context()->Plug(v0); 1267 context()->Plug(v0);
1320 } 1268 }
1321 1269
1322 1270
1323 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1324 Comment cmnt(masm_, "[ VariableProxy");
1325 EmitVariableLoad(expr);
1326 }
1327
1328
1329 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, 1271 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer,
1330 int offset, 1272 int offset,
1331 FeedbackVectorICSlot slot) { 1273 FeedbackVectorICSlot slot) {
1332 if (NeedsHomeObject(initializer)) { 1274 if (NeedsHomeObject(initializer)) {
1333 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); 1275 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp));
1334 __ li(StoreDescriptor::NameRegister(), 1276 __ li(StoreDescriptor::NameRegister(),
1335 Operand(isolate()->factory()->home_object_symbol())); 1277 Operand(isolate()->factory()->home_object_symbol()));
1336 __ lw(StoreDescriptor::ValueRegister(), 1278 __ lw(StoreDescriptor::ValueRegister(),
1337 MemOperand(sp, offset * kPointerSize)); 1279 MemOperand(sp, offset * kPointerSize));
1338 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 1280 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
(...skipping 2547 matching lines...) Expand 10 before | Expand all | Expand 10 after
3886 __ bind(&null); 3828 __ bind(&null);
3887 __ LoadRoot(v0, Heap::kNullValueRootIndex); 3829 __ LoadRoot(v0, Heap::kNullValueRootIndex);
3888 3830
3889 // All done. 3831 // All done.
3890 __ bind(&done); 3832 __ bind(&done);
3891 3833
3892 context()->Plug(v0); 3834 context()->Plug(v0);
3893 } 3835 }
3894 3836
3895 3837
3896 void FullCodeGenerator::EmitSubString(CallRuntime* expr) {
3897 // Load the arguments on the stack and call the stub.
3898 SubStringStub stub(isolate());
3899 ZoneList<Expression*>* args = expr->arguments();
3900 DCHECK(args->length() == 3);
3901 VisitForStackValue(args->at(0));
3902 VisitForStackValue(args->at(1));
3903 VisitForStackValue(args->at(2));
3904 __ CallStub(&stub);
3905 context()->Plug(v0);
3906 }
3907
3908
3909 void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) {
3910 // Load the arguments on the stack and call the stub.
3911 RegExpExecStub stub(isolate());
3912 ZoneList<Expression*>* args = expr->arguments();
3913 DCHECK(args->length() == 4);
3914 VisitForStackValue(args->at(0));
3915 VisitForStackValue(args->at(1));
3916 VisitForStackValue(args->at(2));
3917 VisitForStackValue(args->at(3));
3918 __ CallStub(&stub);
3919 context()->Plug(v0);
3920 }
3921
3922
3923 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { 3838 void FullCodeGenerator::EmitValueOf(CallRuntime* expr) {
3924 ZoneList<Expression*>* args = expr->arguments(); 3839 ZoneList<Expression*>* args = expr->arguments();
3925 DCHECK(args->length() == 1); 3840 DCHECK(args->length() == 1);
3926 3841
3927 VisitForAccumulatorValue(args->at(0)); // Load the object. 3842 VisitForAccumulatorValue(args->at(0)); // Load the object.
3928 3843
3929 Label done; 3844 Label done;
3930 // If the object is a smi return the object. 3845 // If the object is a smi return the object.
3931 __ JumpIfSmi(v0, &done); 3846 __ JumpIfSmi(v0, &done);
3932 // If the object is not a value type, return the object. 3847 // If the object is not a value type, return the object.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 __ Addu(at, 3983 __ Addu(at,
4069 string, 3984 string,
4070 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); 3985 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
4071 __ Addu(at, at, index); 3986 __ Addu(at, at, index);
4072 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 3987 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
4073 __ sh(value, MemOperand(at)); 3988 __ sh(value, MemOperand(at));
4074 context()->Plug(string); 3989 context()->Plug(string);
4075 } 3990 }
4076 3991
4077 3992
4078 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
4079 // Load the arguments on the stack and call the runtime function.
4080 ZoneList<Expression*>* args = expr->arguments();
4081 DCHECK(args->length() == 2);
4082 VisitForStackValue(args->at(0));
4083 VisitForStackValue(args->at(1));
4084 MathPowStub stub(isolate(), MathPowStub::ON_STACK);
4085 __ CallStub(&stub);
4086 context()->Plug(v0);
4087 }
4088
4089
4090 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { 3993 void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) {
4091 ZoneList<Expression*>* args = expr->arguments(); 3994 ZoneList<Expression*>* args = expr->arguments();
4092 DCHECK(args->length() == 2); 3995 DCHECK(args->length() == 2);
4093 3996
4094 VisitForStackValue(args->at(0)); // Load the object. 3997 VisitForStackValue(args->at(0)); // Load the object.
4095 VisitForAccumulatorValue(args->at(1)); // Load the value. 3998 VisitForAccumulatorValue(args->at(1)); // Load the value.
4096 __ pop(a1); // v0 = value. a1 = object. 3999 __ pop(a1); // v0 = value. a1 = object.
4097 4000
4098 Label done; 4001 Label done;
4099 // If the object is a smi, return the value. 4002 // If the object is a smi, return the value.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
4252 VisitForAccumulatorValue(args->at(1)); 4155 VisitForAccumulatorValue(args->at(1));
4253 4156
4254 __ pop(a1); 4157 __ pop(a1);
4255 __ mov(a0, result_register()); // StringAddStub requires args in a0, a1. 4158 __ mov(a0, result_register()); // StringAddStub requires args in a0, a1.
4256 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED); 4159 StringAddStub stub(isolate(), STRING_ADD_CHECK_BOTH, NOT_TENURED);
4257 __ CallStub(&stub); 4160 __ CallStub(&stub);
4258 context()->Plug(v0); 4161 context()->Plug(v0);
4259 } 4162 }
4260 4163
4261 4164
4262 void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
4263 ZoneList<Expression*>* args = expr->arguments();
4264 DCHECK_EQ(2, args->length());
4265
4266 VisitForStackValue(args->at(0));
4267 VisitForStackValue(args->at(1));
4268
4269 StringCompareStub stub(isolate());
4270 __ CallStub(&stub);
4271 context()->Plug(v0);
4272 }
4273
4274
4275 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { 4165 void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
4276 ZoneList<Expression*>* args = expr->arguments(); 4166 ZoneList<Expression*>* args = expr->arguments();
4277 DCHECK(args->length() >= 2); 4167 DCHECK(args->length() >= 2);
4278 4168
4279 int arg_count = args->length() - 2; // 2 ~ receiver and function. 4169 int arg_count = args->length() - 2; // 2 ~ receiver and function.
4280 for (int i = 0; i < arg_count + 1; i++) { 4170 for (int i = 0; i < arg_count + 1; i++) {
4281 VisitForStackValue(args->at(i)); 4171 VisitForStackValue(args->at(i));
4282 } 4172 }
4283 VisitForAccumulatorValue(args->last()); // Function. 4173 VisitForAccumulatorValue(args->last()); // Function.
4284 4174
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
5536 reinterpret_cast<uint32_t>( 5426 reinterpret_cast<uint32_t>(
5537 isolate->builtins()->OsrAfterStackCheck()->entry())); 5427 isolate->builtins()->OsrAfterStackCheck()->entry()));
5538 return OSR_AFTER_STACK_CHECK; 5428 return OSR_AFTER_STACK_CHECK;
5539 } 5429 }
5540 5430
5541 5431
5542 } // namespace internal 5432 } // namespace internal
5543 } // namespace v8 5433 } // namespace v8
5544 5434
5545 #endif // V8_TARGET_ARCH_MIPS 5435 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698