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.h" | 5 #include "src/ast.h" |
6 | 6 |
7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
8 #include "src/builtins.h" | 8 #include "src/builtins.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 549 |
550 int constants_length = | 550 int constants_length = |
551 first_spread_index_ >= 0 ? first_spread_index_ : values()->length(); | 551 first_spread_index_ >= 0 ? first_spread_index_ : values()->length(); |
552 | 552 |
553 // Allocate a fixed array to hold all the object literals. | 553 // Allocate a fixed array to hold all the object literals. |
554 Handle<JSArray> array = isolate->factory()->NewJSArray( | 554 Handle<JSArray> array = isolate->factory()->NewJSArray( |
555 FAST_HOLEY_SMI_ELEMENTS, constants_length, constants_length, | 555 FAST_HOLEY_SMI_ELEMENTS, constants_length, constants_length, |
556 Strength::WEAK, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); | 556 Strength::WEAK, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); |
557 | 557 |
558 // Fill in the literals. | 558 // Fill in the literals. |
559 bool is_simple = true; | 559 bool is_simple = (first_spread_index_ < 0); |
560 int depth_acc = 1; | 560 int depth_acc = 1; |
561 bool is_holey = false; | 561 bool is_holey = false; |
562 int array_index = 0; | 562 int array_index = 0; |
563 for (; array_index < constants_length; array_index++) { | 563 for (; array_index < constants_length; array_index++) { |
564 Expression* element = values()->at(array_index); | 564 Expression* element = values()->at(array_index); |
565 DCHECK(!element->IsSpread()); | 565 DCHECK(!element->IsSpread()); |
566 MaterializedLiteral* m_literal = element->AsMaterializedLiteral(); | 566 MaterializedLiteral* m_literal = element->AsMaterializedLiteral(); |
567 if (m_literal != NULL) { | 567 if (m_literal != NULL) { |
568 m_literal->BuildConstants(isolate); | 568 m_literal->BuildConstants(isolate); |
569 if (m_literal->depth() + 1 > depth_acc) { | 569 if (m_literal->depth() + 1 > depth_acc) { |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 bool Literal::Match(void* literal1, void* literal2) { | 1187 bool Literal::Match(void* literal1, void* literal2) { |
1188 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1188 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1189 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1189 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1190 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1190 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1191 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1191 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1192 } | 1192 } |
1193 | 1193 |
1194 | 1194 |
1195 } // namespace internal | 1195 } // namespace internal |
1196 } // namespace v8 | 1196 } // namespace v8 |
OLD | NEW |