OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 jsfunction_candidates_head_(NULL), | 419 jsfunction_candidates_head_(NULL), |
420 shared_function_info_candidates_head_(NULL) {} | 420 shared_function_info_candidates_head_(NULL) {} |
421 | 421 |
422 void AddCandidate(SharedFunctionInfo* shared_info) { | 422 void AddCandidate(SharedFunctionInfo* shared_info) { |
423 SetNextCandidate(shared_info, shared_function_info_candidates_head_); | 423 SetNextCandidate(shared_info, shared_function_info_candidates_head_); |
424 shared_function_info_candidates_head_ = shared_info; | 424 shared_function_info_candidates_head_ = shared_info; |
425 } | 425 } |
426 | 426 |
427 void AddCandidate(JSFunction* function) { | 427 void AddCandidate(JSFunction* function) { |
428 ASSERT(function->code() == function->shared()->code()); | 428 ASSERT(function->code() == function->shared()->code()); |
| 429 ASSERT(function->next_function_link()->IsUndefined()); |
429 SetNextCandidate(function, jsfunction_candidates_head_); | 430 SetNextCandidate(function, jsfunction_candidates_head_); |
430 jsfunction_candidates_head_ = function; | 431 jsfunction_candidates_head_ = function; |
431 } | 432 } |
432 | 433 |
433 void ProcessCandidates() { | 434 void ProcessCandidates() { |
434 ProcessSharedFunctionInfoCandidates(); | 435 ProcessSharedFunctionInfoCandidates(); |
435 ProcessJSFunctionCandidates(); | 436 ProcessJSFunctionCandidates(); |
436 } | 437 } |
437 | 438 |
438 private: | 439 private: |
439 void ProcessJSFunctionCandidates(); | 440 void ProcessJSFunctionCandidates(); |
440 void ProcessSharedFunctionInfoCandidates(); | 441 void ProcessSharedFunctionInfoCandidates(); |
441 | 442 |
442 static JSFunction** GetNextCandidateField(JSFunction* candidate) { | |
443 return reinterpret_cast<JSFunction**>( | |
444 candidate->address() + JSFunction::kCodeEntryOffset); | |
445 } | |
446 | |
447 static JSFunction* GetNextCandidate(JSFunction* candidate) { | 443 static JSFunction* GetNextCandidate(JSFunction* candidate) { |
448 return *GetNextCandidateField(candidate); | 444 Object* next_candidate = candidate->next_function_link(); |
| 445 return reinterpret_cast<JSFunction*>(next_candidate); |
449 } | 446 } |
450 | 447 |
451 static void SetNextCandidate(JSFunction* candidate, | 448 static void SetNextCandidate(JSFunction* candidate, |
452 JSFunction* next_candidate) { | 449 JSFunction* next_candidate) { |
453 *GetNextCandidateField(candidate) = next_candidate; | 450 candidate->set_next_function_link(next_candidate); |
454 } | 451 } |
455 | 452 |
456 static SharedFunctionInfo** GetNextCandidateField( | 453 static void ClearNextCandidate(JSFunction* candidate, Object* undefined) { |
457 SharedFunctionInfo* candidate) { | 454 ASSERT(undefined->IsUndefined()); |
458 Code* code = candidate->code(); | 455 candidate->set_next_function_link(undefined, SKIP_WRITE_BARRIER); |
459 return reinterpret_cast<SharedFunctionInfo**>( | |
460 code->address() + Code::kGCMetadataOffset); | |
461 } | 456 } |
462 | 457 |
463 static SharedFunctionInfo* GetNextCandidate(SharedFunctionInfo* candidate) { | 458 static SharedFunctionInfo* GetNextCandidate(SharedFunctionInfo* candidate) { |
464 return reinterpret_cast<SharedFunctionInfo*>( | 459 Object* next_candidate = candidate->code()->gc_metadata(); |
465 candidate->code()->gc_metadata()); | 460 return reinterpret_cast<SharedFunctionInfo*>(next_candidate); |
466 } | 461 } |
467 | 462 |
468 static void SetNextCandidate(SharedFunctionInfo* candidate, | 463 static void SetNextCandidate(SharedFunctionInfo* candidate, |
469 SharedFunctionInfo* next_candidate) { | 464 SharedFunctionInfo* next_candidate) { |
470 candidate->code()->set_gc_metadata(next_candidate); | 465 candidate->code()->set_gc_metadata(next_candidate); |
471 } | 466 } |
472 | 467 |
| 468 static void ClearNextCandidate(SharedFunctionInfo* candidate) { |
| 469 candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER); |
| 470 } |
| 471 |
473 Isolate* isolate_; | 472 Isolate* isolate_; |
474 JSFunction* jsfunction_candidates_head_; | 473 JSFunction* jsfunction_candidates_head_; |
475 SharedFunctionInfo* shared_function_info_candidates_head_; | 474 SharedFunctionInfo* shared_function_info_candidates_head_; |
476 | 475 |
477 DISALLOW_COPY_AND_ASSIGN(CodeFlusher); | 476 DISALLOW_COPY_AND_ASSIGN(CodeFlusher); |
478 }; | 477 }; |
479 | 478 |
480 | 479 |
481 // Defined in isolate.h. | 480 // Defined in isolate.h. |
482 class ThreadLocalTop; | 481 class ThreadLocalTop; |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 | 832 |
834 friend class Heap; | 833 friend class Heap; |
835 }; | 834 }; |
836 | 835 |
837 | 836 |
838 const char* AllocationSpaceName(AllocationSpace space); | 837 const char* AllocationSpaceName(AllocationSpace space); |
839 | 838 |
840 } } // namespace v8::internal | 839 } } // namespace v8::internal |
841 | 840 |
842 #endif // V8_MARK_COMPACT_H_ | 841 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |