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

Side by Side Diff: src/ast/compile-time-value.cc

Issue 2445333002: Ensure slow properties for simple {__proto__:null} literals. (Closed)
Patch Set: fixing compilation issue Created 3 years, 7 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/compile-time-value.h ('k') | src/bootstrapper.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/compile-time-value.h" 5 #include "src/ast/compile-time-value.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/handles-inl.h" 9 #include "src/handles-inl.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
11 #include "src/objects-inl.h" 11 #include "src/objects-inl.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { 16 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) {
17 if (expression->IsLiteral()) return true; 17 if (expression->IsLiteral()) return true;
18 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); 18 MaterializedLiteral* lit = expression->AsMaterializedLiteral();
19 return lit != NULL && lit->is_simple(); 19 return lit != NULL && lit->is_simple();
20 } 20 }
21 21
22 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate, 22 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate,
23 Expression* expression) { 23 Expression* expression) {
24 Factory* factory = isolate->factory(); 24 Factory* factory = isolate->factory();
25 DCHECK(IsCompileTimeValue(expression)); 25 DCHECK(IsCompileTimeValue(expression));
26 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); 26 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED);
27 ObjectLiteral* object_literal = expression->AsObjectLiteral(); 27 if (expression->IsObjectLiteral()) {
28 if (object_literal != NULL) { 28 ObjectLiteral* object_literal = expression->AsObjectLiteral();
29 DCHECK(object_literal->is_simple()); 29 DCHECK(object_literal->is_simple());
30 if (object_literal->fast_elements()) { 30 int literalTypeFlag = object_literal->EncodeLiteralType();
31 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); 31 DCHECK_NE(kArrayLiteralFlag, literalTypeFlag);
32 } else { 32 result->set(kLiteralTypeSlot, Smi::FromInt(literalTypeFlag));
33 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS));
34 }
35 result->set(kElementsSlot, *object_literal->constant_properties()); 33 result->set(kElementsSlot, *object_literal->constant_properties());
36 } else { 34 } else {
37 ArrayLiteral* array_literal = expression->AsArrayLiteral(); 35 ArrayLiteral* array_literal = expression->AsArrayLiteral();
38 DCHECK(array_literal != NULL && array_literal->is_simple()); 36 DCHECK(array_literal != NULL && array_literal->is_simple());
39 result->set(kLiteralTypeSlot, Smi::FromInt(ARRAY_LITERAL)); 37 result->set(kLiteralTypeSlot, Smi::FromInt(kArrayLiteralFlag));
40 result->set(kElementsSlot, *array_literal->constant_elements()); 38 result->set(kElementsSlot, *array_literal->constant_elements());
41 } 39 }
42 return result; 40 return result;
43 } 41 }
44 42
45 CompileTimeValue::LiteralType CompileTimeValue::GetLiteralType( 43 int CompileTimeValue::GetLiteralTypeFlags(Handle<FixedArray> value) {
46 Handle<FixedArray> value) { 44 return Smi::cast(value->get(kLiteralTypeSlot))->value();
47 Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot));
48 return static_cast<LiteralType>(literal_type->value());
49 } 45 }
50 46
51 Handle<HeapObject> CompileTimeValue::GetElements(Handle<FixedArray> value) { 47 Handle<HeapObject> CompileTimeValue::GetElements(Handle<FixedArray> value) {
52 return Handle<HeapObject>(HeapObject::cast(value->get(kElementsSlot))); 48 return Handle<HeapObject>(HeapObject::cast(value->get(kElementsSlot)));
53 } 49 }
54 50
55 } // namespace internal 51 } // namespace internal
56 } // namespace v8 52 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/compile-time-value.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698