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 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 | 2025 |
2026 | 2026 |
2027 // The CallRuntime class does not represent any official JavaScript | 2027 // The CallRuntime class does not represent any official JavaScript |
2028 // language construct. Instead it is used to call a C or JS function | 2028 // language construct. Instead it is used to call a C or JS function |
2029 // with a set of arguments. This is used from the builtins that are | 2029 // with a set of arguments. This is used from the builtins that are |
2030 // implemented in JavaScript (see "v8natives.js"). | 2030 // implemented in JavaScript (see "v8natives.js"). |
2031 class CallRuntime final : public Expression { | 2031 class CallRuntime final : public Expression { |
2032 public: | 2032 public: |
2033 DECLARE_NODE_TYPE(CallRuntime) | 2033 DECLARE_NODE_TYPE(CallRuntime) |
2034 | 2034 |
2035 Handle<String> name() const { return raw_name_->string(); } | |
2036 const AstRawString* raw_name() const { return raw_name_; } | |
2037 const Runtime::Function* function() const { return function_; } | |
2038 ZoneList<Expression*>* arguments() const { return arguments_; } | 2035 ZoneList<Expression*>* arguments() const { return arguments_; } |
2039 bool is_jsruntime() const { return function_ == NULL; } | 2036 bool is_jsruntime() const { return function_ == NULL; } |
2040 | 2037 |
2041 // Type feedback information. | 2038 int context_index() const { |
2042 bool HasCallRuntimeFeedbackSlot() const { return is_jsruntime(); } | 2039 DCHECK(is_jsruntime()); |
2043 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( | 2040 return context_index_; |
2044 Isolate* isolate, const ICSlotCache* cache) override { | |
2045 return FeedbackVectorRequirements(0, HasCallRuntimeFeedbackSlot() ? 1 : 0); | |
2046 } | 2041 } |
2047 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, | 2042 const Runtime::Function* function() const { |
2048 ICSlotCache* cache) override { | 2043 DCHECK(!is_jsruntime()); |
2049 callruntime_feedback_slot_ = slot; | 2044 return function_; |
2050 } | |
2051 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; } | |
2052 | |
2053 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { | |
2054 DCHECK(!HasCallRuntimeFeedbackSlot() || | |
2055 !callruntime_feedback_slot_.IsInvalid()); | |
2056 return callruntime_feedback_slot_; | |
2057 } | 2045 } |
2058 | 2046 |
2059 static int num_ids() { return parent_num_ids() + 1; } | 2047 static int num_ids() { return parent_num_ids() + 1; } |
2060 BailoutId CallId() { return BailoutId(local_id(0)); } | 2048 BailoutId CallId() { return BailoutId(local_id(0)); } |
2061 | 2049 |
| 2050 const char* debug_name() { |
| 2051 return is_jsruntime() ? "(context function)" : function_->name; |
| 2052 } |
| 2053 |
2062 protected: | 2054 protected: |
2063 CallRuntime(Zone* zone, const AstRawString* name, | 2055 CallRuntime(Zone* zone, const Runtime::Function* function, |
2064 const Runtime::Function* function, | |
2065 ZoneList<Expression*>* arguments, int pos) | 2056 ZoneList<Expression*>* arguments, int pos) |
| 2057 : Expression(zone, pos), function_(function), arguments_(arguments) {} |
| 2058 |
| 2059 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments, |
| 2060 int pos) |
2066 : Expression(zone, pos), | 2061 : Expression(zone, pos), |
2067 raw_name_(name), | 2062 function_(NULL), |
2068 function_(function), | 2063 context_index_(context_index), |
2069 arguments_(arguments), | 2064 arguments_(arguments) {} |
2070 callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} | 2065 |
2071 static int parent_num_ids() { return Expression::num_ids(); } | 2066 static int parent_num_ids() { return Expression::num_ids(); } |
2072 | 2067 |
2073 private: | 2068 private: |
2074 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2069 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2075 | 2070 |
2076 const AstRawString* raw_name_; | |
2077 const Runtime::Function* function_; | 2071 const Runtime::Function* function_; |
| 2072 int context_index_; |
2078 ZoneList<Expression*>* arguments_; | 2073 ZoneList<Expression*>* arguments_; |
2079 FeedbackVectorICSlot callruntime_feedback_slot_; | |
2080 }; | 2074 }; |
2081 | 2075 |
2082 | 2076 |
2083 class UnaryOperation final : public Expression { | 2077 class UnaryOperation final : public Expression { |
2084 public: | 2078 public: |
2085 DECLARE_NODE_TYPE(UnaryOperation) | 2079 DECLARE_NODE_TYPE(UnaryOperation) |
2086 | 2080 |
2087 Token::Value op() const { return op_; } | 2081 Token::Value op() const { return op_; } |
2088 Expression* expression() const { return expression_; } | 2082 Expression* expression() const { return expression_; } |
2089 | 2083 |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3514 int pos) { | 3508 int pos) { |
3515 return new (zone_) Call(zone_, expression, arguments, pos); | 3509 return new (zone_) Call(zone_, expression, arguments, pos); |
3516 } | 3510 } |
3517 | 3511 |
3518 CallNew* NewCallNew(Expression* expression, | 3512 CallNew* NewCallNew(Expression* expression, |
3519 ZoneList<Expression*>* arguments, | 3513 ZoneList<Expression*>* arguments, |
3520 int pos) { | 3514 int pos) { |
3521 return new (zone_) CallNew(zone_, expression, arguments, pos); | 3515 return new (zone_) CallNew(zone_, expression, arguments, pos); |
3522 } | 3516 } |
3523 | 3517 |
3524 CallRuntime* NewCallRuntime(const AstRawString* name, | 3518 CallRuntime* NewCallRuntime(Runtime::FunctionId id, |
3525 const Runtime::Function* function, | 3519 ZoneList<Expression*>* arguments, int pos) { |
3526 ZoneList<Expression*>* arguments, | 3520 return new (zone_) |
3527 int pos) { | 3521 CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos); |
3528 return new (zone_) CallRuntime(zone_, name, function, arguments, pos); | 3522 } |
| 3523 |
| 3524 CallRuntime* NewCallRuntime(const Runtime::Function* function, |
| 3525 ZoneList<Expression*>* arguments, int pos) { |
| 3526 return new (zone_) CallRuntime(zone_, function, arguments, pos); |
| 3527 } |
| 3528 |
| 3529 CallRuntime* NewCallRuntime(int context_index, |
| 3530 ZoneList<Expression*>* arguments, int pos) { |
| 3531 return new (zone_) CallRuntime(zone_, context_index, arguments, pos); |
3529 } | 3532 } |
3530 | 3533 |
3531 UnaryOperation* NewUnaryOperation(Token::Value op, | 3534 UnaryOperation* NewUnaryOperation(Token::Value op, |
3532 Expression* expression, | 3535 Expression* expression, |
3533 int pos) { | 3536 int pos) { |
3534 return new (zone_) UnaryOperation(zone_, op, expression, pos); | 3537 return new (zone_) UnaryOperation(zone_, op, expression, pos); |
3535 } | 3538 } |
3536 | 3539 |
3537 BinaryOperation* NewBinaryOperation(Token::Value op, | 3540 BinaryOperation* NewBinaryOperation(Token::Value op, |
3538 Expression* left, | 3541 Expression* left, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3651 | 3654 |
3652 private: | 3655 private: |
3653 Zone* zone_; | 3656 Zone* zone_; |
3654 AstValueFactory* ast_value_factory_; | 3657 AstValueFactory* ast_value_factory_; |
3655 }; | 3658 }; |
3656 | 3659 |
3657 | 3660 |
3658 } } // namespace v8::internal | 3661 } } // namespace v8::internal |
3659 | 3662 |
3660 #endif // V8_AST_H_ | 3663 #endif // V8_AST_H_ |
OLD | NEW |