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

Side by Side Diff: src/mark-compact.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/liveedit.cc ('k') | src/objects.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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 249
250 class StaticMarkingVisitor : public StaticVisitorBase { 250 class StaticMarkingVisitor : public StaticVisitorBase {
251 public: 251 public:
252 static inline void IterateBody(Map* map, HeapObject* obj) { 252 static inline void IterateBody(Map* map, HeapObject* obj) {
253 table_.GetVisitor(map)(map, obj); 253 table_.GetVisitor(map)(map, obj);
254 } 254 }
255 255
256 static void EnableCodeFlushing(bool enabled) { 256 static void EnableCodeFlushing(bool enabled) {
257 if (enabled) { 257 if (enabled) {
258 table_.Register(kVisitJSFunction, &VisitJSFunctionAndFlushCode);
259 } else {
258 table_.Register(kVisitJSFunction, &VisitJSFunction); 260 table_.Register(kVisitJSFunction, &VisitJSFunction);
259 } else {
260 table_.Register(kVisitJSFunction,
261 &JSObjectVisitor::VisitSpecialized<JSFunction::kSize>);
262 } 261 }
263 } 262 }
264 263
265 static void Initialize() { 264 static void Initialize() {
266 table_.Register(kVisitShortcutCandidate, 265 table_.Register(kVisitShortcutCandidate,
267 &FixedBodyVisitor<StaticMarkingVisitor, 266 &FixedBodyVisitor<StaticMarkingVisitor,
268 ConsString::BodyDescriptor, 267 ConsString::BodyDescriptor,
269 void>::Visit); 268 void>::Visit);
270 269
271 table_.Register(kVisitConsString, 270 table_.Register(kVisitConsString,
(...skipping 20 matching lines...) Expand all
292 &FixedBodyVisitor<StaticMarkingVisitor, 291 &FixedBodyVisitor<StaticMarkingVisitor,
293 Oddball::BodyDescriptor, 292 Oddball::BodyDescriptor,
294 void>::Visit); 293 void>::Visit);
295 table_.Register(kVisitMap, 294 table_.Register(kVisitMap,
296 &FixedBodyVisitor<StaticMarkingVisitor, 295 &FixedBodyVisitor<StaticMarkingVisitor,
297 Map::BodyDescriptor, 296 Map::BodyDescriptor,
298 void>::Visit); 297 void>::Visit);
299 298
300 table_.Register(kVisitCode, &VisitCode); 299 table_.Register(kVisitCode, &VisitCode);
301 300
302 table_.Register(kVisitJSFunction, &VisitJSFunction); 301 table_.Register(kVisitJSFunction, &VisitJSFunctionAndFlushCode);
303 302
304 table_.Register(kVisitPropertyCell, 303 table_.Register(kVisitPropertyCell,
305 &FixedBodyVisitor<StaticMarkingVisitor, 304 &FixedBodyVisitor<StaticMarkingVisitor,
306 JSGlobalPropertyCell::BodyDescriptor, 305 JSGlobalPropertyCell::BodyDescriptor,
307 void>::Visit); 306 void>::Visit);
308 307
309 table_.RegisterSpecializations<DataObjectVisitor, 308 table_.RegisterSpecializations<DataObjectVisitor,
310 kVisitDataObject, 309 kVisitDataObject,
311 kVisitDataObjectGeneric>(); 310 kVisitDataObjectGeneric>();
312 311
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 Context* context = reinterpret_cast<Context*>(ctx); 526 Context* context = reinterpret_cast<Context*>(ctx);
528 527
529 if (IsJSBuiltinsObject(context->global())) { 528 if (IsJSBuiltinsObject(context->global())) {
530 return false; 529 return false;
531 } 530 }
532 531
533 return true; 532 return true;
534 } 533 }
535 534
536 535
536 static void VisitCodeEntry(Address entry_address) {
537 Object* code = Code::GetObjectFromEntryAddress(entry_address);
538 Object* old_code = code;
539 VisitPointer(&code);
540 if (code != old_code) {
541 Memory::Address_at(entry_address) =
542 reinterpret_cast<Code*>(code)->entry();
543 }
544 }
545
546
547 static void VisitJSFunctionAndFlushCode(Map* map, HeapObject* object) {
548 JSFunction* jsfunction = reinterpret_cast<JSFunction*>(object);
549 // The function must have a valid context and not be a builtin.
550 if (IsValidNotBuiltinContext(jsfunction->unchecked_context())) {
551 FlushCodeForFunction(jsfunction);
552 }
553 VisitJSFunction(map, object);
554 }
555
556
537 static void VisitJSFunction(Map* map, HeapObject* object) { 557 static void VisitJSFunction(Map* map, HeapObject* object) {
538 JSFunction* jsfunction = reinterpret_cast<JSFunction*>(object); 558 #define SLOT_ADDR(obj, offset) \
559 reinterpret_cast<Object**>((obj)->address() + offset)
539 560
540 // The function must have a valid context and not be a builtin. 561 VisitPointers(SLOT_ADDR(object, JSFunction::kPropertiesOffset),
541 if (IsValidNotBuiltinContext(jsfunction->unchecked_context())) { 562 SLOT_ADDR(object, JSFunction::kCodeEntryOffset));
542 FlushCodeForFunction(jsfunction);
543 }
544 563
545 JSObjectVisitor::VisitSpecialized<JSFunction::kSize>(map, object); 564 VisitCodeEntry(object->address() + JSFunction::kCodeEntryOffset);
565
566 VisitPointers(SLOT_ADDR(object,
567 JSFunction::kCodeEntryOffset + kPointerSize),
568 SLOT_ADDR(object, JSFunction::kSize));
569 #undef SLOT_ADDR
546 } 570 }
547 571
572
548 typedef void (*Callback)(Map* map, HeapObject* object); 573 typedef void (*Callback)(Map* map, HeapObject* object);
549 574
550 static VisitorDispatchTable<Callback> table_; 575 static VisitorDispatchTable<Callback> table_;
551 }; 576 };
552 577
553 578
554 VisitorDispatchTable<StaticMarkingVisitor::Callback> 579 VisitorDispatchTable<StaticMarkingVisitor::Callback>
555 StaticMarkingVisitor::table_; 580 StaticMarkingVisitor::table_;
556 581
557 582
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 } 2664 }
2640 2665
2641 2666
2642 void MarkCompactCollector::Initialize() { 2667 void MarkCompactCollector::Initialize() {
2643 StaticPointersToNewGenUpdatingVisitor::Initialize(); 2668 StaticPointersToNewGenUpdatingVisitor::Initialize();
2644 StaticMarkingVisitor::Initialize(); 2669 StaticMarkingVisitor::Initialize();
2645 } 2670 }
2646 2671
2647 2672
2648 } } // namespace v8::internal 2673 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/liveedit.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698