OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 4888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4899 // needed. At that point, a new initial map is created and the | 4899 // needed. At that point, a new initial map is created and the |
4900 // prototype is put into the initial map where it belongs. | 4900 // prototype is put into the initial map where it belongs. |
4901 set_prototype_or_initial_map(value); | 4901 set_prototype_or_initial_map(value); |
4902 } | 4902 } |
4903 return value; | 4903 return value; |
4904 } | 4904 } |
4905 | 4905 |
4906 | 4906 |
4907 | 4907 |
4908 Object* JSFunction::SetPrototype(Object* value) { | 4908 Object* JSFunction::SetPrototype(Object* value) { |
| 4909 ASSERT(should_have_prototype()); |
4909 Object* construct_prototype = value; | 4910 Object* construct_prototype = value; |
4910 | 4911 |
4911 // If the value is not a JSObject, store the value in the map's | 4912 // If the value is not a JSObject, store the value in the map's |
4912 // constructor field so it can be accessed. Also, set the prototype | 4913 // constructor field so it can be accessed. Also, set the prototype |
4913 // used for constructing objects to the original object prototype. | 4914 // used for constructing objects to the original object prototype. |
4914 // See ECMA-262 13.2.2. | 4915 // See ECMA-262 13.2.2. |
4915 if (!value->IsJSObject()) { | 4916 if (!value->IsJSObject()) { |
4916 // Copy the map so this does not affect unrelated functions. | 4917 // Copy the map so this does not affect unrelated functions. |
4917 // Remove map transitions because they point to maps with a | 4918 // Remove map transitions because they point to maps with a |
4918 // different prototype. | 4919 // different prototype. |
4919 Object* new_map = map()->CopyDropTransitions(); | 4920 Object* new_map = map()->CopyDropTransitions(); |
4920 if (new_map->IsFailure()) return new_map; | 4921 if (new_map->IsFailure()) return new_map; |
4921 set_map(Map::cast(new_map)); | 4922 set_map(Map::cast(new_map)); |
4922 map()->set_constructor(value); | 4923 map()->set_constructor(value); |
4923 map()->set_non_instance_prototype(true); | 4924 map()->set_non_instance_prototype(true); |
4924 construct_prototype = | 4925 construct_prototype = |
4925 Top::context()->global_context()->initial_object_prototype(); | 4926 Top::context()->global_context()->initial_object_prototype(); |
4926 } else { | 4927 } else { |
4927 map()->set_non_instance_prototype(false); | 4928 map()->set_non_instance_prototype(false); |
4928 } | 4929 } |
4929 | 4930 |
4930 return SetInstancePrototype(construct_prototype); | 4931 return SetInstancePrototype(construct_prototype); |
4931 } | 4932 } |
4932 | 4933 |
4933 | 4934 |
| 4935 Object* JSFunction::RemovePrototype() { |
| 4936 ASSERT(map() == context()->global_context()->function_map()); |
| 4937 set_map(context()->global_context()->function_without_prototype_map()); |
| 4938 set_prototype_or_initial_map(Heap::the_hole_value()); |
| 4939 return this; |
| 4940 } |
| 4941 |
| 4942 |
4934 Object* JSFunction::SetInstanceClassName(String* name) { | 4943 Object* JSFunction::SetInstanceClassName(String* name) { |
4935 shared()->set_instance_class_name(name); | 4944 shared()->set_instance_class_name(name); |
4936 return this; | 4945 return this; |
4937 } | 4946 } |
4938 | 4947 |
4939 | 4948 |
4940 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) { | 4949 Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) { |
4941 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); | 4950 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); |
4942 } | 4951 } |
4943 | 4952 |
(...skipping 3592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8536 if (break_point_objects()->IsUndefined()) return 0; | 8545 if (break_point_objects()->IsUndefined()) return 0; |
8537 // Single beak point. | 8546 // Single beak point. |
8538 if (!break_point_objects()->IsFixedArray()) return 1; | 8547 if (!break_point_objects()->IsFixedArray()) return 1; |
8539 // Multiple break points. | 8548 // Multiple break points. |
8540 return FixedArray::cast(break_point_objects())->length(); | 8549 return FixedArray::cast(break_point_objects())->length(); |
8541 } | 8550 } |
8542 #endif | 8551 #endif |
8543 | 8552 |
8544 | 8553 |
8545 } } // namespace v8::internal | 8554 } } // namespace v8::internal |
OLD | NEW |