| OLD | NEW |
| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 CallIC(ic, id); | 228 CallIC(ic, id); |
| 229 if (FLAG_tf_load_ic_stub) RestoreContext(); | 229 if (FLAG_tf_load_ic_stub) RestoreContext(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void FullCodeGenerator::CallLoadGlobalIC(TypeofMode typeof_mode, | 232 void FullCodeGenerator::CallLoadGlobalIC(TypeofMode typeof_mode, |
| 233 TypeFeedbackId id) { | 233 TypeFeedbackId id) { |
| 234 Handle<Code> ic = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code(); | 234 Handle<Code> ic = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code(); |
| 235 CallIC(ic, id); | 235 CallIC(ic, id); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void FullCodeGenerator::CallStoreIC(FeedbackVectorSlot slot, | 238 void FullCodeGenerator::CallStoreIC(TypeFeedbackId id) { |
| 239 Handle<Object> name, TypeFeedbackId id) { | 239 Handle<Code> ic = CodeFactory::StoreIC(isolate(), language_mode()).code(); |
| 240 DCHECK(name->IsName()); | |
| 241 __ Move(StoreDescriptor::NameRegister(), name); | |
| 242 | 240 |
| 243 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack || | 241 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack || |
| 244 StoreDescriptor::kStackArgumentsCount == 2); | 242 StoreDescriptor::kStackArgumentsCount == 2); |
| 245 if (StoreDescriptor::kPassLastArgsOnStack) { | 243 if (StoreDescriptor::kPassLastArgsOnStack) { |
| 246 __ Push(StoreDescriptor::ValueRegister()); | 244 __ Push(StoreDescriptor::ValueRegister()); |
| 247 EmitPushSlot(slot); | 245 __ Push(StoreDescriptor::SlotRegister()); |
| 248 } else { | |
| 249 EmitLoadSlot(StoreDescriptor::SlotRegister(), slot); | |
| 250 } | 246 } |
| 251 | 247 |
| 252 Handle<Code> ic = CodeFactory::StoreIC(isolate(), language_mode()).code(); | |
| 253 CallIC(ic, id); | 248 CallIC(ic, id); |
| 254 RestoreContext(); | 249 RestoreContext(); |
| 255 } | 250 } |
| 256 | 251 |
| 257 void FullCodeGenerator::CallKeyedStoreIC(FeedbackVectorSlot slot) { | 252 void FullCodeGenerator::CallKeyedStoreIC() { |
| 253 Handle<Code> ic = |
| 254 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
| 255 |
| 258 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack || | 256 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack || |
| 259 StoreDescriptor::kStackArgumentsCount == 2); | 257 StoreDescriptor::kStackArgumentsCount == 2); |
| 260 if (StoreDescriptor::kPassLastArgsOnStack) { | 258 if (StoreDescriptor::kPassLastArgsOnStack) { |
| 261 __ Push(StoreDescriptor::ValueRegister()); | 259 __ Push(StoreDescriptor::ValueRegister()); |
| 262 EmitPushSlot(slot); | 260 __ Push(StoreDescriptor::SlotRegister()); |
| 263 } else { | |
| 264 EmitLoadSlot(StoreDescriptor::SlotRegister(), slot); | |
| 265 } | 261 } |
| 266 | 262 |
| 267 Handle<Code> ic = | |
| 268 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); | |
| 269 CallIC(ic); | 263 CallIC(ic); |
| 270 RestoreContext(); | 264 RestoreContext(); |
| 271 } | 265 } |
| 272 | 266 |
| 273 void FullCodeGenerator::RecordJSReturnSite(Call* call) { | 267 void FullCodeGenerator::RecordJSReturnSite(Call* call) { |
| 274 // We record the offset of the function return so we can rebuild the frame | 268 // We record the offset of the function return so we can rebuild the frame |
| 275 // if the function was inlined, i.e., this is the return address in the | 269 // if the function was inlined, i.e., this is the return address in the |
| 276 // inlined function's frame. | 270 // inlined function's frame. |
| 277 // | 271 // |
| 278 // The bailout state is ignored. We defensively set it to TOS_REGISTER, which | 272 // The bailout state is ignored. We defensively set it to TOS_REGISTER, which |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 481 |
| 488 globals_ = saved_globals; | 482 globals_ = saved_globals; |
| 489 } | 483 } |
| 490 | 484 |
| 491 | 485 |
| 492 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 486 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
| 493 Comment cmnt(masm_, "[ VariableProxy"); | 487 Comment cmnt(masm_, "[ VariableProxy"); |
| 494 EmitVariableLoad(expr); | 488 EmitVariableLoad(expr); |
| 495 } | 489 } |
| 496 | 490 |
| 491 |
| 497 void FullCodeGenerator::VisitSloppyBlockFunctionStatement( | 492 void FullCodeGenerator::VisitSloppyBlockFunctionStatement( |
| 498 SloppyBlockFunctionStatement* declaration) { | 493 SloppyBlockFunctionStatement* declaration) { |
| 499 Visit(declaration->statement()); | 494 Visit(declaration->statement()); |
| 500 } | 495 } |
| 501 | 496 |
| 502 | 497 |
| 503 int FullCodeGenerator::DeclareGlobalsFlags() { | 498 int FullCodeGenerator::DeclareGlobalsFlags() { |
| 504 return info_->GetDeclareGlobalsFlags(); | 499 return info_->GetDeclareGlobalsFlags(); |
| 505 } | 500 } |
| 506 | 501 |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 } | 1121 } |
| 1127 | 1122 |
| 1128 void FullCodeGenerator::EmitPropertyKey(LiteralProperty* property, | 1123 void FullCodeGenerator::EmitPropertyKey(LiteralProperty* property, |
| 1129 BailoutId bailout_id) { | 1124 BailoutId bailout_id) { |
| 1130 VisitForStackValue(property->key()); | 1125 VisitForStackValue(property->key()); |
| 1131 CallRuntimeWithOperands(Runtime::kToName); | 1126 CallRuntimeWithOperands(Runtime::kToName); |
| 1132 PrepareForBailoutForId(bailout_id, BailoutState::TOS_REGISTER); | 1127 PrepareForBailoutForId(bailout_id, BailoutState::TOS_REGISTER); |
| 1133 PushOperand(result_register()); | 1128 PushOperand(result_register()); |
| 1134 } | 1129 } |
| 1135 | 1130 |
| 1136 void FullCodeGenerator::EmitLoadSlot(Register destination, | 1131 void FullCodeGenerator::EmitLoadStoreICSlot(FeedbackVectorSlot slot) { |
| 1137 FeedbackVectorSlot slot) { | |
| 1138 DCHECK(!slot.IsInvalid()); | 1132 DCHECK(!slot.IsInvalid()); |
| 1139 __ Move(destination, SmiFromSlot(slot)); | 1133 __ Move(StoreDescriptor::SlotRegister(), SmiFromSlot(slot)); |
| 1140 } | |
| 1141 | |
| 1142 void FullCodeGenerator::EmitPushSlot(FeedbackVectorSlot slot) { | |
| 1143 __ Push(SmiFromSlot(slot)); | |
| 1144 } | 1134 } |
| 1145 | 1135 |
| 1146 void FullCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 1136 void FullCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { |
| 1147 Comment cmnt(masm_, "[ ReturnStatement"); | 1137 Comment cmnt(masm_, "[ ReturnStatement"); |
| 1148 SetStatementPosition(stmt); | 1138 SetStatementPosition(stmt); |
| 1149 Expression* expr = stmt->expression(); | 1139 Expression* expr = stmt->expression(); |
| 1150 VisitForAccumulatorValue(expr); | 1140 VisitForAccumulatorValue(expr); |
| 1151 EmitUnwindAndReturn(); | 1141 EmitUnwindAndReturn(); |
| 1152 } | 1142 } |
| 1153 | 1143 |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 return info_->has_simple_parameters(); | 2031 return info_->has_simple_parameters(); |
| 2042 } | 2032 } |
| 2043 | 2033 |
| 2044 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } | 2034 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } |
| 2045 | 2035 |
| 2046 #undef __ | 2036 #undef __ |
| 2047 | 2037 |
| 2048 | 2038 |
| 2049 } // namespace internal | 2039 } // namespace internal |
| 2050 } // namespace v8 | 2040 } // namespace v8 |
| OLD | NEW |