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

Side by Side Diff: src/hydrogen.h

Issue 9265004: Support inlining at call-sites with mismatched number of arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: finished implementation, extended tests, ported to x64&arm Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 336
337 Zone* HBasicBlock::zone() { return graph_->zone(); } 337 Zone* HBasicBlock::zone() { return graph_->zone(); }
338 338
339 339
340 class HEnvironment: public ZoneObject { 340 class HEnvironment: public ZoneObject {
341 public: 341 public:
342 HEnvironment(HEnvironment* outer, 342 HEnvironment(HEnvironment* outer,
343 Scope* scope, 343 Scope* scope,
344 Handle<JSFunction> closure); 344 Handle<JSFunction> closure);
345 345
346 bool is_arguments_adaptor() const {
347 return arguments_adaptor_;
348 }
349
350 HEnvironment* DiscardInlined(bool drop_extra) {
351 HEnvironment* outer = outer_->is_arguments_adaptor() ?
352 outer_->outer_ : outer_;
353 if (drop_extra) outer->Drop(1);
354 return outer;
355 }
356
346 // Simple accessors. 357 // Simple accessors.
347 Handle<JSFunction> closure() const { return closure_; } 358 Handle<JSFunction> closure() const { return closure_; }
348 const ZoneList<HValue*>* values() const { return &values_; } 359 const ZoneList<HValue*>* values() const { return &values_; }
349 const ZoneList<int>* assigned_variables() const { 360 const ZoneList<int>* assigned_variables() const {
350 return &assigned_variables_; 361 return &assigned_variables_;
351 } 362 }
352 int parameter_count() const { return parameter_count_; } 363 int parameter_count() const { return parameter_count_; }
353 int specials_count() const { return specials_count_; } 364 int specials_count() const { return specials_count_; }
354 int local_count() const { return local_count_; } 365 int local_count() const { return local_count_; }
355 HEnvironment* outer() const { return outer_; } 366 HEnvironment* outer() const { return outer_; }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 void SetExpressionStackAt(int index_from_top, HValue* value); 431 void SetExpressionStackAt(int index_from_top, HValue* value);
421 432
422 HEnvironment* Copy() const; 433 HEnvironment* Copy() const;
423 HEnvironment* CopyWithoutHistory() const; 434 HEnvironment* CopyWithoutHistory() const;
424 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; 435 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const;
425 436
426 // Create an "inlined version" of this environment, where the original 437 // Create an "inlined version" of this environment, where the original
427 // environment is the outer environment but the top expression stack 438 // environment is the outer environment but the top expression stack
428 // elements are moved to an inner environment as parameters. 439 // elements are moved to an inner environment as parameters.
429 HEnvironment* CopyForInlining(Handle<JSFunction> target, 440 HEnvironment* CopyForInlining(Handle<JSFunction> target,
441 int arguments,
430 FunctionLiteral* function, 442 FunctionLiteral* function,
431 HConstant* undefined, 443 HConstant* undefined,
432 CallKind call_kind) const; 444 CallKind call_kind) const;
433 445
434 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); 446 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other);
435 447
436 void ClearHistory() { 448 void ClearHistory() {
437 pop_count_ = 0; 449 pop_count_ = 0;
438 push_count_ = 0; 450 push_count_ = 0;
439 assigned_variables_.Rewind(0); 451 assigned_variables_.Rewind(0);
440 } 452 }
441 453
442 void SetValueAt(int index, HValue* value) { 454 void SetValueAt(int index, HValue* value) {
443 ASSERT(index < length()); 455 ASSERT(index < length());
444 values_[index] = value; 456 values_[index] = value;
445 } 457 }
446 458
447 void PrintTo(StringStream* stream); 459 void PrintTo(StringStream* stream);
448 void PrintToStd(); 460 void PrintToStd();
449 461
450 private: 462 private:
451 explicit HEnvironment(const HEnvironment* other); 463 explicit HEnvironment(const HEnvironment* other);
452 464
465 // Create an argument adaptor environment.
466 HEnvironment(HEnvironment* outer, Handle<JSFunction> closure, int arguments);
467
468
453 // True if index is included in the expression stack part of the environment. 469 // True if index is included in the expression stack part of the environment.
454 bool HasExpressionAt(int index) const; 470 bool HasExpressionAt(int index) const;
455 471
456 void Initialize(int parameter_count, int local_count, int stack_height); 472 void Initialize(int parameter_count, int local_count, int stack_height);
457 void Initialize(const HEnvironment* other); 473 void Initialize(const HEnvironment* other);
458 474
459 // Map a variable to an environment index. Parameter indices are shifted 475 // Map a variable to an environment index. Parameter indices are shifted
460 // by 1 (receiver is parameter index -1 but environment index 0). 476 // by 1 (receiver is parameter index -1 but environment index 0).
461 // Stack-allocated local indices are shifted by the number of parameters. 477 // Stack-allocated local indices are shifted by the number of parameters.
462 int IndexFor(Variable* variable) const { 478 int IndexFor(Variable* variable) const {
463 ASSERT(variable->IsStackAllocated()); 479 ASSERT(variable->IsStackAllocated());
464 int shift = variable->IsParameter() 480 int shift = variable->IsParameter()
465 ? 1 481 ? 1
466 : parameter_count_ + specials_count_; 482 : parameter_count_ + specials_count_;
467 return variable->index() + shift; 483 return variable->index() + shift;
468 } 484 }
469 485
470 Handle<JSFunction> closure_; 486 Handle<JSFunction> closure_;
471 // Value array [parameters] [specials] [locals] [temporaries]. 487 // Value array [parameters] [specials] [locals] [temporaries].
472 ZoneList<HValue*> values_; 488 ZoneList<HValue*> values_;
473 ZoneList<int> assigned_variables_; 489 ZoneList<int> assigned_variables_;
474 int parameter_count_; 490 int parameter_count_;
475 int specials_count_; 491 int specials_count_;
476 int local_count_; 492 int local_count_;
477 HEnvironment* outer_; 493 HEnvironment* outer_;
478 int pop_count_; 494 int pop_count_;
479 int push_count_; 495 int push_count_;
480 int ast_id_; 496 int ast_id_;
497 bool arguments_adaptor_;
481 }; 498 };
482 499
483 500
484 class HGraphBuilder; 501 class HGraphBuilder;
485 502
486 enum ArgumentsAllowedFlag { 503 enum ArgumentsAllowedFlag {
487 ARGUMENTS_NOT_ALLOWED, 504 ARGUMENTS_NOT_ALLOWED,
488 ARGUMENTS_ALLOWED 505 ARGUMENTS_ALLOWED
489 }; 506 };
490 507
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 const char* filename_; 1269 const char* filename_;
1253 HeapStringAllocator string_allocator_; 1270 HeapStringAllocator string_allocator_;
1254 StringStream trace_; 1271 StringStream trace_;
1255 int indent_; 1272 int indent_;
1256 }; 1273 };
1257 1274
1258 1275
1259 } } // namespace v8::internal 1276 } } // namespace v8::internal
1260 1277
1261 #endif // V8_HYDROGEN_H_ 1278 #endif // V8_HYDROGEN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698