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

Side by Side Diff: src/deoptimizer.cc

Issue 12049069: Revert r13494: "Use MemoryChunk-based allocation for deoptimization entry code" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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/deoptimizer.h ('k') | src/isolate.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 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 26 matching lines...) Expand all
37 #include "prettyprinter.h" 37 #include "prettyprinter.h"
38 38
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43 DeoptimizerData::DeoptimizerData() { 43 DeoptimizerData::DeoptimizerData() {
44 eager_deoptimization_entry_code_entries_ = -1; 44 eager_deoptimization_entry_code_entries_ = -1;
45 lazy_deoptimization_entry_code_entries_ = -1; 45 lazy_deoptimization_entry_code_entries_ = -1;
46 size_t deopt_table_size = Deoptimizer::GetMaxDeoptTableSize(); 46 size_t deopt_table_size = Deoptimizer::GetMaxDeoptTableSize();
47 MemoryAllocator* allocator = Isolate::Current()->memory_allocator(); 47 eager_deoptimization_entry_code_ = new VirtualMemory(deopt_table_size);
48 size_t initial_commit_size = OS::CommitPageSize(); 48 lazy_deoptimization_entry_code_ = new VirtualMemory(deopt_table_size);
49 eager_deoptimization_entry_code_ =
50 allocator->AllocateChunk(deopt_table_size,
51 initial_commit_size,
52 EXECUTABLE,
53 NULL);
54 lazy_deoptimization_entry_code_ =
55 allocator->AllocateChunk(deopt_table_size,
56 initial_commit_size,
57 EXECUTABLE,
58 NULL);
59 current_ = NULL; 49 current_ = NULL;
60 deoptimizing_code_list_ = NULL; 50 deoptimizing_code_list_ = NULL;
61 #ifdef ENABLE_DEBUGGER_SUPPORT 51 #ifdef ENABLE_DEBUGGER_SUPPORT
62 deoptimized_frame_info_ = NULL; 52 deoptimized_frame_info_ = NULL;
63 #endif 53 #endif
64 } 54 }
65 55
66 56
67 DeoptimizerData::~DeoptimizerData() { 57 DeoptimizerData::~DeoptimizerData() {
68 Isolate::Current()->memory_allocator()->Free( 58 delete eager_deoptimization_entry_code_;
69 eager_deoptimization_entry_code_);
70 eager_deoptimization_entry_code_ = NULL; 59 eager_deoptimization_entry_code_ = NULL;
71 Isolate::Current()->memory_allocator()->Free( 60 delete lazy_deoptimization_entry_code_;
72 lazy_deoptimization_entry_code_);
73 lazy_deoptimization_entry_code_ = NULL; 61 lazy_deoptimization_entry_code_ = NULL;
74 62
75 DeoptimizingCodeListNode* current = deoptimizing_code_list_; 63 DeoptimizingCodeListNode* current = deoptimizing_code_list_;
76 while (current != NULL) { 64 while (current != NULL) {
77 DeoptimizingCodeListNode* prev = current; 65 DeoptimizingCodeListNode* prev = current;
78 current = current->next(); 66 current = current->next();
79 delete prev; 67 delete prev;
80 } 68 }
81 deoptimizing_code_list_ = NULL; 69 deoptimizing_code_list_ = NULL;
82 } 70 }
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 output_ = NULL; 610 output_ = NULL;
623 ASSERT(!HEAP->allow_allocation(true)); 611 ASSERT(!HEAP->allow_allocation(true));
624 } 612 }
625 613
626 614
627 Address Deoptimizer::GetDeoptimizationEntry(int id, 615 Address Deoptimizer::GetDeoptimizationEntry(int id,
628 BailoutType type, 616 BailoutType type,
629 GetEntryMode mode) { 617 GetEntryMode mode) {
630 ASSERT(id >= 0); 618 ASSERT(id >= 0);
631 if (id >= kMaxNumberOfEntries) return NULL; 619 if (id >= kMaxNumberOfEntries) return NULL;
632 MemoryChunk* base = NULL; 620 VirtualMemory* base = NULL;
633 if (mode == ENSURE_ENTRY_CODE) { 621 if (mode == ENSURE_ENTRY_CODE) {
634 EnsureCodeForDeoptimizationEntry(type, id); 622 EnsureCodeForDeoptimizationEntry(type, id);
635 } else { 623 } else {
636 ASSERT(mode == CALCULATE_ENTRY_ADDRESS); 624 ASSERT(mode == CALCULATE_ENTRY_ADDRESS);
637 } 625 }
638 DeoptimizerData* data = Isolate::Current()->deoptimizer_data(); 626 DeoptimizerData* data = Isolate::Current()->deoptimizer_data();
639 if (type == EAGER) { 627 if (type == EAGER) {
640 base = data->eager_deoptimization_entry_code_; 628 base = data->eager_deoptimization_entry_code_;
641 } else { 629 } else {
642 base = data->lazy_deoptimization_entry_code_; 630 base = data->lazy_deoptimization_entry_code_;
643 } 631 }
644 return base->area_start() + (id * table_entry_size_); 632 return
633 static_cast<Address>(base->address()) + (id * table_entry_size_);
645 } 634 }
646 635
647 636
648 int Deoptimizer::GetDeoptimizationId(Address addr, BailoutType type) { 637 int Deoptimizer::GetDeoptimizationId(Address addr, BailoutType type) {
649 MemoryChunk* base = NULL; 638 VirtualMemory* base = NULL;
650 DeoptimizerData* data = Isolate::Current()->deoptimizer_data(); 639 DeoptimizerData* data = Isolate::Current()->deoptimizer_data();
651 if (type == EAGER) { 640 if (type == EAGER) {
652 base = data->eager_deoptimization_entry_code_; 641 base = data->eager_deoptimization_entry_code_;
653 } else { 642 } else {
654 base = data->lazy_deoptimization_entry_code_; 643 base = data->lazy_deoptimization_entry_code_;
655 } 644 }
656 Address start = base->area_start(); 645 Address base_casted = reinterpret_cast<Address>(base->address());
657 if (base == NULL || 646 if (base == NULL ||
658 addr < start || 647 addr < base->address() ||
659 addr >= start + (kMaxNumberOfEntries * table_entry_size_)) { 648 addr >= base_casted + (kMaxNumberOfEntries * table_entry_size_)) {
660 return kNotDeoptimizationEntry; 649 return kNotDeoptimizationEntry;
661 } 650 }
662 ASSERT_EQ(0, 651 ASSERT_EQ(0,
663 static_cast<int>(addr - start) % table_entry_size_); 652 static_cast<int>(addr - base_casted) % table_entry_size_);
664 return static_cast<int>(addr - start) / table_entry_size_; 653 return static_cast<int>(addr - base_casted) / table_entry_size_;
665 } 654 }
666 655
667 656
668 int Deoptimizer::GetOutputInfo(DeoptimizationOutputData* data, 657 int Deoptimizer::GetOutputInfo(DeoptimizationOutputData* data,
669 BailoutId id, 658 BailoutId id,
670 SharedFunctionInfo* shared) { 659 SharedFunctionInfo* shared) {
671 // TODO(kasperl): For now, we do a simple linear search for the PC 660 // TODO(kasperl): For now, we do a simple linear search for the PC
672 // offset associated with the given node id. This should probably be 661 // offset associated with the given node id. This should probably be
673 // changed to a binary search. 662 // changed to a binary search.
674 int length = data->DeoptPoints(); 663 int length = data->DeoptPoints();
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 entry_count = Max(entry_count, Deoptimizer::kMinNumberOfEntries); 1562 entry_count = Max(entry_count, Deoptimizer::kMinNumberOfEntries);
1574 while (max_entry_id >= entry_count) entry_count *= 2; 1563 while (max_entry_id >= entry_count) entry_count *= 2;
1575 ASSERT(entry_count <= Deoptimizer::kMaxNumberOfEntries); 1564 ASSERT(entry_count <= Deoptimizer::kMaxNumberOfEntries);
1576 1565
1577 MacroAssembler masm(Isolate::Current(), NULL, 16 * KB); 1566 MacroAssembler masm(Isolate::Current(), NULL, 16 * KB);
1578 masm.set_emit_debug_code(false); 1567 masm.set_emit_debug_code(false);
1579 GenerateDeoptimizationEntries(&masm, entry_count, type); 1568 GenerateDeoptimizationEntries(&masm, entry_count, type);
1580 CodeDesc desc; 1569 CodeDesc desc;
1581 masm.GetCode(&desc); 1570 masm.GetCode(&desc);
1582 1571
1583 MemoryChunk* chunk = type == EAGER 1572 VirtualMemory* memory = type == EAGER
1584 ? data->eager_deoptimization_entry_code_ 1573 ? data->eager_deoptimization_entry_code_
1585 : data->lazy_deoptimization_entry_code_; 1574 : data->lazy_deoptimization_entry_code_;
1586 ASSERT(static_cast<int>(Deoptimizer::GetMaxDeoptTableSize()) >= 1575 size_t table_size = Deoptimizer::GetMaxDeoptTableSize();
1587 desc.instr_size); 1576 ASSERT(static_cast<int>(table_size) >= desc.instr_size);
1588 chunk->CommitArea(desc.instr_size); 1577 memory->Commit(memory->address(), table_size, true);
1589 memcpy(chunk->area_start(), desc.buffer, desc.instr_size); 1578 memcpy(memory->address(), desc.buffer, desc.instr_size);
1590 CPU::FlushICache(chunk->area_start(), desc.instr_size); 1579 CPU::FlushICache(memory->address(), desc.instr_size);
1591 1580
1592 if (type == EAGER) { 1581 if (type == EAGER) {
1593 data->eager_deoptimization_entry_code_entries_ = entry_count; 1582 data->eager_deoptimization_entry_code_entries_ = entry_count;
1594 } else { 1583 } else {
1595 data->lazy_deoptimization_entry_code_entries_ = entry_count; 1584 data->lazy_deoptimization_entry_code_entries_ = entry_count;
1596 } 1585 }
1597 } 1586 }
1598 1587
1599 1588
1600 void Deoptimizer::ReplaceCodeForRelatedFunctions(JSFunction* function, 1589 void Deoptimizer::ReplaceCodeForRelatedFunctions(JSFunction* function,
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 2111
2123 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 2112 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
2124 v->VisitPointer(BitCast<Object**>(&function_)); 2113 v->VisitPointer(BitCast<Object**>(&function_));
2125 v->VisitPointers(parameters_, parameters_ + parameters_count_); 2114 v->VisitPointers(parameters_, parameters_ + parameters_count_);
2126 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 2115 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
2127 } 2116 }
2128 2117
2129 #endif // ENABLE_DEBUGGER_SUPPORT 2118 #endif // ENABLE_DEBUGGER_SUPPORT
2130 2119
2131 } } // namespace v8::internal 2120 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/deoptimizer.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698