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

Side by Side Diff: src/ast.h

Issue 1306993003: Call JS functions via native context instead of js builtins object. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
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 #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
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_; } 2034 const Runtime::Function* function() const { return function_; }
2037 ZoneList<Expression*>* arguments() const { return arguments_; } 2035 ZoneList<Expression*>* arguments() const { return arguments_; }
2038 bool is_jsruntime() const { return function_ == NULL; } 2036 bool is_jsruntime() const {
2039 2037 return function_->intrinsic_type == Runtime::CONTEXT;
2040 // Type feedback information.
2041 bool HasCallRuntimeFeedbackSlot() const { return is_jsruntime(); }
2042 virtual FeedbackVectorRequirements ComputeFeedbackRequirements(
2043 Isolate* isolate, const ICSlotCache* cache) override {
2044 return FeedbackVectorRequirements(0, HasCallRuntimeFeedbackSlot() ? 1 : 0);
2045 }
2046 void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot,
2047 ICSlotCache* cache) override {
2048 callruntime_feedback_slot_ = slot;
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 } 2038 }
2057 2039
2058 static int num_ids() { return parent_num_ids() + 1; } 2040 static int num_ids() { return parent_num_ids() + 1; }
2059 BailoutId CallId() { return BailoutId(local_id(0)); } 2041 BailoutId CallId() { return BailoutId(local_id(0)); }
2060 2042
2061 protected: 2043 protected:
2062 CallRuntime(Zone* zone, const AstRawString* name, 2044 CallRuntime(Zone* zone, const Runtime::Function* function,
2063 const Runtime::Function* function,
2064 ZoneList<Expression*>* arguments, int pos) 2045 ZoneList<Expression*>* arguments, int pos)
2065 : Expression(zone, pos), 2046 : Expression(zone, pos), function_(function), arguments_(arguments) {}
2066 raw_name_(name),
2067 function_(function),
2068 arguments_(arguments),
2069 callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {}
2070 static int parent_num_ids() { return Expression::num_ids(); } 2047 static int parent_num_ids() { return Expression::num_ids(); }
2071 2048
2072 private: 2049 private:
2073 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2050 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2074 2051
2075 const AstRawString* raw_name_;
2076 const Runtime::Function* function_; 2052 const Runtime::Function* function_;
Michael Starzinger 2015/08/25 18:12:09 If below comment is addressed then we would need t
2077 ZoneList<Expression*>* arguments_; 2053 ZoneList<Expression*>* arguments_;
2078 FeedbackVectorICSlot callruntime_feedback_slot_;
2079 }; 2054 };
2080 2055
2081 2056
2082 class UnaryOperation final : public Expression { 2057 class UnaryOperation final : public Expression {
2083 public: 2058 public:
2084 DECLARE_NODE_TYPE(UnaryOperation) 2059 DECLARE_NODE_TYPE(UnaryOperation)
2085 2060
2086 Token::Value op() const { return op_; } 2061 Token::Value op() const { return op_; }
2087 Expression* expression() const { return expression_; } 2062 Expression* expression() const { return expression_; }
2088 2063
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
3502 int pos) { 3477 int pos) {
3503 return new (zone_) Call(zone_, expression, arguments, pos); 3478 return new (zone_) Call(zone_, expression, arguments, pos);
3504 } 3479 }
3505 3480
3506 CallNew* NewCallNew(Expression* expression, 3481 CallNew* NewCallNew(Expression* expression,
3507 ZoneList<Expression*>* arguments, 3482 ZoneList<Expression*>* arguments,
3508 int pos) { 3483 int pos) {
3509 return new (zone_) CallNew(zone_, expression, arguments, pos); 3484 return new (zone_) CallNew(zone_, expression, arguments, pos);
3510 } 3485 }
3511 3486
3512 CallRuntime* NewCallRuntime(const AstRawString* name, 3487 CallRuntime* NewCallRuntime(Runtime::FunctionId id,
3513 const Runtime::Function* function, 3488 ZoneList<Expression*>* arguments, int pos) {
3514 ZoneList<Expression*>* arguments, 3489 return new (zone_)
3515 int pos) { 3490 CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos);
3516 return new (zone_) CallRuntime(zone_, name, function, arguments, pos); 3491 }
3492
3493 CallRuntime* NewCallRuntime(const Runtime::Function* function,
3494 ZoneList<Expression*>* arguments, int pos) {
3495 return new (zone_) CallRuntime(zone_, function, arguments, pos);
3517 } 3496 }
3518 3497
3519 UnaryOperation* NewUnaryOperation(Token::Value op, 3498 UnaryOperation* NewUnaryOperation(Token::Value op,
3520 Expression* expression, 3499 Expression* expression,
3521 int pos) { 3500 int pos) {
3522 return new (zone_) UnaryOperation(zone_, op, expression, pos); 3501 return new (zone_) UnaryOperation(zone_, op, expression, pos);
3523 } 3502 }
3524 3503
3525 BinaryOperation* NewBinaryOperation(Token::Value op, 3504 BinaryOperation* NewBinaryOperation(Token::Value op,
3526 Expression* left, 3505 Expression* left,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 3614
3636 private: 3615 private:
3637 Zone* zone_; 3616 Zone* zone_;
3638 AstValueFactory* ast_value_factory_; 3617 AstValueFactory* ast_value_factory_;
3639 }; 3618 };
3640 3619
3641 3620
3642 } } // namespace v8::internal 3621 } } // namespace v8::internal
3643 3622
3644 #endif // V8_AST_H_ 3623 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « src/assembler.cc ('k') | src/ast-value-factory.h » ('j') | src/runtime/runtime.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698