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

Unified Diff: runtime/vm/kernel_binary.cc

Issue 2654983002: Revert "Revert "Revert "Removed usage of std::map and std::vector from kernel code. Issue #28064.""" (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/kernel_reader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_binary.cc
diff --git a/runtime/vm/kernel_binary.cc b/runtime/vm/kernel_binary.cc
index ec71cd838da1887d5715c868118aa40ec8a3ae88..1f56c09be4e28396926cbec1b9673725f9df2d19 100644
--- a/runtime/vm/kernel_binary.cc
+++ b/runtime/vm/kernel_binary.cc
@@ -3,11 +3,12 @@
// BSD-style license that can be found in the LICENSE file.
#if !defined(DART_PRECOMPILED_RUNTIME)
+#include <map>
+#include <vector>
+
#include "platform/globals.h"
#include "vm/flags.h"
-#include "vm/growable_array.h"
#include "vm/kernel.h"
-#include "vm/kernel_to_il.h"
#include "vm/os.h"
#if defined(DEBUG)
@@ -152,47 +153,47 @@ class BlockStack {
BlockStack() : current_count_(0) {}
void EnterScope() {
- variable_count_.Add(current_count_);
+ variable_count_.push_back(current_count_);
current_count_ = 0;
}
void LeaveScope() {
- variables_.TruncateTo(variables_.length() - current_count_);
- current_count_ = variable_count_[variable_count_.length() - 1];
- variable_count_.RemoveLast();
+ variables_.resize(variables_.size() - current_count_);
+ current_count_ = variable_count_[variable_count_.size() - 1];
+ variable_count_.pop_back();
}
T* Lookup(int index) {
- ASSERT(index < variables_.length());
+ ASSERT(static_cast<unsigned>(index) < variables_.size());
return variables_[index];
}
void Push(T* v) {
- variables_.Add(v);
+ variables_.push_back(v);
current_count_++;
}
void Push(List<T>* decl) {
for (int i = 0; i < decl->length(); i++) {
- variables_.Add(decl[i]);
+ variables_.push_back(decl[i]);
current_count_++;
}
}
void Pop(T* decl) {
- variables_.RemoveLast();
+ variables_.resize(variables_.size() - 1);
current_count_--;
}
void Pop(List<T>* decl) {
- variables_.TruncateTo(variables_.length() - decl->length());
+ variables_.resize(variables_.size() - decl->length());
current_count_ -= decl->length();
}
private:
int current_count_;
- GrowableArray<T*> variables_;
- GrowableArray<int> variable_count_;
+ std::vector<T*> variables_;
+ std::vector<int> variable_count_;
};
@@ -202,35 +203,29 @@ class BlockMap {
BlockMap() : current_count_(0), stack_height_(0) {}
void EnterScope() {
- variable_count_.Add(current_count_);
+ variable_count_.push_back(current_count_);
current_count_ = 0;
}
void LeaveScope() {
stack_height_ -= current_count_;
- current_count_ = variable_count_[variable_count_.length() - 1];
- variable_count_.RemoveLast();
+ current_count_ = variable_count_[variable_count_.size() - 1];
+ variable_count_.pop_back();
}
int Lookup(T* object) {
- typename Map<T, int>::Pair* result = variables_.LookupPair(object);
- ASSERT(result != NULL);
- if (result == NULL) FATAL("lookup failure");
- return RawPointerKeyValueTrait<T, int>::ValueOf(*result);
+ ASSERT(variables_.find(object) != variables_.end());
+ if (variables_.find(object) == variables_.end()) FATAL("lookup failure");
+ return variables_[object];
}
void Push(T* v) {
- ASSERT(variables_.LookupPair(v) == NULL);
int index = stack_height_++;
- variables_.Insert(v, index);
+ variables_[v] = index;
current_count_++;
}
- void Set(T* v, int index) {
- typename Map<T, int>::Pair* entry = variables_.LookupPair(v);
- ASSERT(entry != NULL);
- entry->value = index;
- }
+ void Set(T* v, int index) { variables_[v] = index; }
void Push(List<T>* decl) {
for (int i = 0; i < decl->length(); i++) {
@@ -246,8 +241,8 @@ class BlockMap {
private:
int current_count_;
int stack_height_;
- Map<T, int> variables_;
- GrowableArray<int> variable_count_;
+ std::map<T*, int> variables_;
+ std::vector<int> variable_count_;
};
« no previous file with comments | « no previous file | runtime/vm/kernel_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698