Revision: 7444
Author: [email protected]
Date: Wed Mar 30 08:31:16 2011
Log: Reduce handle usage in type-info.cc PopulateMap.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6771008
http://code.google.com/p/v8/source/detail?r=7444
Modified:
/branches/bleeding_edge/src/type-info.cc
/branches/bleeding_edge/src/type-info.h
=======================================
--- /branches/bleeding_edge/src/type-info.cc Wed Mar 23 06:40:07 2011
+++ /branches/bleeding_edge/src/type-info.cc Wed Mar 30 08:31:16 2011
@@ -353,6 +353,15 @@
return NULL;
}
}
+
+
+void TypeFeedbackOracle::SetInfo(int position, Object* target) {
+ MaybeObject* maybe_result = dictionary_->AtNumberPut(position, target);
+ Object* result;
+ // Dictionary has been allocated with sufficient size for all elements.
+ ASSERT(maybe_result->ToObject(&result));
+ ASSERT(*dictionary_ == result);
+}
void TypeFeedbackOracle::PopulateMap(Handle<Code> code) {
@@ -371,14 +380,14 @@
int length = code_positions.length();
ASSERT(source_positions.length() == length);
for (int i = 0; i < length; i++) {
- HandleScope loop_scope(isolate);
+ AssertNoAllocation no_allocation();
RelocInfo info(code->instruction_start() + code_positions[i],
RelocInfo::CODE_TARGET, 0);
- Handle<Code>
target(Code::GetCodeFromTargetAddress(info.target_address()));
+ 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) {
@@ -387,35 +396,28 @@
// recorded for all binary ICs.
int entry = dictionary_->FindEntry(position);
if (entry == NumberDictionary::kNotFound) {
- value = target;
+ SetInfo(position, target);
}
} else if (state == MONOMORPHIC) {
if (kind == Code::KEYED_EXTERNAL_ARRAY_LOAD_IC ||
kind == Code::KEYED_EXTERNAL_ARRAY_STORE_IC) {
- value = target;
+ SetInfo(position, target);
} else if (target->kind() != Code::CALL_IC ||
target->check_type() == RECEIVER_MAP_CHECK) {
Map* map = target->FindFirstMap();
if (map == NULL) {
- value = target;
+ SetInfo(position, target);
} else {
- value = Handle<Map>(map);
+ SetInfo(position, map);
}
} else {
ASSERT(target->kind() == Code::CALL_IC);
CheckType check = target->check_type();
ASSERT(check != RECEIVER_MAP_CHECK);
- value = Handle<Object>(Smi::FromInt(check));
+ SetInfo(position, Smi::FromInt(check));
}
} else if (state == MEGAMORPHIC) {
- value = target;
- }
-
- if (!value.is_null()) {
- Handle<NumberDictionary> new_dict =
- isolate->factory()->DictionaryAtNumberPut(
- dictionary_, position, value);
- dictionary_ = loop_scope.CloseAndEscape(new_dict);
+ SetInfo(position, target);
}
}
// Allocate handle in the parent scope.
=======================================
--- /branches/bleeding_edge/src/type-info.h Wed Mar 9 07:01:16 2011
+++ /branches/bleeding_edge/src/type-info.h Wed Mar 30 08:31:16 2011
@@ -267,6 +267,8 @@
Handle<String> name,
Code::Flags flags);
+ void SetInfo(int position, Object* target);
+
void PopulateMap(Handle<Code> code);
void CollectPositions(Code* code,
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev