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

Side by Side Diff: src/compiler/js-operator.cc

Issue 1466643002: [turbofan] Initial support for Array constructor specialization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/js-operator.h" 5 #include "src/compiler/js-operator.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/lazy-instance.h" 9 #include "src/base/lazy-instance.h"
10 #include "src/compiler/opcodes.h" 10 #include "src/compiler/opcodes.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 case TailCallMode::kAllow: 56 case TailCallMode::kAllow:
57 return os << "ALLOW_TAIL_CALLS"; 57 return os << "ALLOW_TAIL_CALLS";
58 case TailCallMode::kDisallow: 58 case TailCallMode::kDisallow:
59 return os << "DISALLOW_TAIL_CALLS"; 59 return os << "DISALLOW_TAIL_CALLS";
60 } 60 }
61 UNREACHABLE(); 61 UNREACHABLE();
62 return os; 62 return os;
63 } 63 }
64 64
65 65
66 bool operator==(CallConstructParameters const& lhs,
67 CallConstructParameters const& rhs) {
68 return lhs.arity() == rhs.arity() && lhs.feedback() == rhs.feedback();
69 }
70
71
72 bool operator!=(CallConstructParameters const& lhs,
73 CallConstructParameters const& rhs) {
74 return !(lhs == rhs);
75 }
76
77
78 size_t hash_value(CallConstructParameters const& p) {
79 return base::hash_combine(p.arity(), p.feedback());
80 }
81
82
83 std::ostream& operator<<(std::ostream& os, CallConstructParameters const& p) {
84 return os << p.arity();
85 }
86
87
88 CallConstructParameters const& CallConstructParametersOf(Operator const* op) {
89 DCHECK_EQ(IrOpcode::kJSCallConstruct, op->opcode());
90 return OpParameter<CallConstructParameters>(op);
91 }
92
93
66 std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) { 94 std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) {
67 os << p.arity() << ", " << p.language_mode() << ", " << p.convert_mode() 95 os << p.arity() << ", " << p.language_mode() << ", " << p.convert_mode()
68 << ", " << p.tail_call_mode(); 96 << ", " << p.tail_call_mode();
69 return os; 97 return os;
70 } 98 }
71 99
72 100
73 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { 101 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) {
74 DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode()); 102 DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode());
75 return OpParameter<CallFunctionParameters>(op); 103 return OpParameter<CallFunctionParameters>(op);
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 343 }
316 344
317 345
318 const CreateArgumentsParameters& CreateArgumentsParametersOf( 346 const CreateArgumentsParameters& CreateArgumentsParametersOf(
319 const Operator* op) { 347 const Operator* op) {
320 DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode()); 348 DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode());
321 return OpParameter<CreateArgumentsParameters>(op); 349 return OpParameter<CreateArgumentsParameters>(op);
322 } 350 }
323 351
324 352
353 bool operator==(CreateArrayParameters const& lhs,
354 CreateArrayParameters const& rhs) {
355 return lhs.arity() == rhs.arity() &&
356 lhs.site().location() == rhs.site().location();
357 }
358
359
360 bool operator!=(CreateArrayParameters const& lhs,
361 CreateArrayParameters const& rhs) {
362 return !(lhs == rhs);
363 }
364
365
366 size_t hash_value(CreateArrayParameters const& p) {
367 return base::hash_combine(p.arity(), p.site().location());
368 }
369
370
371 std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) {
372 os << p.arity();
373 Handle<AllocationSite> site;
374 if (p.site().ToHandle(&site)) os << ", " << Brief(*site);
375 return os;
376 }
377
378
379 const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) {
380 DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode());
381 return OpParameter<CreateArrayParameters>(op);
382 }
383
384
325 bool operator==(CreateClosureParameters const& lhs, 385 bool operator==(CreateClosureParameters const& lhs,
326 CreateClosureParameters const& rhs) { 386 CreateClosureParameters const& rhs) {
327 return lhs.pretenure() == rhs.pretenure() && 387 return lhs.pretenure() == rhs.pretenure() &&
328 lhs.shared_info().location() == rhs.shared_info().location(); 388 lhs.shared_info().location() == rhs.shared_info().location();
329 } 389 }
330 390
331 391
332 bool operator!=(CreateClosureParameters const& lhs, 392 bool operator!=(CreateClosureParameters const& lhs,
333 CreateClosureParameters const& rhs) { 393 CreateClosureParameters const& rhs) {
334 return !(lhs == rhs); 394 return !(lhs == rhs);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 V(HasProperty, Operator::kNoProperties, 2, 1) \ 427 V(HasProperty, Operator::kNoProperties, 2, 1) \
368 V(TypeOf, Operator::kEliminatable, 1, 1) \ 428 V(TypeOf, Operator::kEliminatable, 1, 1) \
369 V(InstanceOf, Operator::kNoProperties, 2, 1) \ 429 V(InstanceOf, Operator::kNoProperties, 2, 1) \
370 V(ForInDone, Operator::kPure, 2, 1) \ 430 V(ForInDone, Operator::kPure, 2, 1) \
371 V(ForInNext, Operator::kNoProperties, 4, 1) \ 431 V(ForInNext, Operator::kNoProperties, 4, 1) \
372 V(ForInPrepare, Operator::kNoProperties, 1, 3) \ 432 V(ForInPrepare, Operator::kNoProperties, 1, 3) \
373 V(ForInStep, Operator::kPure, 1, 1) \ 433 V(ForInStep, Operator::kPure, 1, 1) \
374 V(LoadMessage, Operator::kNoThrow, 0, 1) \ 434 V(LoadMessage, Operator::kNoThrow, 0, 1) \
375 V(StoreMessage, Operator::kNoThrow, 1, 0) \ 435 V(StoreMessage, Operator::kNoThrow, 1, 0) \
376 V(StackCheck, Operator::kNoProperties, 0, 0) \ 436 V(StackCheck, Operator::kNoProperties, 0, 0) \
437 V(LoadNativeContext, Operator::kEliminatable, 1, 1) \
377 V(CreateWithContext, Operator::kNoProperties, 2, 1) \ 438 V(CreateWithContext, Operator::kNoProperties, 2, 1) \
378 V(CreateModuleContext, Operator::kNoProperties, 2, 1) 439 V(CreateModuleContext, Operator::kNoProperties, 2, 1)
379 440
380 441
381 #define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \ 442 #define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \
382 V(LessThan, Operator::kNoProperties, 2, 1) \ 443 V(LessThan, Operator::kNoProperties, 2, 1) \
383 V(GreaterThan, Operator::kNoProperties, 2, 1) \ 444 V(GreaterThan, Operator::kNoProperties, 2, 1) \
384 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ 445 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
385 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ 446 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \
386 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ 447 V(BitwiseOr, Operator::kNoProperties, 2, 1) \
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 const Runtime::Function* f = Runtime::FunctionForId(parameters.id()); 547 const Runtime::Function* f = Runtime::FunctionForId(parameters.id());
487 DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity())); 548 DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity()));
488 return new (zone()) Operator1<CallRuntimeParameters>( // -- 549 return new (zone()) Operator1<CallRuntimeParameters>( // --
489 IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode 550 IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode
490 "JSCallRuntime", // name 551 "JSCallRuntime", // name
491 parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs 552 parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs
492 parameters); // parameter 553 parameters); // parameter
493 } 554 }
494 555
495 556
496 const Operator* JSOperatorBuilder::CallConstruct(int arguments) { 557 const Operator* JSOperatorBuilder::CallConstruct(
497 return new (zone()) Operator1<int>( // -- 558 size_t arity, VectorSlotPair const& feedback) {
559 CallConstructParameters parameters(arity, feedback);
560 return new (zone()) Operator1<CallConstructParameters>( // --
498 IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode 561 IrOpcode::kJSCallConstruct, Operator::kNoProperties, // opcode
499 "JSCallConstruct", // name 562 "JSCallConstruct", // name
500 arguments, 1, 1, 1, 1, 2, // counts 563 parameters.arity(), 1, 1, 1, 1, 2, // counts
501 arguments); // parameter 564 parameters); // parameter
502 } 565 }
503 566
504 567
505 const Operator* JSOperatorBuilder::ConvertReceiver( 568 const Operator* JSOperatorBuilder::ConvertReceiver(
506 ConvertReceiverMode convert_mode) { 569 ConvertReceiverMode convert_mode) {
507 return new (zone()) Operator1<ConvertReceiverMode>( // -- 570 return new (zone()) Operator1<ConvertReceiverMode>( // --
508 IrOpcode::kJSConvertReceiver, Operator::kNoThrow, // opcode 571 IrOpcode::kJSConvertReceiver, Operator::kNoThrow, // opcode
509 "JSConvertReceiver", // name 572 "JSConvertReceiver", // name
510 1, 1, 1, 1, 1, 0, // counts 573 1, 1, 1, 1, 1, 0, // counts
511 convert_mode); // parameter 574 convert_mode); // parameter
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 DCHECK_IMPLIES(start_index, type == CreateArgumentsParameters::kRestArray); 693 DCHECK_IMPLIES(start_index, type == CreateArgumentsParameters::kRestArray);
631 CreateArgumentsParameters parameters(type, start_index); 694 CreateArgumentsParameters parameters(type, start_index);
632 return new (zone()) Operator1<CreateArgumentsParameters>( // -- 695 return new (zone()) Operator1<CreateArgumentsParameters>( // --
633 IrOpcode::kJSCreateArguments, Operator::kNoThrow, // opcode 696 IrOpcode::kJSCreateArguments, Operator::kNoThrow, // opcode
634 "JSCreateArguments", // name 697 "JSCreateArguments", // name
635 1, 1, 1, 1, 1, 0, // counts 698 1, 1, 1, 1, 1, 0, // counts
636 parameters); // parameter 699 parameters); // parameter
637 } 700 }
638 701
639 702
703 const Operator* JSOperatorBuilder::CreateArray(
704 size_t arity, MaybeHandle<AllocationSite> site) {
705 // constructor, new_target, arg1, ..., argN
706 int const value_input_count = static_cast<int>(arity) + 2;
707 CreateArrayParameters parameters(arity, site);
708 return new (zone()) Operator1<CreateArrayParameters>( // --
709 IrOpcode::kJSCreateArray, Operator::kNoProperties, // opcode
710 "JSCreateArray", // name
711 value_input_count, 1, 1, 1, 1, 2, // counts
712 parameters); // parameter
713 }
714
715
640 const Operator* JSOperatorBuilder::CreateClosure( 716 const Operator* JSOperatorBuilder::CreateClosure(
641 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { 717 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) {
642 CreateClosureParameters parameters(shared_info, pretenure); 718 CreateClosureParameters parameters(shared_info, pretenure);
643 return new (zone()) Operator1<CreateClosureParameters>( // -- 719 return new (zone()) Operator1<CreateClosureParameters>( // --
644 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode 720 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode
645 "JSCreateClosure", // name 721 "JSCreateClosure", // name
646 0, 1, 1, 1, 1, 0, // counts 722 0, 1, 1, 1, 1, 0, // counts
647 parameters); // parameter 723 parameters); // parameter
648 } 724 }
649 725
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 return new (zone()) Operator1<Handle<ScopeInfo>>( // -- 776 return new (zone()) Operator1<Handle<ScopeInfo>>( // --
701 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode 777 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode
702 "JSCreateScriptContext", // name 778 "JSCreateScriptContext", // name
703 1, 1, 1, 1, 1, 2, // counts 779 1, 1, 1, 1, 1, 2, // counts
704 scpope_info); // parameter 780 scpope_info); // parameter
705 } 781 }
706 782
707 } // namespace compiler 783 } // namespace compiler
708 } // namespace internal 784 } // namespace internal
709 } // namespace v8 785 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698