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 #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 Loading... |
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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 return static_cast<const Node*>(this)->IsMonomorphic(); | 863 return static_cast<const Node*>(this)->IsMonomorphic(); |
868 PROPERTY_NODE_LIST(GENERATE_CASE) | 864 PROPERTY_NODE_LIST(GENERATE_CASE) |
869 CALL_NODE_LIST(GENERATE_CASE) | 865 CALL_NODE_LIST(GENERATE_CASE) |
870 #undef GENERATE_CASE | 866 #undef GENERATE_CASE |
871 default: | 867 default: |
872 UNREACHABLE(); | 868 UNREACHABLE(); |
873 return false; | 869 return false; |
874 } | 870 } |
875 } | 871 } |
876 | 872 |
877 bool Call::IsUsingCallFeedbackICSlot(Isolate* isolate) const { | 873 bool Call::IsUsingCallFeedbackICSlot( |
878 CallType call_type = GetCallType(isolate); | 874 Isolate* isolate, HandleDereferenceMode dereference_mode) const { |
| 875 CallType call_type = GetCallType(isolate, dereference_mode); |
879 if (call_type == POSSIBLY_EVAL_CALL) { | 876 if (call_type == POSSIBLY_EVAL_CALL) { |
880 return false; | 877 return false; |
881 } | 878 } |
882 return true; | 879 return true; |
883 } | 880 } |
884 | 881 |
885 | 882 bool Call::IsUsingCallFeedbackSlot( |
886 bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const { | 883 Isolate* isolate, HandleDereferenceMode dereference_mode) const { |
887 // SuperConstructorCall uses a CallConstructStub, which wants | 884 // SuperConstructorCall uses a CallConstructStub, which wants |
888 // a Slot, in addition to any IC slots requested elsewhere. | 885 // a Slot, in addition to any IC slots requested elsewhere. |
889 return GetCallType(isolate) == SUPER_CALL; | 886 return GetCallType(isolate, dereference_mode) == SUPER_CALL; |
890 } | 887 } |
891 | 888 |
892 | 889 |
893 void Call::AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 890 void Call::AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
894 FeedbackVectorSlotCache* cache) { | 891 FeedbackVectorSlotCache* cache) { |
895 if (IsUsingCallFeedbackICSlot(isolate)) { | 892 if (IsUsingCallFeedbackICSlot(isolate)) { |
896 ic_slot_ = spec->AddCallICSlot(); | 893 ic_slot_ = spec->AddCallICSlot(); |
897 } | 894 } |
898 if (IsUsingCallFeedbackSlot(isolate)) { | 895 if (IsUsingCallFeedbackSlot(isolate)) { |
899 stub_slot_ = spec->AddGeneralSlot(); | 896 stub_slot_ = spec->AddGeneralSlot(); |
900 } | 897 } |
901 } | 898 } |
902 | 899 |
903 | 900 Call::CallType Call::GetCallType(Isolate* isolate, |
904 Call::CallType Call::GetCallType(Isolate* isolate) const { | 901 HandleDereferenceMode deref_mode) const { |
905 VariableProxy* proxy = expression()->AsVariableProxy(); | 902 VariableProxy* proxy = expression()->AsVariableProxy(); |
906 if (proxy != NULL) { | 903 if (proxy != NULL) { |
907 if (proxy->var()->is_possibly_eval(isolate)) { | 904 if (proxy->var()->is_possibly_eval(isolate, deref_mode)) { |
908 return POSSIBLY_EVAL_CALL; | 905 return POSSIBLY_EVAL_CALL; |
909 } else if (proxy->var()->IsUnallocatedOrGlobalSlot()) { | 906 } else if (proxy->var()->IsUnallocatedOrGlobalSlot()) { |
910 return GLOBAL_CALL; | 907 return GLOBAL_CALL; |
911 } else if (proxy->var()->IsLookupSlot()) { | 908 } else if (proxy->var()->IsLookupSlot()) { |
912 return LOOKUP_SLOT_CALL; | 909 return LOOKUP_SLOT_CALL; |
913 } | 910 } |
914 } | 911 } |
915 | 912 |
916 if (expression()->IsSuperCallReference()) return SUPER_CALL; | 913 if (expression()->IsSuperCallReference()) return SUPER_CALL; |
917 | 914 |
918 Property* property = expression()->AsProperty(); | 915 Property* property = expression()->AsProperty(); |
919 if (property != nullptr) { | 916 if (property != nullptr) { |
920 bool is_super = property->IsSuperAccess(); | 917 bool is_super = property->IsSuperAccess(); |
921 if (property->key()->IsPropertyName()) { | 918 if (property->key()->IsPropertyName(deref_mode)) { |
922 return is_super ? NAMED_SUPER_PROPERTY_CALL : NAMED_PROPERTY_CALL; | 919 return is_super ? NAMED_SUPER_PROPERTY_CALL : NAMED_PROPERTY_CALL; |
923 } else { | 920 } else { |
924 return is_super ? KEYED_SUPER_PROPERTY_CALL : KEYED_PROPERTY_CALL; | 921 return is_super ? KEYED_SUPER_PROPERTY_CALL : KEYED_PROPERTY_CALL; |
925 } | 922 } |
926 } | 923 } |
927 | 924 |
928 return OTHER_CALL; | 925 return OTHER_CALL; |
929 } | 926 } |
930 | 927 |
931 | 928 |
(...skipping 12 matching lines...) Expand all Loading... |
944 | 941 |
945 | 942 |
946 // static | 943 // static |
947 bool Literal::Match(void* literal1, void* literal2) { | 944 bool Literal::Match(void* literal1, void* literal2) { |
948 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 945 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
949 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 946 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
950 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 947 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
951 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 948 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
952 } | 949 } |
953 | 950 |
954 | |
955 } // namespace internal | 951 } // namespace internal |
956 } // namespace v8 | 952 } // namespace v8 |
OLD | NEW |