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

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

Issue 2225423002: Make the AstValueFactory more efficient and less memory hungry (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Undo union since windows 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 bool Expression::IsSmiLiteral() const { 68 bool Expression::IsSmiLiteral() const {
69 return IsLiteral() && AsLiteral()->value()->IsSmi(); 69 return IsLiteral() && AsLiteral()->value()->IsSmi();
70 } 70 }
71 71
72 72
73 bool Expression::IsStringLiteral() const { 73 bool Expression::IsStringLiteral() const {
74 return IsLiteral() && AsLiteral()->value()->IsString(); 74 return IsLiteral() && AsLiteral()->value()->IsString();
75 } 75 }
76 76
77 bool Expression::IsPropertyName(HandleDereferenceMode deref_mode) const { 77 bool Expression::IsPropertyName() const {
78 return IsLiteral() && AsLiteral()->IsPropertyName(deref_mode); 78 return IsLiteral() && AsLiteral()->IsPropertyName();
79 } 79 }
80 80
81 bool Expression::IsNullLiteral() const { 81 bool Expression::IsNullLiteral() const {
82 if (!IsLiteral()) return false; 82 if (!IsLiteral()) return false;
83 return AsLiteral()->raw_value()->IsNull(); 83 return AsLiteral()->raw_value()->IsNull();
84 } 84 }
85 85
86 bool Expression::IsUndefinedLiteral() const { 86 bool Expression::IsUndefinedLiteral() const {
87 if (IsLiteral()) { 87 if (IsLiteral()) {
88 if (AsLiteral()->raw_value()->IsUndefined()) { 88 if (AsLiteral()->raw_value()->IsUndefined()) {
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 } else if (proxy->var()->IsLookupSlot()) { 926 } else if (proxy->var()->IsLookupSlot()) {
927 return LOOKUP_SLOT_CALL; 927 return LOOKUP_SLOT_CALL;
928 } 928 }
929 } 929 }
930 930
931 if (expression()->IsSuperCallReference()) return SUPER_CALL; 931 if (expression()->IsSuperCallReference()) return SUPER_CALL;
932 932
933 Property* property = expression()->AsProperty(); 933 Property* property = expression()->AsProperty();
934 if (property != nullptr) { 934 if (property != nullptr) {
935 bool is_super = property->IsSuperAccess(); 935 bool is_super = property->IsSuperAccess();
936 if (property->key()->IsPropertyName(deref_mode)) { 936 if (property->key()->IsPropertyName()) {
937 return is_super ? NAMED_SUPER_PROPERTY_CALL : NAMED_PROPERTY_CALL; 937 return is_super ? NAMED_SUPER_PROPERTY_CALL : NAMED_PROPERTY_CALL;
938 } else { 938 } else {
939 return is_super ? KEYED_SUPER_PROPERTY_CALL : KEYED_PROPERTY_CALL; 939 return is_super ? KEYED_SUPER_PROPERTY_CALL : KEYED_PROPERTY_CALL;
940 } 940 }
941 } 941 }
942 942
943 return OTHER_CALL; 943 return OTHER_CALL;
944 } 944 }
945 945
946 946
(...skipping 14 matching lines...) Expand all
961 // static 961 // static
962 bool Literal::Match(void* literal1, void* literal2) { 962 bool Literal::Match(void* literal1, void* literal2) {
963 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 963 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
964 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 964 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
965 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 965 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
966 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 966 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
967 } 967 }
968 968
969 } // namespace internal 969 } // namespace internal
970 } // namespace v8 970 } // 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