| Index: src/type-info.cc
|
| diff --git a/src/type-info.cc b/src/type-info.cc
|
| index 5f6022b6f133ac8631b7b5fad28e687febd9e151..19c21652567913348f365d3fbf346d8151c3cdf2 100644
|
| --- a/src/type-info.cc
|
| +++ b/src/type-info.cc
|
| @@ -71,49 +71,49 @@ void TypeFeedbackOracle::Initialize(Handle<Code> code) {
|
|
|
|
|
| bool TypeFeedbackOracle::LoadIsMonomorphic(Property* expr) {
|
| - return IsMonomorphic(expr->position());
|
| + return IsMonomorphic(expr->id());
|
| }
|
|
|
|
|
| bool TypeFeedbackOracle:: StoreIsMonomorphic(Assignment* expr) {
|
| - return IsMonomorphic(expr->position());
|
| + return IsMonomorphic(expr->id());
|
| }
|
|
|
|
|
| bool TypeFeedbackOracle::CallIsMonomorphic(Call* expr) {
|
| - return IsMonomorphic(expr->position());
|
| + return IsMonomorphic(expr->id());
|
| }
|
|
|
|
|
| Handle<Map> TypeFeedbackOracle::LoadMonomorphicReceiverType(Property* expr) {
|
| ASSERT(LoadIsMonomorphic(expr));
|
| - return Handle<Map>::cast(GetElement(map_, expr->position()));
|
| + return Handle<Map>::cast(GetElement(map_, expr->id()));
|
| }
|
|
|
|
|
| Handle<Map> TypeFeedbackOracle::StoreMonomorphicReceiverType(Assignment* expr) {
|
| ASSERT(StoreIsMonomorphic(expr));
|
| - return Handle<Map>::cast(GetElement(map_, expr->position()));
|
| + return Handle<Map>::cast(GetElement(map_, expr->id()));
|
| }
|
|
|
|
|
| Handle<Map> TypeFeedbackOracle::CallMonomorphicReceiverType(Call* expr) {
|
| ASSERT(CallIsMonomorphic(expr));
|
| - return Handle<Map>::cast(GetElement(map_, expr->position()));
|
| + return Handle<Map>::cast(GetElement(map_, expr->id()));
|
| }
|
|
|
|
|
| ZoneMapList* TypeFeedbackOracle::LoadReceiverTypes(Property* expr,
|
| Handle<String> name) {
|
| Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL);
|
| - return CollectReceiverTypes(expr->position(), name, flags);
|
| + return CollectReceiverTypes(expr->id(), name, flags);
|
| }
|
|
|
|
|
| ZoneMapList* TypeFeedbackOracle::StoreReceiverTypes(Assignment* expr,
|
| Handle<String> name) {
|
| Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL);
|
| - return CollectReceiverTypes(expr->position(), name, flags);
|
| + return CollectReceiverTypes(expr->id(), name, flags);
|
| }
|
|
|
|
|
| @@ -122,18 +122,18 @@ ZoneMapList* TypeFeedbackOracle::CallReceiverTypes(Call* expr,
|
| int arity = expr->arguments()->length();
|
| Code::Flags flags = Code::ComputeMonomorphicFlags(
|
| Code::CALL_IC, NORMAL, OWN_MAP, NOT_IN_LOOP, arity);
|
| - return CollectReceiverTypes(expr->position(), name, flags);
|
| + return CollectReceiverTypes(expr->id(), name, flags);
|
| }
|
|
|
|
|
| bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) {
|
| - Handle<Object> object = GetElement(map_, expr->position());
|
| + Handle<Object> object = GetElement(map_, expr->id());
|
| return *object == Builtins::builtin(id);
|
| }
|
|
|
|
|
| TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr, Side side) {
|
| - Handle<Object> object = GetElement(map_, expr->position());
|
| + Handle<Object> object = GetElement(map_, expr->id());
|
| TypeInfo unknown = TypeInfo::Unknown();
|
| if (!object->IsCode()) return unknown;
|
| Handle<Code> code = Handle<Code>::cast(object);
|
| @@ -157,7 +157,7 @@ TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr, Side side) {
|
|
|
|
|
| TypeInfo TypeFeedbackOracle::BinaryType(BinaryOperation* expr, Side side) {
|
| - Handle<Object> object = GetElement(map_, expr->position());
|
| + Handle<Object> object = GetElement(map_, expr->id());
|
| TypeInfo unknown = TypeInfo::Unknown();
|
| if (!object->IsCode()) return unknown;
|
| Handle<Code> code = Handle<Code>::cast(object);
|
| @@ -215,7 +215,7 @@ TypeInfo TypeFeedbackOracle::BinaryType(BinaryOperation* expr, Side side) {
|
| }
|
|
|
| TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) {
|
| - Handle<Object> object = GetElement(map_, clause->position());
|
| + Handle<Object> object = GetElement(map_, clause->label()->id());
|
| TypeInfo unknown = TypeInfo::Unknown();
|
| if (!object->IsCode()) return unknown;
|
| Handle<Code> code = Handle<Code>::cast(object);
|
| @@ -239,10 +239,10 @@ TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) {
|
|
|
|
|
|
|
| -ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(int position,
|
| +ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(AstId id,
|
| Handle<String> name,
|
| Code::Flags flags) {
|
| - Handle<Object> object = GetElement(map_, position);
|
| + Handle<Object> object = GetElement(map_, id);
|
| if (object->IsUndefined()) return NULL;
|
|
|
| if (*object == Builtins::builtin(Builtins::StoreIC_GlobalProxy)) {
|
| @@ -270,82 +270,72 @@ void TypeFeedbackOracle::PopulateMap(Handle<Code> code) {
|
|
|
| const int kInitialCapacity = 16;
|
| List<int> code_positions(kInitialCapacity);
|
| - List<int> source_positions(kInitialCapacity);
|
| - CollectPositions(*code, &code_positions, &source_positions);
|
| + List<AstId> ast_ids(kInitialCapacity);
|
| + CollectIds(*code, &code_positions, &ast_ids);
|
|
|
| - int length = code_positions.length();
|
| - ASSERT(source_positions.length() == length);
|
| + const int length = code_positions.length();
|
| + ASSERT(ast_ids.length() == length);
|
| for (int i = 0; i < length; i++) {
|
| 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];
|
| + AstId id = ast_ids[i];
|
| InlineCacheState state = target->ic_state();
|
| Code::Kind kind = target->kind();
|
| 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);
|
| - }
|
| + SetInfo(id, target);
|
| } else if (state == MONOMORPHIC) {
|
| Handle<Map> map = Handle<Map>(target->FindFirstMap());
|
| if (*map == NULL) {
|
| - SetElement(map_, position, target);
|
| + SetInfo(id, target);
|
| } else {
|
| - SetElement(map_, position, map);
|
| + SetInfo(id, map);
|
| }
|
| } else if (state == MEGAMORPHIC) {
|
| - SetElement(map_, position, target);
|
| + SetInfo(id, target);
|
| }
|
| }
|
| }
|
|
|
|
|
| -void TypeFeedbackOracle::CollectPositions(Code* code,
|
| - List<int>* code_positions,
|
| - List<int>* source_positions) {
|
| +void TypeFeedbackOracle::CollectIds(Code* code,
|
| + List<int>* code_positions,
|
| + List<AstId>* ast_ids) {
|
| AssertNoAllocation no_allocation;
|
| - int position = 0;
|
| - // Because the ICs we use for global variables access in the full
|
| - // code generator do not have any meaningful positions, we avoid
|
| - // collecting those by filtering out contextual code targets.
|
| - int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
|
| - RelocInfo::kPositionMask;
|
| + int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID);
|
| for (RelocIterator it(code, mask); !it.done(); it.next()) {
|
| RelocInfo* info = it.rinfo();
|
| - RelocInfo::Mode mode = info->rmode();
|
| - if (RelocInfo::IsCodeTarget(mode)) {
|
| - Code* target = Code::GetCodeFromTargetAddress(info->target_address());
|
| - if (target->is_inline_cache_stub()) {
|
| - InlineCacheState state = target->ic_state();
|
| - Code::Kind kind = target->kind();
|
| - if (kind == Code::BINARY_OP_IC) {
|
| - if (target->binary_op_type() == BinaryOpIC::GENERIC) continue;
|
| - } else if (kind == Code::TYPE_RECORDING_BINARY_OP_IC) {
|
| - if (target->type_recording_binary_op_type() ==
|
| - TRBinaryOpIC::GENERIC) {
|
| - continue;
|
| - }
|
| - } else if (kind == Code::COMPARE_IC) {
|
| - if (target->compare_state() == CompareIC::GENERIC) continue;
|
| - } else {
|
| - if (kind == Code::CALL_IC && state == MONOMORPHIC &&
|
| - target->check_type() != RECEIVER_MAP_CHECK) continue;
|
| - if (state != MONOMORPHIC && state != MEGAMORPHIC) continue;
|
| + Code* target = Code::GetCodeFromTargetAddress(info->target_address());
|
| + if (target->is_inline_cache_stub()) {
|
| + InlineCacheState state = target->ic_state();
|
| + Code::Kind kind = target->kind();
|
| + if (kind == Code::BINARY_OP_IC) {
|
| + if (target->binary_op_type() == BinaryOpIC::GENERIC) continue;
|
| + } else if (kind == Code::TYPE_RECORDING_BINARY_OP_IC) {
|
| + if (target->type_recording_binary_op_type() ==
|
| + TRBinaryOpIC::GENERIC) {
|
| + continue;
|
| }
|
| - code_positions->Add(
|
| - static_cast<int>(info->pc() - code->instruction_start()));
|
| - source_positions->Add(position);
|
| + } else if (kind == Code::COMPARE_IC) {
|
| + if (target->compare_state() == CompareIC::GENERIC) continue;
|
| + } else {
|
| + if (kind == Code::CALL_IC && state == MONOMORPHIC &&
|
| + target->check_type() != RECEIVER_MAP_CHECK) continue;
|
| + if (state != MONOMORPHIC && state != MEGAMORPHIC) continue;
|
| }
|
| - } else {
|
| - ASSERT(RelocInfo::IsPosition(mode));
|
| - position = static_cast<int>(info->data());
|
| + code_positions->Add(
|
| + static_cast<int>(info->pc() - code->instruction_start()));
|
| + ast_ids->Add(static_cast<AstId>(info->data()));
|
| }
|
| }
|
| }
|
|
|
| +
|
| +void TypeFeedbackOracle::SetInfo(AstId id, Handle<Object> info) {
|
| + ASSERT(GetElement(map_, id)->IsUndefined());
|
| + SetElement(map_, id, info);
|
| +}
|
| +
|
| } } // namespace v8::internal
|
|
|