| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 PropertyDetails details = | 408 PropertyDetails details = |
| 409 target->instance_descriptors()->GetDetails(descriptor); | 409 target->instance_descriptors()->GetDetails(descriptor); |
| 410 Representation expected_representation = details.representation(); | 410 Representation expected_representation = details.representation(); |
| 411 | 411 |
| 412 if (value->FitsRepresentation(expected_representation)) { | 412 if (value->FitsRepresentation(expected_representation)) { |
| 413 // If the target representation is double and the value is already | 413 // If the target representation is double and the value is already |
| 414 // double, use the existing box. | 414 // double, use the existing box. |
| 415 if (value->IsSmi() && expected_representation.IsDouble()) { | 415 if (value->IsSmi() && expected_representation.IsDouble()) { |
| 416 value = factory()->NewHeapNumber( | 416 value = factory()->NewHeapNumber( |
| 417 Handle<Smi>::cast(value)->value()); | 417 Handle<Smi>::cast(value)->value()); |
| 418 } else if (expected_representation.IsHeapObject() && |
| 419 !target->instance_descriptors()->GetFieldType( |
| 420 descriptor)->NowContains(value)) { |
| 421 Handle<HeapType> value_type(value->OptimalType( |
| 422 isolate(), expected_representation)); |
| 423 Map::GeneralizeFieldType(target, descriptor, value_type); |
| 418 } | 424 } |
| 425 ASSERT(target->instance_descriptors()->GetFieldType( |
| 426 descriptor)->NowContains(value)); |
| 419 properties.Add(value, zone()); | 427 properties.Add(value, zone()); |
| 420 map = target; | 428 map = target; |
| 421 continue; | 429 continue; |
| 422 } else { | 430 } else { |
| 423 transitioning = false; | 431 transitioning = false; |
| 424 } | 432 } |
| 425 } | 433 } |
| 426 | 434 |
| 427 // Commit the intermediate state to the object and stop transitioning. | 435 // Commit the intermediate state to the object and stop transitioning. |
| 428 JSObject::AllocateStorageForMap(json_object, map); | 436 JSObject::AllocateStorageForMap(json_object, map); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 | 804 |
| 797 ASSERT_EQ('"', c0_); | 805 ASSERT_EQ('"', c0_); |
| 798 // Advance past the last '"'. | 806 // Advance past the last '"'. |
| 799 AdvanceSkipWhitespace(); | 807 AdvanceSkipWhitespace(); |
| 800 return result; | 808 return result; |
| 801 } | 809 } |
| 802 | 810 |
| 803 } } // namespace v8::internal | 811 } } // namespace v8::internal |
| 804 | 812 |
| 805 #endif // V8_JSON_PARSER_H_ | 813 #endif // V8_JSON_PARSER_H_ |
| OLD | NEW |