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 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 new_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors)); | 1508 new_map->set_instance_descriptors(DescriptorArray::cast(new_descriptors)); |
1509 set_map(new_map); | 1509 set_map(new_map); |
1510 return FastPropertyAtPut(index, value); | 1510 return FastPropertyAtPut(index, value); |
1511 } | 1511 } |
1512 | 1512 |
1513 | 1513 |
1514 MaybeObject* JSObject::AddConstantFunctionProperty( | 1514 MaybeObject* JSObject::AddConstantFunctionProperty( |
1515 String* name, | 1515 String* name, |
1516 JSFunction* function, | 1516 JSFunction* function, |
1517 PropertyAttributes attributes) { | 1517 PropertyAttributes attributes) { |
1518 ASSERT(!GetHeap()->InNewSpace(function)); | |
1519 | |
1520 // Allocate new instance descriptors with (name, function) added | 1518 // Allocate new instance descriptors with (name, function) added |
1521 ConstantFunctionDescriptor d(name, function, attributes); | 1519 ConstantFunctionDescriptor d(name, function, attributes); |
1522 Object* new_descriptors; | 1520 Object* new_descriptors; |
1523 { MaybeObject* maybe_new_descriptors = | 1521 { MaybeObject* maybe_new_descriptors = |
1524 map()->instance_descriptors()->CopyInsert(&d, REMOVE_TRANSITIONS); | 1522 map()->instance_descriptors()->CopyInsert(&d, REMOVE_TRANSITIONS); |
1525 if (!maybe_new_descriptors->ToObject(&new_descriptors)) { | 1523 if (!maybe_new_descriptors->ToObject(&new_descriptors)) { |
1526 return maybe_new_descriptors; | 1524 return maybe_new_descriptors; |
1527 } | 1525 } |
1528 } | 1526 } |
1529 | 1527 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 Handle<Object> args[1] = {Handle<String>(name)}; | 1622 Handle<Object> args[1] = {Handle<String>(name)}; |
1625 return heap->isolate()->Throw( | 1623 return heap->isolate()->Throw( |
1626 *FACTORY->NewTypeError("object_not_extensible", | 1624 *FACTORY->NewTypeError("object_not_extensible", |
1627 HandleVector(args, 1))); | 1625 HandleVector(args, 1))); |
1628 } | 1626 } |
1629 } | 1627 } |
1630 if (HasFastProperties()) { | 1628 if (HasFastProperties()) { |
1631 // Ensure the descriptor array does not get too big. | 1629 // Ensure the descriptor array does not get too big. |
1632 if (map_of_this->instance_descriptors()->number_of_descriptors() < | 1630 if (map_of_this->instance_descriptors()->number_of_descriptors() < |
1633 DescriptorArray::kMaxNumberOfDescriptors) { | 1631 DescriptorArray::kMaxNumberOfDescriptors) { |
1634 if (value->IsJSFunction() && !heap->InNewSpace(value)) { | 1632 if (value->IsJSFunction()) { |
1635 return AddConstantFunctionProperty(name, | 1633 return AddConstantFunctionProperty(name, |
1636 JSFunction::cast(value), | 1634 JSFunction::cast(value), |
1637 attributes); | 1635 attributes); |
1638 } else { | 1636 } else { |
1639 return AddFastProperty(name, value, attributes); | 1637 return AddFastProperty(name, value, attributes); |
1640 } | 1638 } |
1641 } else { | 1639 } else { |
1642 // Normalize the object to prevent very large instance descriptors. | 1640 // Normalize the object to prevent very large instance descriptors. |
1643 // This eliminates unwanted N^2 allocation and lookup behavior. | 1641 // This eliminates unwanted N^2 allocation and lookup behavior. |
1644 Object* obj; | 1642 Object* obj; |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2754 case CONSTANT_TRANSITION: { | 2752 case CONSTANT_TRANSITION: { |
2755 // If the same constant function is being added we can simply | 2753 // If the same constant function is being added we can simply |
2756 // transition to the target map. | 2754 // transition to the target map. |
2757 Map* target_map = result->GetTransitionMap(); | 2755 Map* target_map = result->GetTransitionMap(); |
2758 DescriptorArray* target_descriptors = target_map->instance_descriptors(); | 2756 DescriptorArray* target_descriptors = target_map->instance_descriptors(); |
2759 int number = target_descriptors->SearchWithCache(name); | 2757 int number = target_descriptors->SearchWithCache(name); |
2760 ASSERT(number != DescriptorArray::kNotFound); | 2758 ASSERT(number != DescriptorArray::kNotFound); |
2761 ASSERT(target_descriptors->GetType(number) == CONSTANT_FUNCTION); | 2759 ASSERT(target_descriptors->GetType(number) == CONSTANT_FUNCTION); |
2762 JSFunction* function = | 2760 JSFunction* function = |
2763 JSFunction::cast(target_descriptors->GetValue(number)); | 2761 JSFunction::cast(target_descriptors->GetValue(number)); |
2764 ASSERT(!HEAP->InNewSpace(function)); | |
2765 if (value == function) { | 2762 if (value == function) { |
2766 set_map(target_map); | 2763 set_map(target_map); |
2767 return value; | 2764 return value; |
2768 } | 2765 } |
2769 // Otherwise, replace with a MAP_TRANSITION to a new map with a | 2766 // Otherwise, replace with a MAP_TRANSITION to a new map with a |
2770 // FIELD, even if the value is a constant function. | 2767 // FIELD, even if the value is a constant function. |
2771 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); | 2768 return ConvertDescriptorToFieldAndMapTransition(name, value, attributes); |
2772 } | 2769 } |
2773 case NULL_DESCRIPTOR: | 2770 case NULL_DESCRIPTOR: |
2774 case ELEMENTS_TRANSITION: | 2771 case ELEMENTS_TRANSITION: |
(...skipping 9404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12179 if (break_point_objects()->IsUndefined()) return 0; | 12176 if (break_point_objects()->IsUndefined()) return 0; |
12180 // Single break point. | 12177 // Single break point. |
12181 if (!break_point_objects()->IsFixedArray()) return 1; | 12178 if (!break_point_objects()->IsFixedArray()) return 1; |
12182 // Multiple break points. | 12179 // Multiple break points. |
12183 return FixedArray::cast(break_point_objects())->length(); | 12180 return FixedArray::cast(break_point_objects())->length(); |
12184 } | 12181 } |
12185 #endif | 12182 #endif |
12186 | 12183 |
12187 | 12184 |
12188 } } // namespace v8::internal | 12185 } } // namespace v8::internal |
OLD | NEW |