| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef V8_JSON_PARSER_H_ | 5 #ifndef V8_JSON_PARSER_H_ |
| 6 #define V8_JSON_PARSER_H_ | 6 #define V8_JSON_PARSER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/char-predicates-inl.h" | 10 #include "src/char-predicates-inl.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 value = ParseJsonValue(); | 380 value = ParseJsonValue(); |
| 381 if (value.is_null()) return ReportUnexpectedCharacter(); | 381 if (value.is_null()) return ReportUnexpectedCharacter(); |
| 382 | 382 |
| 383 if (transitioning) { | 383 if (transitioning) { |
| 384 int descriptor = map->NumberOfOwnDescriptors(); | 384 int descriptor = map->NumberOfOwnDescriptors(); |
| 385 PropertyDetails details = | 385 PropertyDetails details = |
| 386 target->instance_descriptors()->GetDetails(descriptor); | 386 target->instance_descriptors()->GetDetails(descriptor); |
| 387 Representation expected_representation = details.representation(); | 387 Representation expected_representation = details.representation(); |
| 388 | 388 |
| 389 if (value->FitsRepresentation(expected_representation)) { | 389 if (value->FitsRepresentation(expected_representation)) { |
| 390 // If the target representation is double and the value is already | 390 if (expected_representation.IsDouble()) { |
| 391 // double, use the existing box. | 391 value = Object::NewStorageFor(isolate(), value, |
| 392 if (value->IsSmi() && expected_representation.IsDouble()) { | 392 expected_representation); |
| 393 value = factory()->NewHeapNumber( | |
| 394 Handle<Smi>::cast(value)->value()); | |
| 395 } else if (expected_representation.IsHeapObject() && | 393 } else if (expected_representation.IsHeapObject() && |
| 396 !target->instance_descriptors()->GetFieldType( | 394 !target->instance_descriptors()->GetFieldType( |
| 397 descriptor)->NowContains(value)) { | 395 descriptor)->NowContains(value)) { |
| 398 Handle<HeapType> value_type(value->OptimalType( | 396 Handle<HeapType> value_type(value->OptimalType( |
| 399 isolate(), expected_representation)); | 397 isolate(), expected_representation)); |
| 400 Map::GeneralizeFieldType(target, descriptor, value_type); | 398 Map::GeneralizeFieldType(target, descriptor, value_type); |
| 401 } | 399 } |
| 402 ASSERT(target->instance_descriptors()->GetFieldType( | 400 ASSERT(target->instance_descriptors()->GetFieldType( |
| 403 descriptor)->NowContains(value)); | 401 descriptor)->NowContains(value)); |
| 404 properties.Add(value, zone()); | 402 properties.Add(value, zone()); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 | 781 |
| 784 ASSERT_EQ('"', c0_); | 782 ASSERT_EQ('"', c0_); |
| 785 // Advance past the last '"'. | 783 // Advance past the last '"'. |
| 786 AdvanceSkipWhitespace(); | 784 AdvanceSkipWhitespace(); |
| 787 return result; | 785 return result; |
| 788 } | 786 } |
| 789 | 787 |
| 790 } } // namespace v8::internal | 788 } } // namespace v8::internal |
| 791 | 789 |
| 792 #endif // V8_JSON_PARSER_H_ | 790 #endif // V8_JSON_PARSER_H_ |
| OLD | NEW |