Commit c7cddee6 authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC: Move hashmap into src/base.

Port 2fd55667

Original commit message:

    We ported hashmap.h into libsampler as a workaround before, so the main focus of
    this patch is to reduce code duplication. This patch moves the hashmap into
    src/base as well as creates DefaultAllocationPolicy using malloc and free.

R=lpy@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com

BUG=v8:5050
LOG=N

Review-Url: https://codereview.chromium.org/2057263002
Cr-Commit-Position: refs/heads/master@{#36900}
parent 817dcf28
...@@ -707,7 +707,7 @@ void Simulator::set_last_debugger_input(char* input) { ...@@ -707,7 +707,7 @@ void Simulator::set_last_debugger_input(char* input) {
} }
void Simulator::FlushICache(v8::internal::HashMap* i_cache, void* start_addr, void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr,
size_t size) { size_t size) {
intptr_t start = reinterpret_cast<intptr_t>(start_addr); intptr_t start = reinterpret_cast<intptr_t>(start_addr);
int intra_line = (start & CachePage::kLineMask); int intra_line = (start & CachePage::kLineMask);
...@@ -729,9 +729,8 @@ void Simulator::FlushICache(v8::internal::HashMap* i_cache, void* start_addr, ...@@ -729,9 +729,8 @@ void Simulator::FlushICache(v8::internal::HashMap* i_cache, void* start_addr,
} }
CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) { CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) {
v8::internal::HashMap::Entry* entry = base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
i_cache->LookupOrInsert(page, ICacheHash(page));
if (entry->value == NULL) { if (entry->value == NULL) {
CachePage* new_page = new CachePage(); CachePage* new_page = new CachePage();
entry->value = new_page; entry->value = new_page;
...@@ -741,8 +740,7 @@ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) { ...@@ -741,8 +740,7 @@ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
// Flush from start up to and not including start + size. // Flush from start up to and not including start + size.
void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start, int size) {
int size) {
DCHECK(size <= CachePage::kPageSize); DCHECK(size <= CachePage::kPageSize);
DCHECK(AllOnOnePage(start, size - 1)); DCHECK(AllOnOnePage(start, size - 1));
DCHECK((start & CachePage::kLineMask) == 0); DCHECK((start & CachePage::kLineMask) == 0);
...@@ -754,9 +752,7 @@ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, ...@@ -754,9 +752,7 @@ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
} }
void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) {
void Simulator::CheckICache(v8::internal::HashMap* i_cache,
Instruction* instr) {
intptr_t address = reinterpret_cast<intptr_t>(instr); intptr_t address = reinterpret_cast<intptr_t>(instr);
void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask)); void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask)); void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
...@@ -789,7 +785,7 @@ void Simulator::Initialize(Isolate* isolate) { ...@@ -789,7 +785,7 @@ void Simulator::Initialize(Isolate* isolate) {
Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
i_cache_ = isolate_->simulator_i_cache(); i_cache_ = isolate_->simulator_i_cache();
if (i_cache_ == NULL) { if (i_cache_ == NULL) {
i_cache_ = new v8::internal::HashMap(&ICacheMatch); i_cache_ = new base::HashMap(&ICacheMatch);
isolate_->set_simulator_i_cache(i_cache_); isolate_->set_simulator_i_cache(i_cache_);
} }
Initialize(isolate); Initialize(isolate);
...@@ -925,10 +921,10 @@ class Redirection { ...@@ -925,10 +921,10 @@ class Redirection {
// static // static
void Simulator::TearDown(HashMap* i_cache, Redirection* first) { void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
Redirection::DeleteChain(first); Redirection::DeleteChain(first);
if (i_cache != nullptr) { if (i_cache != nullptr) {
for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr; for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
entry = i_cache->Next(entry)) { entry = i_cache->Next(entry)) {
delete static_cast<CachePage*>(entry->value); delete static_cast<CachePage*>(entry->value);
} }
......
...@@ -217,7 +217,7 @@ class Simulator { ...@@ -217,7 +217,7 @@ class Simulator {
// Call on program start. // Call on program start.
static void Initialize(Isolate* isolate); static void Initialize(Isolate* isolate);
static void TearDown(HashMap* i_cache, Redirection* first); static void TearDown(base::HashMap* i_cache, Redirection* first);
// V8 generally calls into generated JS code with 5 parameters and into // V8 generally calls into generated JS code with 5 parameters and into
// generated RegExp code with 7 parameters. This is a convenience function, // generated RegExp code with 7 parameters. This is a convenience function,
...@@ -239,8 +239,7 @@ class Simulator { ...@@ -239,8 +239,7 @@ class Simulator {
char* last_debugger_input() { return last_debugger_input_; } char* last_debugger_input() { return last_debugger_input_; }
// ICache checking. // ICache checking.
static void FlushICache(v8::internal::HashMap* i_cache, void* start, static void FlushICache(base::HashMap* i_cache, void* start, size_t size);
size_t size);
// Returns true if pc register contains one of the 'special_values' defined // Returns true if pc register contains one of the 'special_values' defined
// below (bad_lr, end_sim_pc). // below (bad_lr, end_sim_pc).
...@@ -330,10 +329,9 @@ class Simulator { ...@@ -330,10 +329,9 @@ class Simulator {
void ExecuteInstruction(Instruction* instr); void ExecuteInstruction(Instruction* instr);
// ICache. // ICache.
static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr); static void CheckICache(base::HashMap* i_cache, Instruction* instr);
static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start, static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size);
int size); static CachePage* GetCachePage(base::HashMap* i_cache, void* page);
static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
// Runtime call support. // Runtime call support.
static void* RedirectExternalReference( static void* RedirectExternalReference(
...@@ -371,7 +369,7 @@ class Simulator { ...@@ -371,7 +369,7 @@ class Simulator {
char* last_debugger_input_; char* last_debugger_input_;
// Icache simulation // Icache simulation
v8::internal::HashMap* i_cache_; base::HashMap* i_cache_;
// Registered breakpoints. // Registered breakpoints.
Instruction* break_pc_; Instruction* break_pc_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment