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

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

Issue 2581683003: Introduce {ConstantElementsPair} struct for type safety. (Closed)
Patch Set: Re-cemment bytecode tests. Created 4 years 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 #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/compile-time-value.h" 9 #include "src/ast/compile-time-value.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 630
631 Handle<FixedArrayBase> elements = fixed_array; 631 Handle<FixedArrayBase> elements = fixed_array;
632 if (IsFastDoubleElementsKind(kind)) { 632 if (IsFastDoubleElementsKind(kind)) {
633 ElementsAccessor* accessor = ElementsAccessor::ForKind(kind); 633 ElementsAccessor* accessor = ElementsAccessor::ForKind(kind);
634 elements = isolate->factory()->NewFixedDoubleArray(constants_length); 634 elements = isolate->factory()->NewFixedDoubleArray(constants_length);
635 // We are copying from non-fast-double to fast-double. 635 // We are copying from non-fast-double to fast-double.
636 ElementsKind from_kind = TERMINAL_FAST_ELEMENTS_KIND; 636 ElementsKind from_kind = TERMINAL_FAST_ELEMENTS_KIND;
637 accessor->CopyElements(fixed_array, from_kind, elements, constants_length); 637 accessor->CopyElements(fixed_array, from_kind, elements, constants_length);
638 } 638 }
639 639
640 // Remember both the literal's constant values as well as the ElementsKind 640 // Remember both the literal's constant values as well as the ElementsKind.
641 // in a 2-element FixedArray. 641 Handle<ConstantElementsPair> literals =
642 Handle<FixedArray> literals = isolate->factory()->NewFixedArray(2, TENURED); 642 isolate->factory()->NewConstantElementsPair(kind, elements);
643 literals->set(0, Smi::FromInt(kind));
644 literals->set(1, *elements);
645 643
646 constant_elements_ = literals; 644 constant_elements_ = literals;
647 set_is_simple(is_simple); 645 set_is_simple(is_simple);
648 set_depth(depth_acc); 646 set_depth(depth_acc);
649 } 647 }
650 648
651 649
652 void ArrayLiteral::AssignFeedbackVectorSlots(Isolate* isolate, 650 void ArrayLiteral::AssignFeedbackVectorSlots(Isolate* isolate,
653 FeedbackVectorSpec* spec, 651 FeedbackVectorSpec* spec,
654 FeedbackVectorSlotCache* cache) { 652 FeedbackVectorSlotCache* cache) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 // static 945 // static
948 bool Literal::Match(void* literal1, void* literal2) { 946 bool Literal::Match(void* literal1, void* literal2) {
949 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 947 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
950 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 948 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
951 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 949 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
952 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 950 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
953 } 951 }
954 952
955 } // namespace internal 953 } // namespace internal
956 } // namespace v8 954 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/ast-types.cc » ('j') | src/objects-printer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698