| 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 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 properties()->CopySize(properties()->length() + new_unused + 1); | 1533 properties()->CopySize(properties()->length() + new_unused + 1); |
| 1534 if (!maybe_values->ToObject(&values)) return maybe_values; | 1534 if (!maybe_values->ToObject(&values)) return maybe_values; |
| 1535 } | 1535 } |
| 1536 set_properties(FixedArray::cast(values)); | 1536 set_properties(FixedArray::cast(values)); |
| 1537 } | 1537 } |
| 1538 set_map(new_map); | 1538 set_map(new_map); |
| 1539 return FastPropertyAtPut(index, value); | 1539 return FastPropertyAtPut(index, value); |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 | 1542 |
| 1543 static bool IsIdentifier(UnicodeCache* cache, | |
| 1544 unibrow::CharacterStream* buffer) { | |
| 1545 // Checks whether the buffer contains an identifier (no escape). | |
| 1546 if (!buffer->has_more()) return false; | |
| 1547 if (!cache->IsIdentifierStart(buffer->GetNext())) { | |
| 1548 return false; | |
| 1549 } | |
| 1550 while (buffer->has_more()) { | |
| 1551 if (!cache->IsIdentifierPart(buffer->GetNext())) { | |
| 1552 return false; | |
| 1553 } | |
| 1554 } | |
| 1555 return true; | |
| 1556 } | |
| 1557 | |
| 1558 | |
| 1559 MaybeObject* JSObject::AddFastProperty(String* name, | 1543 MaybeObject* JSObject::AddFastProperty(String* name, |
| 1560 Object* value, | 1544 Object* value, |
| 1561 PropertyAttributes attributes) { | 1545 PropertyAttributes attributes) { |
| 1562 ASSERT(!IsJSGlobalProxy()); | 1546 ASSERT(!IsJSGlobalProxy()); |
| 1563 | |
| 1564 // Normalize the object if the name is an actual string (not the | |
| 1565 // hidden symbols) and is not a real identifier. | |
| 1566 Isolate* isolate = GetHeap()->isolate(); | 1547 Isolate* isolate = GetHeap()->isolate(); |
| 1567 StringInputBuffer buffer(name); | |
| 1568 if (!IsIdentifier(isolate->unicode_cache(), &buffer) | |
| 1569 && name != isolate->heap()->hidden_symbol()) { | |
| 1570 Object* obj; | |
| 1571 { MaybeObject* maybe_obj = | |
| 1572 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | |
| 1573 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
| 1574 } | |
| 1575 return AddSlowProperty(name, value, attributes); | |
| 1576 } | |
| 1577 | |
| 1578 DescriptorArray* old_descriptors = map()->instance_descriptors(); | 1548 DescriptorArray* old_descriptors = map()->instance_descriptors(); |
| 1579 // Compute the new index for new field. | 1549 // Compute the new index for new field. |
| 1580 int index = map()->NextFreePropertyIndex(); | 1550 int index = map()->NextFreePropertyIndex(); |
| 1581 | 1551 |
| 1582 // Allocate new instance descriptors with (name, index) added | 1552 // Allocate new instance descriptors with (name, index) added |
| 1583 FieldDescriptor new_field(name, index, attributes); | 1553 FieldDescriptor new_field(name, index, attributes); |
| 1584 Object* new_descriptors; | 1554 Object* new_descriptors; |
| 1585 { MaybeObject* maybe_new_descriptors = | 1555 { MaybeObject* maybe_new_descriptors = |
| 1586 old_descriptors->CopyInsert(&new_field, REMOVE_TRANSITIONS); | 1556 old_descriptors->CopyInsert(&new_field, REMOVE_TRANSITIONS); |
| 1587 if (!maybe_new_descriptors->ToObject(&new_descriptors)) { | 1557 if (!maybe_new_descriptors->ToObject(&new_descriptors)) { |
| (...skipping 11160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12748 if (break_point_objects()->IsUndefined()) return 0; | 12718 if (break_point_objects()->IsUndefined()) return 0; |
| 12749 // Single break point. | 12719 // Single break point. |
| 12750 if (!break_point_objects()->IsFixedArray()) return 1; | 12720 if (!break_point_objects()->IsFixedArray()) return 1; |
| 12751 // Multiple break points. | 12721 // Multiple break points. |
| 12752 return FixedArray::cast(break_point_objects())->length(); | 12722 return FixedArray::cast(break_point_objects())->length(); |
| 12753 } | 12723 } |
| 12754 #endif // ENABLE_DEBUGGER_SUPPORT | 12724 #endif // ENABLE_DEBUGGER_SUPPORT |
| 12755 | 12725 |
| 12756 | 12726 |
| 12757 } } // namespace v8::internal | 12727 } } // namespace v8::internal |
| OLD | NEW |