| 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 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 | 2024 |
| 2025 | 2025 |
| 2026 // The CallRuntime class does not represent any official JavaScript | 2026 // The CallRuntime class does not represent any official JavaScript |
| 2027 // language construct. Instead it is used to call a C or JS function | 2027 // language construct. Instead it is used to call a C or JS function |
| 2028 // with a set of arguments. This is used from the builtins that are | 2028 // with a set of arguments. This is used from the builtins that are |
| 2029 // implemented in JavaScript (see "v8natives.js"). | 2029 // implemented in JavaScript (see "v8natives.js"). |
| 2030 class CallRuntime final : public Expression { | 2030 class CallRuntime final : public Expression { |
| 2031 public: | 2031 public: |
| 2032 DECLARE_NODE_TYPE(CallRuntime) | 2032 DECLARE_NODE_TYPE(CallRuntime) |
| 2033 | 2033 |
| 2034 Handle<String> name() const { return raw_name_->string(); } | |
| 2035 const AstRawString* raw_name() const { return raw_name_; } | |
| 2036 const Runtime::Function* function() const { return function_; } | |
| 2037 ZoneList<Expression*>* arguments() const { return arguments_; } | 2034 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 2038 bool is_jsruntime() const { return function_ == NULL; } | 2035 bool is_jsruntime() const { return function_ == NULL; } |
| 2039 | 2036 |
| 2040 // Type feedback information. | 2037 int context_index() const { |
| 2041 bool HasCallRuntimeFeedbackSlot() const { return is_jsruntime(); } | 2038 DCHECK(is_jsruntime()); |
| 2042 virtual FeedbackVectorRequirements ComputeFeedbackRequirements( | 2039 return context_index_; |
| 2043 Isolate* isolate, const ICSlotCache* cache) override { | |
| 2044 return FeedbackVectorRequirements(0, HasCallRuntimeFeedbackSlot() ? 1 : 0); | |
| 2045 } | 2040 } |
| 2046 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, | 2041 const Runtime::Function* function() const { |
| 2047 ICSlotCache* cache) override { | 2042 DCHECK(!is_jsruntime()); |
| 2048 callruntime_feedback_slot_ = slot; | 2043 return function_; |
| 2049 } | |
| 2050 Code::Kind FeedbackICSlotKind(int index) override { return Code::LOAD_IC; } | |
| 2051 | |
| 2052 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { | |
| 2053 DCHECK(!HasCallRuntimeFeedbackSlot() || | |
| 2054 !callruntime_feedback_slot_.IsInvalid()); | |
| 2055 return callruntime_feedback_slot_; | |
| 2056 } | 2044 } |
| 2057 | 2045 |
| 2058 static int num_ids() { return parent_num_ids() + 1; } | 2046 static int num_ids() { return parent_num_ids() + 1; } |
| 2059 BailoutId CallId() { return BailoutId(local_id(0)); } | 2047 BailoutId CallId() { return BailoutId(local_id(0)); } |
| 2060 | 2048 |
| 2061 protected: | 2049 protected: |
| 2062 CallRuntime(Zone* zone, const AstRawString* name, | 2050 CallRuntime(Zone* zone, const Runtime::Function* function, |
| 2063 const Runtime::Function* function, | |
| 2064 ZoneList<Expression*>* arguments, int pos) | 2051 ZoneList<Expression*>* arguments, int pos) |
| 2052 : Expression(zone, pos), function_(function), arguments_(arguments) {} |
| 2053 |
| 2054 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments, |
| 2055 int pos) |
| 2065 : Expression(zone, pos), | 2056 : Expression(zone, pos), |
| 2066 raw_name_(name), | 2057 function_(NULL), |
| 2067 function_(function), | 2058 context_index_(context_index), |
| 2068 arguments_(arguments), | 2059 arguments_(arguments) {} |
| 2069 callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} | 2060 |
| 2070 static int parent_num_ids() { return Expression::num_ids(); } | 2061 static int parent_num_ids() { return Expression::num_ids(); } |
| 2071 | 2062 |
| 2072 private: | 2063 private: |
| 2073 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2064 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2074 | 2065 |
| 2075 const AstRawString* raw_name_; | |
| 2076 const Runtime::Function* function_; | 2066 const Runtime::Function* function_; |
| 2067 int context_index_; |
| 2077 ZoneList<Expression*>* arguments_; | 2068 ZoneList<Expression*>* arguments_; |
| 2078 FeedbackVectorICSlot callruntime_feedback_slot_; | |
| 2079 }; | 2069 }; |
| 2080 | 2070 |
| 2081 | 2071 |
| 2082 class UnaryOperation final : public Expression { | 2072 class UnaryOperation final : public Expression { |
| 2083 public: | 2073 public: |
| 2084 DECLARE_NODE_TYPE(UnaryOperation) | 2074 DECLARE_NODE_TYPE(UnaryOperation) |
| 2085 | 2075 |
| 2086 Token::Value op() const { return op_; } | 2076 Token::Value op() const { return op_; } |
| 2087 Expression* expression() const { return expression_; } | 2077 Expression* expression() const { return expression_; } |
| 2088 | 2078 |
| (...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3502 int pos) { | 3492 int pos) { |
| 3503 return new (zone_) Call(zone_, expression, arguments, pos); | 3493 return new (zone_) Call(zone_, expression, arguments, pos); |
| 3504 } | 3494 } |
| 3505 | 3495 |
| 3506 CallNew* NewCallNew(Expression* expression, | 3496 CallNew* NewCallNew(Expression* expression, |
| 3507 ZoneList<Expression*>* arguments, | 3497 ZoneList<Expression*>* arguments, |
| 3508 int pos) { | 3498 int pos) { |
| 3509 return new (zone_) CallNew(zone_, expression, arguments, pos); | 3499 return new (zone_) CallNew(zone_, expression, arguments, pos); |
| 3510 } | 3500 } |
| 3511 | 3501 |
| 3512 CallRuntime* NewCallRuntime(const AstRawString* name, | 3502 CallRuntime* NewCallRuntime(Runtime::FunctionId id, |
| 3513 const Runtime::Function* function, | 3503 ZoneList<Expression*>* arguments, int pos) { |
| 3514 ZoneList<Expression*>* arguments, | 3504 return new (zone_) |
| 3515 int pos) { | 3505 CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos); |
| 3516 return new (zone_) CallRuntime(zone_, name, function, arguments, pos); | 3506 } |
| 3507 |
| 3508 CallRuntime* NewCallRuntime(const Runtime::Function* function, |
| 3509 ZoneList<Expression*>* arguments, int pos) { |
| 3510 return new (zone_) CallRuntime(zone_, function, arguments, pos); |
| 3511 } |
| 3512 |
| 3513 CallRuntime* NewCallRuntime(int context_index, |
| 3514 ZoneList<Expression*>* arguments, int pos) { |
| 3515 return new (zone_) CallRuntime(zone_, context_index, arguments, pos); |
| 3517 } | 3516 } |
| 3518 | 3517 |
| 3519 UnaryOperation* NewUnaryOperation(Token::Value op, | 3518 UnaryOperation* NewUnaryOperation(Token::Value op, |
| 3520 Expression* expression, | 3519 Expression* expression, |
| 3521 int pos) { | 3520 int pos) { |
| 3522 return new (zone_) UnaryOperation(zone_, op, expression, pos); | 3521 return new (zone_) UnaryOperation(zone_, op, expression, pos); |
| 3523 } | 3522 } |
| 3524 | 3523 |
| 3525 BinaryOperation* NewBinaryOperation(Token::Value op, | 3524 BinaryOperation* NewBinaryOperation(Token::Value op, |
| 3526 Expression* left, | 3525 Expression* left, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3635 | 3634 |
| 3636 private: | 3635 private: |
| 3637 Zone* zone_; | 3636 Zone* zone_; |
| 3638 AstValueFactory* ast_value_factory_; | 3637 AstValueFactory* ast_value_factory_; |
| 3639 }; | 3638 }; |
| 3640 | 3639 |
| 3641 | 3640 |
| 3642 } } // namespace v8::internal | 3641 } } // namespace v8::internal |
| 3643 | 3642 |
| 3644 #endif // V8_AST_H_ | 3643 #endif // V8_AST_H_ |
| OLD | NEW |