Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: src/objects.cc

Issue 3156028: Change code pointer in function objects to a pointer to the first... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1091
1092 switch (type) { 1092 switch (type) {
1093 case FIXED_ARRAY_TYPE: 1093 case FIXED_ARRAY_TYPE:
1094 FixedArray::BodyDescriptor::IterateBody(this, object_size, v); 1094 FixedArray::BodyDescriptor::IterateBody(this, object_size, v);
1095 break; 1095 break;
1096 case JS_OBJECT_TYPE: 1096 case JS_OBJECT_TYPE:
1097 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: 1097 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
1098 case JS_VALUE_TYPE: 1098 case JS_VALUE_TYPE:
1099 case JS_ARRAY_TYPE: 1099 case JS_ARRAY_TYPE:
1100 case JS_REGEXP_TYPE: 1100 case JS_REGEXP_TYPE:
1101 case JS_FUNCTION_TYPE:
1102 case JS_GLOBAL_PROXY_TYPE: 1101 case JS_GLOBAL_PROXY_TYPE:
1103 case JS_GLOBAL_OBJECT_TYPE: 1102 case JS_GLOBAL_OBJECT_TYPE:
1104 case JS_BUILTINS_OBJECT_TYPE: 1103 case JS_BUILTINS_OBJECT_TYPE:
1105 JSObject::BodyDescriptor::IterateBody(this, object_size, v); 1104 JSObject::BodyDescriptor::IterateBody(this, object_size, v);
1106 break; 1105 break;
1106 case JS_FUNCTION_TYPE:
1107 reinterpret_cast<JSFunction*>(this)
1108 ->JSFunctionIterateBody(object_size, v);
1109 break;
1107 case ODDBALL_TYPE: 1110 case ODDBALL_TYPE:
1108 Oddball::BodyDescriptor::IterateBody(this, v); 1111 Oddball::BodyDescriptor::IterateBody(this, v);
1109 break; 1112 break;
1110 case PROXY_TYPE: 1113 case PROXY_TYPE:
1111 reinterpret_cast<Proxy*>(this)->ProxyIterateBody(v); 1114 reinterpret_cast<Proxy*>(this)->ProxyIterateBody(v);
1112 break; 1115 break;
1113 case MAP_TYPE: 1116 case MAP_TYPE:
1114 Map::BodyDescriptor::IterateBody(this, v); 1117 Map::BodyDescriptor::IterateBody(this, v);
1115 break; 1118 break;
1116 case CODE_TYPE: 1119 case CODE_TYPE:
(...skipping 3901 matching lines...) Expand 10 before | Expand all | Expand 10 after
5018 ASSERT(target->prototype() == this || 5021 ASSERT(target->prototype() == this ||
5019 target->prototype() == real_prototype); 5022 target->prototype() == real_prototype);
5020 // Getter prototype() is read-only, set_prototype() has side effects. 5023 // Getter prototype() is read-only, set_prototype() has side effects.
5021 *RawField(target, Map::kPrototypeOffset) = real_prototype; 5024 *RawField(target, Map::kPrototypeOffset) = real_prototype;
5022 } 5025 }
5023 } 5026 }
5024 } 5027 }
5025 } 5028 }
5026 5029
5027 5030
5031 void JSFunction::JSFunctionIterateBody(int object_size, ObjectVisitor* v) {
5032 // Iterate over all fields in the body but take care in dealing with
5033 // the code entry.
5034 IteratePointers(v, kPropertiesOffset, kCodeEntryOffset);
5035 v->VisitCodeEntry(this->address() + kCodeEntryOffset);
5036 IteratePointers(v, kCodeEntryOffset + kPointerSize, object_size);
5037 }
5038
5039
5028 Object* JSFunction::SetInstancePrototype(Object* value) { 5040 Object* JSFunction::SetInstancePrototype(Object* value) {
5029 ASSERT(value->IsJSObject()); 5041 ASSERT(value->IsJSObject());
5030 5042
5031 if (has_initial_map()) { 5043 if (has_initial_map()) {
5032 initial_map()->set_prototype(value); 5044 initial_map()->set_prototype(value);
5033 } else { 5045 } else {
5034 // Put the value in the initial map field until an initial map is 5046 // Put the value in the initial map field until an initial map is
5035 // needed. At that point, a new initial map is created and the 5047 // needed. At that point, a new initial map is created and the
5036 // prototype is put into the initial map where it belongs. 5048 // prototype is put into the initial map where it belongs.
5037 set_prototype_or_initial_map(value); 5049 set_prototype_or_initial_map(value);
5038 } 5050 }
5039 Heap::ClearInstanceofCache(); 5051 Heap::ClearInstanceofCache();
5040 return value; 5052 return value;
5041 } 5053 }
5042 5054
5043 5055
5044
5045 Object* JSFunction::SetPrototype(Object* value) { 5056 Object* JSFunction::SetPrototype(Object* value) {
5046 ASSERT(should_have_prototype()); 5057 ASSERT(should_have_prototype());
5047 Object* construct_prototype = value; 5058 Object* construct_prototype = value;
5048 5059
5049 // If the value is not a JSObject, store the value in the map's 5060 // If the value is not a JSObject, store the value in the map's
5050 // constructor field so it can be accessed. Also, set the prototype 5061 // constructor field so it can be accessed. Also, set the prototype
5051 // used for constructing objects to the original object prototype. 5062 // used for constructing objects to the original object prototype.
5052 // See ECMA-262 13.2.2. 5063 // See ECMA-262 13.2.2.
5053 if (!value->IsJSObject()) { 5064 if (!value->IsJSObject()) {
5054 // Copy the map so this does not affect unrelated functions. 5065 // Copy the map so this does not affect unrelated functions.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
5262 5273
5263 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { 5274 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
5264 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); 5275 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
5265 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); 5276 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
5266 Object* old_target = target; 5277 Object* old_target = target;
5267 VisitPointer(&target); 5278 VisitPointer(&target);
5268 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. 5279 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target.
5269 } 5280 }
5270 5281
5271 5282
5283 void ObjectVisitor::VisitCodeEntry(Address entry_address) {
5284 Object* code = Code::GetObjectFromEntryAddress(entry_address);
5285 Object* old_code = code;
5286 VisitPointer(&code);
5287 if (code != old_code) {
5288 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry();
5289 }
5290 }
5291
5292
5272 void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) { 5293 void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) {
5273 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) && 5294 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) &&
5274 rinfo->IsPatchedReturnSequence()) || 5295 rinfo->IsPatchedReturnSequence()) ||
5275 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && 5296 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
5276 rinfo->IsPatchedDebugBreakSlotSequence())); 5297 rinfo->IsPatchedDebugBreakSlotSequence()));
5277 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); 5298 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address());
5278 Object* old_target = target; 5299 Object* old_target = target;
5279 VisitPointer(&target); 5300 VisitPointer(&target);
5280 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. 5301 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target.
5281 } 5302 }
(...skipping 3491 matching lines...) Expand 10 before | Expand all | Expand 10 after
8773 if (break_point_objects()->IsUndefined()) return 0; 8794 if (break_point_objects()->IsUndefined()) return 0;
8774 // Single beak point. 8795 // Single beak point.
8775 if (!break_point_objects()->IsFixedArray()) return 1; 8796 if (!break_point_objects()->IsFixedArray()) return 1;
8776 // Multiple break points. 8797 // Multiple break points.
8777 return FixedArray::cast(break_point_objects())->length(); 8798 return FixedArray::cast(break_point_objects())->length();
8778 } 8799 }
8779 #endif 8800 #endif
8780 8801
8781 8802
8782 } } // namespace v8::internal 8803 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698