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

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

Issue 2367693002: [fullcodegen] Refactor code that calls load ICs. (Closed)
Patch Set: Created 4 years, 2 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/full-codegen/full-codegen.h ('k') | src/full-codegen/ia32/full-codegen-ia32.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/full-codegen/full-codegen.h" 5 #include "src/full-codegen/full-codegen.h"
6 6
7 #include "src/ast/ast-numbering.h" 7 #include "src/ast/ast-numbering.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 InitializeAstVisitor(stack_limit); 216 InitializeAstVisitor(stack_limit);
217 masm_->set_emit_debug_code(FLAG_debug_code); 217 masm_->set_emit_debug_code(FLAG_debug_code);
218 masm_->set_predictable_code_size(true); 218 masm_->set_predictable_code_size(true);
219 } 219 }
220 220
221 void FullCodeGenerator::PrepareForBailout(Expression* node, 221 void FullCodeGenerator::PrepareForBailout(Expression* node,
222 BailoutState state) { 222 BailoutState state) {
223 PrepareForBailoutForId(node->id(), state); 223 PrepareForBailoutForId(node->id(), state);
224 } 224 }
225 225
226 void FullCodeGenerator::CallLoadIC(TypeFeedbackId id) { 226 void FullCodeGenerator::CallLoadIC(FeedbackVectorSlot slot, Handle<Object> name,
227 TypeFeedbackId id) {
228 DCHECK(name->IsName());
229 __ Move(LoadDescriptor::NameRegister(), name);
230
231 EmitLoadSlot(LoadDescriptor::SlotRegister(), slot);
232
227 Handle<Code> ic = CodeFactory::LoadIC(isolate()).code(); 233 Handle<Code> ic = CodeFactory::LoadIC(isolate()).code();
228 CallIC(ic, id); 234 CallIC(ic, id);
229 if (FLAG_tf_load_ic_stub) RestoreContext(); 235 if (FLAG_tf_load_ic_stub) RestoreContext();
230 } 236 }
231 237
232 void FullCodeGenerator::CallLoadGlobalIC(TypeofMode typeof_mode,
233 TypeFeedbackId id) {
234 Handle<Code> ic = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code();
235 CallIC(ic, id);
236 }
237
238 void FullCodeGenerator::CallStoreIC(FeedbackVectorSlot slot, 238 void FullCodeGenerator::CallStoreIC(FeedbackVectorSlot slot,
239 Handle<Object> name, TypeFeedbackId id) { 239 Handle<Object> name, TypeFeedbackId id) {
240 DCHECK(name->IsName()); 240 DCHECK(name->IsName());
241 __ Move(StoreDescriptor::NameRegister(), name); 241 __ Move(StoreDescriptor::NameRegister(), name);
242 242
243 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack || 243 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack ||
244 StoreDescriptor::kStackArgumentsCount == 2); 244 StoreDescriptor::kStackArgumentsCount == 2);
245 if (StoreDescriptor::kPassLastArgsOnStack) { 245 if (StoreDescriptor::kPassLastArgsOnStack) {
246 __ Push(StoreDescriptor::ValueRegister()); 246 __ Push(StoreDescriptor::ValueRegister());
247 EmitPushSlot(slot); 247 EmitPushSlot(slot);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 487
488 globals_ = saved_globals; 488 globals_ = saved_globals;
489 } 489 }
490 490
491 491
492 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 492 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
493 Comment cmnt(masm_, "[ VariableProxy"); 493 Comment cmnt(masm_, "[ VariableProxy");
494 EmitVariableLoad(expr); 494 EmitVariableLoad(expr);
495 } 495 }
496 496
497 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy,
498 TypeofMode typeof_mode) {
499 #ifdef DEBUG
500 Variable* var = proxy->var();
501 DCHECK(var->IsUnallocated() ||
502 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL));
503 #endif
504 EmitLoadSlot(LoadGlobalDescriptor::SlotRegister(),
505 proxy->VariableFeedbackSlot());
506 Handle<Code> ic = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code();
507 CallIC(ic);
508 }
509
497 void FullCodeGenerator::VisitSloppyBlockFunctionStatement( 510 void FullCodeGenerator::VisitSloppyBlockFunctionStatement(
498 SloppyBlockFunctionStatement* declaration) { 511 SloppyBlockFunctionStatement* declaration) {
499 Visit(declaration->statement()); 512 Visit(declaration->statement());
500 } 513 }
501 514
502 515
503 int FullCodeGenerator::DeclareGlobalsFlags() { 516 int FullCodeGenerator::DeclareGlobalsFlags() {
504 return info_->GetDeclareGlobalsFlags(); 517 return info_->GetDeclareGlobalsFlags();
505 } 518 }
506 519
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 } 1099 }
1087 context()->Plug(result_register()); 1100 context()->Plug(result_register());
1088 } 1101 }
1089 1102
1090 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 1103 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1091 SetExpressionPosition(prop); 1104 SetExpressionPosition(prop);
1092 Literal* key = prop->key()->AsLiteral(); 1105 Literal* key = prop->key()->AsLiteral();
1093 DCHECK(!key->value()->IsSmi()); 1106 DCHECK(!key->value()->IsSmi());
1094 DCHECK(!prop->IsSuperAccess()); 1107 DCHECK(!prop->IsSuperAccess());
1095 1108
1096 __ Move(LoadDescriptor::NameRegister(), key->value()); 1109 CallLoadIC(prop->PropertyFeedbackSlot(), key->value());
1097 __ Move(LoadDescriptor::SlotRegister(),
1098 SmiFromSlot(prop->PropertyFeedbackSlot()));
1099 CallLoadIC();
1100 } 1110 }
1101 1111
1102 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { 1112 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) {
1103 // Stack: receiver, home_object 1113 // Stack: receiver, home_object
1104 SetExpressionPosition(prop); 1114 SetExpressionPosition(prop);
1105 Literal* key = prop->key()->AsLiteral(); 1115 Literal* key = prop->key()->AsLiteral();
1106 DCHECK(!key->value()->IsSmi()); 1116 DCHECK(!key->value()->IsSmi());
1107 DCHECK(prop->IsSuperAccess()); 1117 DCHECK(prop->IsSuperAccess());
1108 1118
1109 PushOperand(key->value()); 1119 PushOperand(key->value());
1110 CallRuntimeWithOperands(Runtime::kLoadFromSuper); 1120 CallRuntimeWithOperands(Runtime::kLoadFromSuper);
1111 } 1121 }
1112 1122
1113 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 1123 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
1114 SetExpressionPosition(prop); 1124 SetExpressionPosition(prop);
1125
1126 EmitLoadSlot(LoadDescriptor::SlotRegister(), prop->PropertyFeedbackSlot());
1127
1115 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); 1128 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code();
1116 __ Move(LoadDescriptor::SlotRegister(),
1117 SmiFromSlot(prop->PropertyFeedbackSlot()));
1118 CallIC(ic); 1129 CallIC(ic);
1119 RestoreContext(); 1130 RestoreContext();
1120 } 1131 }
1121 1132
1122 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { 1133 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) {
1123 // Stack: receiver, home_object, key. 1134 // Stack: receiver, home_object, key.
1124 SetExpressionPosition(prop); 1135 SetExpressionPosition(prop);
1125 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); 1136 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper);
1126 } 1137 }
1127 1138
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 1562
1552 PushOperand(Smi::FromInt(lit->start_position())); 1563 PushOperand(Smi::FromInt(lit->start_position()));
1553 PushOperand(Smi::FromInt(lit->end_position())); 1564 PushOperand(Smi::FromInt(lit->end_position()));
1554 1565
1555 CallRuntimeWithOperands(Runtime::kDefineClass); 1566 CallRuntimeWithOperands(Runtime::kDefineClass);
1556 PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER); 1567 PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER);
1557 PushOperand(result_register()); 1568 PushOperand(result_register());
1558 1569
1559 // Load the "prototype" from the constructor. 1570 // Load the "prototype" from the constructor.
1560 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); 1571 __ Move(LoadDescriptor::ReceiverRegister(), result_register());
1561 __ LoadRoot(LoadDescriptor::NameRegister(), Heap::kprototype_stringRootIndex); 1572 CallLoadIC(lit->PrototypeSlot(), isolate()->factory()->prototype_string());
1562 __ Move(LoadDescriptor::SlotRegister(), SmiFromSlot(lit->PrototypeSlot()));
1563 CallLoadIC();
1564 PrepareForBailoutForId(lit->PrototypeId(), BailoutState::TOS_REGISTER); 1573 PrepareForBailoutForId(lit->PrototypeId(), BailoutState::TOS_REGISTER);
1565 PushOperand(result_register()); 1574 PushOperand(result_register());
1566 1575
1567 EmitClassDefineProperties(lit); 1576 EmitClassDefineProperties(lit);
1568 DropOperands(1); 1577 DropOperands(1);
1569 1578
1570 // Set the constructor to have fast properties. 1579 // Set the constructor to have fast properties.
1571 CallRuntimeWithOperands(Runtime::kToFastProperties); 1580 CallRuntimeWithOperands(Runtime::kToFastProperties);
1572 1581
1573 if (lit->class_variable_proxy() != nullptr) { 1582 if (lit->class_variable_proxy() != nullptr) {
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 return info_->has_simple_parameters(); 2050 return info_->has_simple_parameters();
2042 } 2051 }
2043 2052
2044 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } 2053 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); }
2045 2054
2046 #undef __ 2055 #undef __
2047 2056
2048 2057
2049 } // namespace internal 2058 } // namespace internal
2050 } // namespace v8 2059 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.h ('k') | src/full-codegen/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698