| 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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 | 541 |
| 542 JSObject::AddDataElement(array, array_index, boilerplate_value, NONE) | 542 JSObject::AddDataElement(array, array_index, boilerplate_value, NONE) |
| 543 .Assert(); | 543 .Assert(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 if (array_index != values()->length()) { | 546 if (array_index != values()->length()) { |
| 547 JSArray::SetLength(array, array_index); | 547 JSArray::SetLength(array, array_index); |
| 548 } | 548 } |
| 549 JSObject::ValidateElements(array); | 549 JSObject::ValidateElements(array); |
| 550 Handle<FixedArrayBase> element_values(array->elements()); | 550 Handle<FixedArrayBase> element_values(array->elements()); |
| 551 if (array_index != values()->length()) { |
| 552 element_values->set_length(array_index); |
| 553 } |
| 551 | 554 |
| 552 // Simple and shallow arrays can be lazily copied, we transform the | 555 // Simple and shallow arrays can be lazily copied, we transform the |
| 553 // elements array to a copy-on-write array. | 556 // elements array to a copy-on-write array. |
| 554 if (is_simple && depth_acc == 1 && array_index > 0 && | 557 if (is_simple && depth_acc == 1 && array_index > 0 && |
| 555 array->HasFastSmiOrObjectElements()) { | 558 array->HasFastSmiOrObjectElements()) { |
| 556 element_values->set_map(isolate->heap()->fixed_cow_array_map()); | 559 element_values->set_map(isolate->heap()->fixed_cow_array_map()); |
| 557 } | 560 } |
| 558 | 561 |
| 559 // Remember both the literal's constant values as well as the ElementsKind | 562 // Remember both the literal's constant values as well as the ElementsKind |
| 560 // in a 2-element FixedArray. | 563 // in a 2-element FixedArray. |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 bool Literal::Match(void* literal1, void* literal2) { | 1148 bool Literal::Match(void* literal1, void* literal2) { |
| 1146 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1149 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 1147 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1150 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 1148 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1151 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
| 1149 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1152 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 1150 } | 1153 } |
| 1151 | 1154 |
| 1152 | 1155 |
| 1153 } // namespace internal | 1156 } // namespace internal |
| 1154 } // namespace v8 | 1157 } // namespace v8 |
| OLD | NEW |