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

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

Issue 2472653002: [compiler] Sanitize IC counts for vector based ICs. (Closed)
Patch Set: Fix compile. Created 4 years, 1 month 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(FeedbackVectorSlot slot, Handle<Object> name, 226 void FullCodeGenerator::CallIC(Handle<Code> code, TypeFeedbackId ast_id) {
227 TypeFeedbackId id) { 227 ic_total_count_++;
228 __ Call(code, RelocInfo::CODE_TARGET, ast_id);
229 }
230
231 void FullCodeGenerator::CallLoadIC(FeedbackVectorSlot slot,
232 Handle<Object> name) {
228 DCHECK(name->IsName()); 233 DCHECK(name->IsName());
229 __ Move(LoadDescriptor::NameRegister(), name); 234 __ Move(LoadDescriptor::NameRegister(), name);
230 235
231 EmitLoadSlot(LoadDescriptor::SlotRegister(), slot); 236 EmitLoadSlot(LoadDescriptor::SlotRegister(), slot);
232 237
233 Handle<Code> ic = CodeFactory::LoadIC(isolate()).code(); 238 Handle<Code> code = CodeFactory::LoadIC(isolate()).code();
234 CallIC(ic, id); 239 __ Call(code, RelocInfo::CODE_TARGET);
235 if (FLAG_tf_load_ic_stub) RestoreContext(); 240 if (FLAG_tf_load_ic_stub) RestoreContext();
236 } 241 }
237 242
238 void FullCodeGenerator::CallStoreIC(FeedbackVectorSlot slot, 243 void FullCodeGenerator::CallStoreIC(FeedbackVectorSlot slot,
239 Handle<Object> name, TypeFeedbackId id) { 244 Handle<Object> name) {
240 DCHECK(name->IsName()); 245 DCHECK(name->IsName());
241 __ Move(StoreDescriptor::NameRegister(), name); 246 __ Move(StoreDescriptor::NameRegister(), name);
242 247
243 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack || 248 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack ||
244 StoreDescriptor::kStackArgumentsCount == 2); 249 StoreDescriptor::kStackArgumentsCount == 2);
245 if (StoreDescriptor::kPassLastArgsOnStack) { 250 if (StoreDescriptor::kPassLastArgsOnStack) {
246 __ Push(StoreDescriptor::ValueRegister()); 251 __ Push(StoreDescriptor::ValueRegister());
247 EmitPushSlot(slot); 252 EmitPushSlot(slot);
248 } else { 253 } else {
249 EmitLoadSlot(StoreDescriptor::SlotRegister(), slot); 254 EmitLoadSlot(StoreDescriptor::SlotRegister(), slot);
250 } 255 }
251 256
252 Handle<Code> ic = CodeFactory::StoreIC(isolate(), language_mode()).code(); 257 Handle<Code> code = CodeFactory::StoreIC(isolate(), language_mode()).code();
253 CallIC(ic, id); 258 __ Call(code, RelocInfo::CODE_TARGET);
254 RestoreContext(); 259 RestoreContext();
255 } 260 }
256 261
257 void FullCodeGenerator::CallKeyedStoreIC(FeedbackVectorSlot slot) { 262 void FullCodeGenerator::CallKeyedStoreIC(FeedbackVectorSlot slot) {
258 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack || 263 STATIC_ASSERT(!StoreDescriptor::kPassLastArgsOnStack ||
259 StoreDescriptor::kStackArgumentsCount == 2); 264 StoreDescriptor::kStackArgumentsCount == 2);
260 if (StoreDescriptor::kPassLastArgsOnStack) { 265 if (StoreDescriptor::kPassLastArgsOnStack) {
261 __ Push(StoreDescriptor::ValueRegister()); 266 __ Push(StoreDescriptor::ValueRegister());
262 EmitPushSlot(slot); 267 EmitPushSlot(slot);
263 } else { 268 } else {
264 EmitLoadSlot(StoreDescriptor::SlotRegister(), slot); 269 EmitLoadSlot(StoreDescriptor::SlotRegister(), slot);
265 } 270 }
266 271
267 Handle<Code> ic = 272 Handle<Code> code =
268 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); 273 CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
269 CallIC(ic); 274 __ Call(code, RelocInfo::CODE_TARGET);
270 RestoreContext(); 275 RestoreContext();
271 } 276 }
272 277
273 void FullCodeGenerator::RecordJSReturnSite(Call* call) { 278 void FullCodeGenerator::RecordJSReturnSite(Call* call) {
274 // We record the offset of the function return so we can rebuild the frame 279 // 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 280 // if the function was inlined, i.e., this is the return address in the
276 // inlined function's frame. 281 // inlined function's frame.
277 // 282 //
278 // The bailout state is ignored. We defensively set it to TOS_REGISTER, which 283 // The bailout state is ignored. We defensively set it to TOS_REGISTER, which
279 // is the real state of the unoptimized code at the return site. 284 // is the real state of the unoptimized code at the return site.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 501
497 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, 502 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy,
498 TypeofMode typeof_mode) { 503 TypeofMode typeof_mode) {
499 #ifdef DEBUG 504 #ifdef DEBUG
500 Variable* var = proxy->var(); 505 Variable* var = proxy->var();
501 DCHECK(var->IsUnallocated() || 506 DCHECK(var->IsUnallocated() ||
502 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); 507 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL));
503 #endif 508 #endif
504 EmitLoadSlot(LoadGlobalDescriptor::SlotRegister(), 509 EmitLoadSlot(LoadGlobalDescriptor::SlotRegister(),
505 proxy->VariableFeedbackSlot()); 510 proxy->VariableFeedbackSlot());
506 Handle<Code> ic = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code(); 511 Handle<Code> code = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code();
507 CallIC(ic); 512 __ Call(code, RelocInfo::CODE_TARGET);
508 } 513 }
509 514
510 void FullCodeGenerator::VisitSloppyBlockFunctionStatement( 515 void FullCodeGenerator::VisitSloppyBlockFunctionStatement(
511 SloppyBlockFunctionStatement* declaration) { 516 SloppyBlockFunctionStatement* declaration) {
512 Visit(declaration->statement()); 517 Visit(declaration->statement());
513 } 518 }
514 519
515 520
516 int FullCodeGenerator::DeclareGlobalsFlags() { 521 int FullCodeGenerator::DeclareGlobalsFlags() {
517 return info_->GetDeclareGlobalsFlags(); 522 return info_->GetDeclareGlobalsFlags();
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 1120
1116 PushOperand(key->value()); 1121 PushOperand(key->value());
1117 CallRuntimeWithOperands(Runtime::kLoadFromSuper); 1122 CallRuntimeWithOperands(Runtime::kLoadFromSuper);
1118 } 1123 }
1119 1124
1120 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 1125 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
1121 SetExpressionPosition(prop); 1126 SetExpressionPosition(prop);
1122 1127
1123 EmitLoadSlot(LoadDescriptor::SlotRegister(), prop->PropertyFeedbackSlot()); 1128 EmitLoadSlot(LoadDescriptor::SlotRegister(), prop->PropertyFeedbackSlot());
1124 1129
1125 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); 1130 Handle<Code> code = CodeFactory::KeyedLoadIC(isolate()).code();
1126 CallIC(ic); 1131 __ Call(code, RelocInfo::CODE_TARGET);
1127 RestoreContext(); 1132 RestoreContext();
1128 } 1133 }
1129 1134
1130 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { 1135 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) {
1131 // Stack: receiver, home_object, key. 1136 // Stack: receiver, home_object, key.
1132 SetExpressionPosition(prop); 1137 SetExpressionPosition(prop);
1133 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); 1138 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper);
1134 } 1139 }
1135 1140
1136 void FullCodeGenerator::EmitPropertyKey(LiteralProperty* property, 1141 void FullCodeGenerator::EmitPropertyKey(LiteralProperty* property,
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 return info_->has_simple_parameters(); 1993 return info_->has_simple_parameters();
1989 } 1994 }
1990 1995
1991 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } 1996 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); }
1992 1997
1993 #undef __ 1998 #undef __
1994 1999
1995 2000
1996 } // namespace internal 2001 } // namespace internal
1997 } // namespace v8 2002 } // 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