| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 if (c0_ != '}') { | 450 if (c0_ != '}') { |
| 451 return ReportUnexpectedCharacter(); | 451 return ReportUnexpectedCharacter(); |
| 452 } | 452 } |
| 453 | 453 |
| 454 // If we transitioned until the very end, transition the map now. | 454 // If we transitioned until the very end, transition the map now. |
| 455 if (transitioning) { | 455 if (transitioning) { |
| 456 JSObject::AllocateStorageForMap(json_object, map); | 456 JSObject::AllocateStorageForMap(json_object, map); |
| 457 int length = properties.length(); | 457 int length = properties.length(); |
| 458 for (int i = 0; i < length; i++) { | 458 for (int i = 0; i < length; i++) { |
| 459 Handle<Object> value = properties[i]; | 459 Handle<Object> value = properties[i]; |
| 460 // If the target representation is double and the value is already | |
| 461 // double, use the existing box. | |
| 462 if (FLAG_track_double_fields && value->IsSmi()) { | |
| 463 Representation representation = | |
| 464 map->instance_descriptors()->GetDetails(i).representation(); | |
| 465 if (representation.IsDouble()) { | |
| 466 value = factory()->NewHeapNumber( | |
| 467 Handle<Smi>::cast(value)->value()); | |
| 468 } | |
| 469 } | |
| 470 json_object->FastPropertyAtPut(i, *value); | 460 json_object->FastPropertyAtPut(i, *value); |
| 471 } | 461 } |
| 472 } | 462 } |
| 473 } | 463 } |
| 474 AdvanceSkipWhitespace(); | 464 AdvanceSkipWhitespace(); |
| 475 return scope.CloseAndEscape(json_object); | 465 return scope.CloseAndEscape(json_object); |
| 476 } | 466 } |
| 477 | 467 |
| 478 // Parse a JSON array. Position must be right at '['. | 468 // Parse a JSON array. Position must be right at '['. |
| 479 template <bool seq_ascii> | 469 template <bool seq_ascii> |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 | 801 |
| 812 ASSERT_EQ('"', c0_); | 802 ASSERT_EQ('"', c0_); |
| 813 // Advance past the last '"'. | 803 // Advance past the last '"'. |
| 814 AdvanceSkipWhitespace(); | 804 AdvanceSkipWhitespace(); |
| 815 return result; | 805 return result; |
| 816 } | 806 } |
| 817 | 807 |
| 818 } } // namespace v8::internal | 808 } } // namespace v8::internal |
| 819 | 809 |
| 820 #endif // V8_JSON_PARSER_H_ | 810 #endif // V8_JSON_PARSER_H_ |
| OLD | NEW |