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

Unified Diff: src/type-info.cc

Issue 6624085: [Isolates] Merge 7051:7083 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 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 | « src/type-info.h ('k') | src/version.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/type-info.cc
===================================================================
--- src/type-info.cc (revision 7083)
+++ src/type-info.cc (working copy)
@@ -64,43 +64,44 @@
TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code,
Handle<Context> global_context) {
global_context_ = global_context;
- Initialize(code);
+ PopulateMap(code);
+ ASSERT(reinterpret_cast<Address>(*dictionary_.location()) != kHandleZapValue);
}
-void TypeFeedbackOracle::Initialize(Handle<Code> code) {
- Isolate* isolate = Isolate::Current();
- ASSERT(map_.is_null()); // Only initialize once.
- map_ = isolate->factory()->NewJSObject(isolate->object_function());
- PopulateMap(code);
+Handle<Object> TypeFeedbackOracle::GetInfo(int pos) {
+ int entry = dictionary_->FindEntry(pos);
+ return entry != NumberDictionary::kNotFound
+ ? Handle<Object>(dictionary_->ValueAt(entry))
+ : Isolate::Current()->factory()->undefined_value();
}
bool TypeFeedbackOracle::LoadIsMonomorphic(Property* expr) {
- return GetElement(map_, expr->position())->IsMap();
+ return GetInfo(expr->position())->IsMap();
}
bool TypeFeedbackOracle:: StoreIsMonomorphic(Assignment* expr) {
- return GetElement(map_, expr->position())->IsMap();
+ return GetInfo(expr->position())->IsMap();
}
bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) {
- Handle<Object> value = GetElement(map_, expr->position());
+ Handle<Object> value = GetInfo(expr->position());
return value->IsMap() || value->IsSmi();
}
Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) {
ASSERT(LoadIsMonomorphic(expr));
- return Handle<Map>::cast(GetElement(map_, expr->position()));
+ return Handle<Map>::cast(GetInfo(expr->position()));
}
Handle<Map> TypeFeedbackOracle::StoreMonomorphicReceiverType(Assignment* expr) {
ASSERT(StoreIsMonomorphic(expr));
- return Handle<Map>::cast(GetElement(map_, expr->position()));
+ return Handle<Map>::cast(GetInfo(expr->position()));
}
@@ -136,7 +137,7 @@
CheckType TypeFeedbackOracle::GetCallCheckType(Call* expr) {
- Handle<Object> value = GetElement(map_, expr->position());
+ Handle<Object> value = GetInfo(expr->position());
if (!value->IsSmi()) return RECEIVER_MAP_CHECK;
CheckType check = static_cast<CheckType>(Smi::cast(*value)->value());
ASSERT(check != RECEIVER_MAP_CHECK);
@@ -167,13 +168,13 @@
bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) {
- Handle<Object> object = GetElement(map_, expr->position());
- return *object == Isolate::Current()->builtins()->builtin(id);
+ return *GetInfo(expr->position()) ==
+ Isolate::Current()->builtins()->builtin(id);
}
TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr) {
- Handle<Object> object = GetElement(map_, expr->position());
+ Handle<Object> object = GetInfo(expr->position());
TypeInfo unknown = TypeInfo::Unknown();
if (!object->IsCode()) return unknown;
Handle<Code> code = Handle<Code>::cast(object);
@@ -200,7 +201,7 @@
TypeInfo TypeFeedbackOracle::BinaryType(BinaryOperation* expr) {
- Handle<Object> object = GetElement(map_, expr->position());
+ Handle<Object> object = GetInfo(expr->position());
TypeInfo unknown = TypeInfo::Unknown();
if (!object->IsCode()) return unknown;
Handle<Code> code = Handle<Code>::cast(object);
@@ -262,7 +263,7 @@
TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) {
- Handle<Object> object = GetElement(map_, clause->position());
+ Handle<Object> object = GetInfo(clause->position());
TypeInfo unknown = TypeInfo::Unknown();
if (!object->IsCode()) return unknown;
Handle<Code> code = Handle<Code>::cast(object);
@@ -292,7 +293,7 @@
Handle<String> name,
Code::Flags flags) {
Isolate* isolate = Isolate::Current();
- Handle<Object> object = GetElement(map_, position);
+ Handle<Object> object = GetInfo(position);
if (object->IsUndefined() || object->IsSmi()) return NULL;
if (*object == isolate->builtins()->builtin(Builtins::StoreIC_GlobalProxy)) {
@@ -316,51 +317,67 @@
void TypeFeedbackOracle::PopulateMap(Handle<Code> code) {
- HandleScope scope;
+ Isolate* isolate = Isolate::Current();
+ HandleScope scope(isolate);
const int kInitialCapacity = 16;
List<int> code_positions(kInitialCapacity);
List<int> source_positions(kInitialCapacity);
CollectPositions(*code, &code_positions, &source_positions);
+ ASSERT(dictionary_.is_null()); // Only initialize once.
+ dictionary_ = isolate->factory()->NewNumberDictionary(
+ code_positions.length());
+
int length = code_positions.length();
ASSERT(source_positions.length() == length);
for (int i = 0; i < length; i++) {
+ HandleScope loop_scope(isolate);
RelocInfo info(code->instruction_start() + code_positions[i],
RelocInfo::CODE_TARGET, 0);
Handle<Code> target(Code::GetCodeFromTargetAddress(info.target_address()));
int position = source_positions[i];
InlineCacheState state = target->ic_state();
Code::Kind kind = target->kind();
+ Handle<Object> value;
if (kind == Code::BINARY_OP_IC ||
kind == Code::TYPE_RECORDING_BINARY_OP_IC ||
kind == Code::COMPARE_IC) {
// TODO(kasperl): Avoid having multiple ICs with the same
// position by making sure that we have position information
// recorded for all binary ICs.
- if (GetElement(map_, position)->IsUndefined()) {
- SetElement(map_, position, target);
+ int entry = dictionary_->FindEntry(position);
+ if (entry == NumberDictionary::kNotFound) {
+ value = target;
}
} else if (state == MONOMORPHIC) {
if (target->kind() != Code::CALL_IC ||
target->check_type() == RECEIVER_MAP_CHECK) {
Map* map = target->FindFirstMap();
if (map == NULL) {
- SetElement(map_, position, target);
+ value = target;
} else {
- SetElement(map_, position, Handle<Map>(map));
+ value = Handle<Map>(map);
}
} else {
ASSERT(target->kind() == Code::CALL_IC);
CheckType check = target->check_type();
ASSERT(check != RECEIVER_MAP_CHECK);
- SetElement(map_, position, Handle<Object>(Smi::FromInt(check)));
- ASSERT(Smi::cast(*GetElement(map_, position))->value() == check);
+ value = Handle<Object>(Smi::FromInt(check));
}
} else if (state == MEGAMORPHIC) {
- SetElement(map_, position, target);
+ value = target;
}
+
+ if (!value.is_null()) {
+ Handle<NumberDictionary> new_dict =
+ isolate->factory()->DictionaryAtNumberPut(
+ dictionary_, position, value);
+ dictionary_ = loop_scope.CloseAndEscape(new_dict);
+ }
}
+ // Allocate handle in the parent scope.
+ dictionary_ = scope.CloseAndEscape(dictionary_);
}
« no previous file with comments | « src/type-info.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698