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

Side by Side Diff: src/ast/ast.cc

Issue 2223523002: [Interpreter] Avoid dereferencing handles on BytecodeGenerator for AST operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_const_array
Patch Set: Rebase Created 4 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
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/ast-value-factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/ast/ast.h" 5 #include "src/ast/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 bool Expression::IsSmiLiteral() const { 81 bool Expression::IsSmiLiteral() const {
82 return IsLiteral() && AsLiteral()->value()->IsSmi(); 82 return IsLiteral() && AsLiteral()->value()->IsSmi();
83 } 83 }
84 84
85 85
86 bool Expression::IsStringLiteral() const { 86 bool Expression::IsStringLiteral() const {
87 return IsLiteral() && AsLiteral()->value()->IsString(); 87 return IsLiteral() && AsLiteral()->value()->IsString();
88 } 88 }
89 89
90 bool Expression::IsPropertyName() const { 90 bool Expression::IsPropertyName(HandleDereferenceMode deref_mode) const {
91 return IsLiteral() && AsLiteral()->IsPropertyName(); 91 return IsLiteral() && AsLiteral()->IsPropertyName(deref_mode);
92 } 92 }
93 93
94 bool Expression::IsNullLiteral() const { 94 bool Expression::IsNullLiteral() const {
95 if (!IsLiteral()) return false; 95 if (!IsLiteral()) return false;
96 Handle<Object> value = AsLiteral()->value(); 96 return AsLiteral()->raw_value()->IsNull();
97 return !value->IsSmi() &&
98 value->IsNull(HeapObject::cast(*value)->GetIsolate());
99 } 97 }
100 98
101 bool Expression::IsUndefinedLiteral() const { 99 bool Expression::IsUndefinedLiteral() const {
102 if (IsLiteral()) { 100 if (IsLiteral()) {
103 Handle<Object> value = AsLiteral()->value(); 101 if (AsLiteral()->raw_value()->IsUndefined()) {
104 if (!value->IsSmi() &&
105 value->IsUndefined(HeapObject::cast(*value)->GetIsolate())) {
106 return true; 102 return true;
107 } 103 }
108 } 104 }
109 105
110 const VariableProxy* var_proxy = AsVariableProxy(); 106 const VariableProxy* var_proxy = AsVariableProxy();
111 if (var_proxy == NULL) return false; 107 if (var_proxy == NULL) return false;
112 Variable* var = var_proxy->var(); 108 Variable* var = var_proxy->var();
113 // The global identifier "undefined" is immutable. Everything 109 // The global identifier "undefined" is immutable. Everything
114 // else could be reassigned. 110 // else could be reassigned.
115 return var != NULL && var->IsUnallocatedOrGlobalSlot() && 111 return var != NULL && var->IsUnallocatedOrGlobalSlot() &&
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 return static_cast<const Node*>(this)->IsMonomorphic(); 894 return static_cast<const Node*>(this)->IsMonomorphic();
899 PROPERTY_NODE_LIST(GENERATE_CASE) 895 PROPERTY_NODE_LIST(GENERATE_CASE)
900 CALL_NODE_LIST(GENERATE_CASE) 896 CALL_NODE_LIST(GENERATE_CASE)
901 #undef GENERATE_CASE 897 #undef GENERATE_CASE
902 default: 898 default:
903 UNREACHABLE(); 899 UNREACHABLE();
904 return false; 900 return false;
905 } 901 }
906 } 902 }
907 903
908 bool Call::IsUsingCallFeedbackICSlot(Isolate* isolate) const { 904 bool Call::IsUsingCallFeedbackICSlot(
909 CallType call_type = GetCallType(isolate); 905 Isolate* isolate, HandleDereferenceMode dereference_mode) const {
906 CallType call_type = GetCallType(isolate, dereference_mode);
910 if (call_type == POSSIBLY_EVAL_CALL) { 907 if (call_type == POSSIBLY_EVAL_CALL) {
911 return false; 908 return false;
912 } 909 }
913 return true; 910 return true;
914 } 911 }
915 912
916 913 bool Call::IsUsingCallFeedbackSlot(
917 bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const { 914 Isolate* isolate, HandleDereferenceMode dereference_mode) const {
918 // SuperConstructorCall uses a CallConstructStub, which wants 915 // SuperConstructorCall uses a CallConstructStub, which wants
919 // a Slot, in addition to any IC slots requested elsewhere. 916 // a Slot, in addition to any IC slots requested elsewhere.
920 return GetCallType(isolate) == SUPER_CALL; 917 return GetCallType(isolate, dereference_mode) == SUPER_CALL;
921 } 918 }
922 919
923 920
924 void Call::AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 921 void Call::AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
925 FeedbackVectorSlotCache* cache) { 922 FeedbackVectorSlotCache* cache) {
926 if (IsUsingCallFeedbackICSlot(isolate)) { 923 if (IsUsingCallFeedbackICSlot(isolate)) {
927 ic_slot_ = spec->AddCallICSlot(); 924 ic_slot_ = spec->AddCallICSlot();
928 } 925 }
929 if (IsUsingCallFeedbackSlot(isolate)) { 926 if (IsUsingCallFeedbackSlot(isolate)) {
930 stub_slot_ = spec->AddGeneralSlot(); 927 stub_slot_ = spec->AddGeneralSlot();
931 } 928 }
932 } 929 }
933 930
934 931 Call::CallType Call::GetCallType(Isolate* isolate,
935 Call::CallType Call::GetCallType(Isolate* isolate) const { 932 HandleDereferenceMode deref_mode) const {
936 VariableProxy* proxy = expression()->AsVariableProxy(); 933 VariableProxy* proxy = expression()->AsVariableProxy();
937 if (proxy != NULL) { 934 if (proxy != NULL) {
938 if (proxy->var()->is_possibly_eval(isolate)) { 935 if (proxy->var()->is_possibly_eval(isolate, deref_mode)) {
939 return POSSIBLY_EVAL_CALL; 936 return POSSIBLY_EVAL_CALL;
940 } else if (proxy->var()->IsUnallocatedOrGlobalSlot()) { 937 } else if (proxy->var()->IsUnallocatedOrGlobalSlot()) {
941 return GLOBAL_CALL; 938 return GLOBAL_CALL;
942 } else if (proxy->var()->IsLookupSlot()) { 939 } else if (proxy->var()->IsLookupSlot()) {
943 return LOOKUP_SLOT_CALL; 940 return LOOKUP_SLOT_CALL;
944 } 941 }
945 } 942 }
946 943
947 if (expression()->IsSuperCallReference()) return SUPER_CALL; 944 if (expression()->IsSuperCallReference()) return SUPER_CALL;
948 945
949 Property* property = expression()->AsProperty(); 946 Property* property = expression()->AsProperty();
950 if (property != nullptr) { 947 if (property != nullptr) {
951 bool is_super = property->IsSuperAccess(); 948 bool is_super = property->IsSuperAccess();
952 if (property->key()->IsPropertyName()) { 949 if (property->key()->IsPropertyName(deref_mode)) {
953 return is_super ? NAMED_SUPER_PROPERTY_CALL : NAMED_PROPERTY_CALL; 950 return is_super ? NAMED_SUPER_PROPERTY_CALL : NAMED_PROPERTY_CALL;
954 } else { 951 } else {
955 return is_super ? KEYED_SUPER_PROPERTY_CALL : KEYED_PROPERTY_CALL; 952 return is_super ? KEYED_SUPER_PROPERTY_CALL : KEYED_PROPERTY_CALL;
956 } 953 }
957 } 954 }
958 955
959 return OTHER_CALL; 956 return OTHER_CALL;
960 } 957 }
961 958
962 959
(...skipping 12 matching lines...) Expand all
975 972
976 973
977 // static 974 // static
978 bool Literal::Match(void* literal1, void* literal2) { 975 bool Literal::Match(void* literal1, void* literal2) {
979 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 976 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
980 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 977 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
981 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 978 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
982 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 979 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
983 } 980 }
984 981
985
986 } // namespace internal 982 } // namespace internal
987 } // namespace v8 983 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/ast-value-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698