From 9a46c6f919199b9c53dd5ab69f49a1b95ca1c5b4 Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Wed, 30 Mar 2011 15:31:16 +0000 Subject: [PATCH] Reduce handle usage in type-info.cc PopulateMap. BUG=none TEST=none Review URL: http://codereview.chromium.org/6771008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7444 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/type-info.cc | 34 ++++++++++++++++++---------------- src/type-info.h | 2 ++ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/type-info.cc b/src/type-info.cc index 78f693c..d73c618 100644 --- a/src/type-info.cc +++ b/src/type-info.cc @@ -355,6 +355,15 @@ ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(int position, } +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) { Isolate* isolate = Isolate::Current(); HandleScope scope(isolate); @@ -371,14 +380,14 @@ void TypeFeedbackOracle::PopulateMap(Handle code) { 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 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 value; + if (kind == Code::BINARY_OP_IC || kind == Code::TYPE_RECORDING_BINARY_OP_IC || kind == Code::COMPARE_IC) { @@ -387,35 +396,28 @@ void TypeFeedbackOracle::PopulateMap(Handle code) { // 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); + SetInfo(position, map); } } else { ASSERT(target->kind() == Code::CALL_IC); CheckType check = target->check_type(); ASSERT(check != RECEIVER_MAP_CHECK); - value = Handle(Smi::FromInt(check)); + SetInfo(position, Smi::FromInt(check)); } } else if (state == MEGAMORPHIC) { - value = target; - } - - if (!value.is_null()) { - Handle new_dict = - isolate->factory()->DictionaryAtNumberPut( - dictionary_, position, value); - dictionary_ = loop_scope.CloseAndEscape(new_dict); + SetInfo(position, target); } } // Allocate handle in the parent scope. diff --git a/src/type-info.h b/src/type-info.h index c068489..9b69526 100644 --- a/src/type-info.h +++ b/src/type-info.h @@ -267,6 +267,8 @@ class TypeFeedbackOracle BASE_EMBEDDED { Handle name, Code::Flags flags); + void SetInfo(int position, Object* target); + void PopulateMap(Handle code); void CollectPositions(Code* code, -- 2.7.4