type-info.cc 20.7 KB
Newer Older
1
// Copyright 2012 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5
#include "src/type-info.h"
6

7
#include "src/ast/ast.h"
8
#include "src/code-stubs.h"
9
#include "src/ic/ic.h"
10
#include "src/ic/stub-cache.h"
11
#include "src/objects-inl.h"
12

13 14 15 16
namespace v8 {
namespace internal {


17
TypeFeedbackOracle::TypeFeedbackOracle(
18 19 20
    Isolate* isolate, Zone* zone, Handle<Code> code,
    Handle<TypeFeedbackVector> feedback_vector, Handle<Context> native_context)
    : native_context_(native_context), isolate_(isolate), zone_(zone) {
21
  BuildDictionary(code);
22
  DCHECK(dictionary_->IsUnseededNumberDictionary());
23 24 25 26
  // We make a copy of the feedback vector because a GC could clear
  // the type feedback info contained therein.
  // TODO(mvstanton): revisit the decision to copy when we weakly
  // traverse the feedback vector at GC time.
27
  feedback_vector_ = TypeFeedbackVector::Copy(isolate, feedback_vector);
28 29 30
}


31 32 33 34 35 36 37
static uint32_t IdToKey(TypeFeedbackId ast_id) {
  return static_cast<uint32_t>(ast_id.ToInt());
}


Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) {
  int entry = dictionary_->FindEntry(IdToKey(ast_id));
38 39
  if (entry != UnseededNumberDictionary::kNotFound) {
    Object* value = dictionary_->ValueAt(entry);
40 41
    if (value->IsCell()) {
      Cell* cell = Cell::cast(value);
42
      return Handle<Object>(cell->value(), isolate());
43
    } else {
44
      return Handle<Object>(value, isolate());
45 46
    }
  }
47
  return Handle<Object>::cast(isolate()->factory()->undefined_value());
48 49 50
}


51 52
Handle<Object> TypeFeedbackOracle::GetInfo(FeedbackVectorSlot slot) {
  DCHECK(slot.ToInt() >= 0 && slot.ToInt() < feedback_vector_->length());
53 54
  Handle<Object> undefined =
      Handle<Object>::cast(isolate()->factory()->undefined_value());
55
  Object* obj = feedback_vector_->Get(slot);
56

57 58
  // Slots do not embed direct pointers to maps, functions. Instead
  // a WeakCell is always used.
59 60 61 62 63 64
  if (obj->IsWeakCell()) {
    WeakCell* cell = WeakCell::cast(obj);
    if (cell->cleared()) return undefined;
    obj = cell->value();
  }

65
  if (obj->IsJSFunction() || obj->IsAllocationSite() || obj->IsSymbol() ||
66
      obj->IsSimd128Value()) {
67 68
    return Handle<Object>(obj, isolate());
  }
69

70
  return undefined;
71 72 73
}


74
InlineCacheState TypeFeedbackOracle::LoadInlineCacheState(
75
    FeedbackVectorSlot slot) {
76
  if (!slot.IsInvalid()) {
77 78
    FeedbackVectorSlotKind kind = feedback_vector_->GetKind(slot);
    if (kind == FeedbackVectorSlotKind::LOAD_IC) {
79 80
      LoadICNexus nexus(feedback_vector_, slot);
      return nexus.StateFromFeedback();
81
    } else if (kind == FeedbackVectorSlotKind::KEYED_LOAD_IC) {
82 83 84
      KeyedLoadICNexus nexus(feedback_vector_, slot);
      return nexus.StateFromFeedback();
    }
85 86
  }

87 88 89
  // If we can't find an IC, assume we've seen *something*, but we don't know
  // what. PREMONOMORPHIC roughly encodes this meaning.
  return PREMONOMORPHIC;
90 91 92
}


93
bool TypeFeedbackOracle::StoreIsUninitialized(FeedbackVectorSlot slot) {
94
  if (!slot.IsInvalid()) {
95 96
    FeedbackVectorSlotKind kind = feedback_vector_->GetKind(slot);
    if (kind == FeedbackVectorSlotKind::STORE_IC) {
97
      StoreICNexus nexus(feedback_vector_, slot);
98
      return nexus.StateFromFeedback() == UNINITIALIZED;
99
    } else if (kind == FeedbackVectorSlotKind::KEYED_STORE_IC) {
100
      KeyedStoreICNexus nexus(feedback_vector_, slot);
101
      return nexus.StateFromFeedback() == UNINITIALIZED;
102 103 104 105 106 107
    }
  }
  return true;
}


108
bool TypeFeedbackOracle::CallIsUninitialized(FeedbackVectorSlot slot) {
109
  Handle<Object> value = GetInfo(slot);
110
  return value->IsUndefined(isolate()) ||
111 112 113 114 115
         value.is_identical_to(
             TypeFeedbackVector::UninitializedSentinel(isolate()));
}


116
bool TypeFeedbackOracle::CallIsMonomorphic(FeedbackVectorSlot slot) {
117
  Handle<Object> value = GetInfo(slot);
118
  return value->IsAllocationSite() || value->IsJSFunction();
119 120 121
}


122
bool TypeFeedbackOracle::CallNewIsMonomorphic(FeedbackVectorSlot slot) {
123
  Handle<Object> info = GetInfo(slot);
124
  return info->IsAllocationSite() || info->IsJSFunction();
125 126 127
}


128
byte TypeFeedbackOracle::ForInType(FeedbackVectorSlot feedback_vector_slot) {
129
  Handle<Object> value = GetInfo(feedback_vector_slot);
130
  return value.is_identical_to(
131 132 133
             TypeFeedbackVector::UninitializedSentinel(isolate()))
             ? ForInStatement::FAST_FOR_IN
             : ForInStatement::SLOW_FOR_IN;
134 135 136
}


137
void TypeFeedbackOracle::GetStoreModeAndKeyType(
138
    FeedbackVectorSlot slot, KeyedAccessStoreMode* store_mode,
139
    IcCheckType* key_type) {
140
  if (!slot.IsInvalid() &&
141 142
      feedback_vector_->GetKind(slot) ==
          FeedbackVectorSlotKind::KEYED_STORE_IC) {
143 144 145 146 147 148
    KeyedStoreICNexus nexus(feedback_vector_, slot);
    *store_mode = nexus.GetKeyedAccessStoreMode();
    *key_type = nexus.GetKeyType();
  } else {
    *store_mode = STANDARD_STORE;
    *key_type = ELEMENT;
149 150 151 152
  }
}


153
Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(FeedbackVectorSlot slot) {
154
  Handle<Object> info = GetInfo(slot);
155 156
  if (info->IsAllocationSite()) {
    return Handle<JSFunction>(isolate()->native_context()->array_function());
157
  }
158

159
  return Handle<JSFunction>::cast(info);
160 161 162
}


163 164
Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(
    FeedbackVectorSlot slot) {
165
  Handle<Object> info = GetInfo(slot);
166
  if (info->IsJSFunction()) {
167 168
    return Handle<JSFunction>::cast(info);
  }
169

170
  DCHECK(info->IsAllocationSite());
171
  return Handle<JSFunction>(isolate()->native_context()->array_function());
172 173 174
}


175
Handle<AllocationSite> TypeFeedbackOracle::GetCallAllocationSite(
176
    FeedbackVectorSlot slot) {
177 178 179 180 181 182 183 184
  Handle<Object> info = GetInfo(slot);
  if (info->IsAllocationSite()) {
    return Handle<AllocationSite>::cast(info);
  }
  return Handle<AllocationSite>::null();
}


185 186
Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite(
    FeedbackVectorSlot slot) {
187
  Handle<Object> info = GetInfo(slot);
188
  if (info->IsAllocationSite()) {
189 190 191
    return Handle<AllocationSite>::cast(info);
  }
  return Handle<AllocationSite>::null();
192 193
}

194 195 196 197 198 199 200 201 202 203 204 205
namespace {

AstType* CompareOpHintToType(CompareOperationHint hint) {
  switch (hint) {
    case CompareOperationHint::kNone:
      return AstType::None();
    case CompareOperationHint::kSignedSmall:
      return AstType::SignedSmall();
    case CompareOperationHint::kNumber:
      return AstType::Number();
    case CompareOperationHint::kNumberOrOddball:
      return AstType::NumberOrOddball();
206 207
    case CompareOperationHint::kInternalizedString:
      return AstType::InternalizedString();
208 209
    case CompareOperationHint::kString:
      return AstType::String();
210 211
    case CompareOperationHint::kReceiver:
      return AstType::Receiver();
212 213 214 215 216 217 218
    case CompareOperationHint::kAny:
      return AstType::Any();
  }
  UNREACHABLE();
  return AstType::None();
}

219
AstType* BinaryOpFeedbackToType(int hint) {
220
  switch (hint) {
221
    case BinaryOperationFeedback::kNone:
222
      return AstType::None();
223
    case BinaryOperationFeedback::kSignedSmall:
224
      return AstType::SignedSmall();
225
    case BinaryOperationFeedback::kNumber:
226
      return AstType::Number();
227
    case BinaryOperationFeedback::kString:
228
      return AstType::String();
229
    case BinaryOperationFeedback::kNumberOrOddball:
230
      return AstType::NumberOrOddball();
231 232
    case BinaryOperationFeedback::kAny:
    default:
233 234 235 236 237 238 239 240 241 242
      return AstType::Any();
  }
  UNREACHABLE();
  return AstType::None();
}

}  // end anonymous namespace

void TypeFeedbackOracle::CompareType(TypeFeedbackId id, FeedbackVectorSlot slot,
                                     AstType** left_type, AstType** right_type,
243
                                     AstType** combined_type) {
244
  Handle<Object> info = GetInfo(id);
245 246
  // A check for a valid slot is not sufficient here. InstanceOf collects
  // type feedback in a General slot.
247
  if (!info->IsCode()) {
248 249
    // For some comparisons we don't have type feedback, e.g.
    // LiteralCompareTypeof.
250
    *left_type = *right_type = *combined_type = AstType::None();
251 252
    return;
  }
253

254 255 256 257 258 259 260 261 262 263
  // Feedback from Ignition. The feedback slot will be allocated and initialized
  // to AstType::None() even when ignition is not enabled. So it is safe to get
  // feedback from the type feedback vector.
  DCHECK(!slot.IsInvalid());
  CompareICNexus nexus(feedback_vector_, slot);
  *left_type = *right_type = *combined_type =
      CompareOpHintToType(nexus.GetCompareOperationFeedback());

  // Merge the feedback from full-codegen if available.
  Handle<Code> code = Handle<Code>::cast(info);
264 265
  Handle<Map> map;
  Map* raw_map = code->FindFirstMap();
266
  if (raw_map != NULL) Map::TryUpdate(handle(raw_map)).ToHandle(&map);
267

268
  if (code->is_compare_ic_stub()) {
269
    CompareICStub stub(code->stub_key(), isolate());
270 271 272 273 274 275
    AstType* left_type_from_ic =
        CompareICState::StateToType(zone(), stub.left());
    AstType* right_type_from_ic =
        CompareICState::StateToType(zone(), stub.right());
    AstType* combined_type_from_ic =
        CompareICState::StateToType(zone(), stub.state(), map);
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
    // Full-codegen collects lhs and rhs feedback seperately and Crankshaft
    // could use this information to optimize better. So if combining the
    // feedback has made the feedback less precise, we should use the feedback
    // only from Full-codegen. If the union of the feedback from Full-codegen
    // is same as that of Ignition, there is no need to combine feedback from
    // from Ignition.
    AstType* combined_type_from_fcg = AstType::Union(
        left_type_from_ic,
        AstType::Union(right_type_from_ic, combined_type_from_ic, zone()),
        zone());
    if (combined_type_from_fcg == *left_type) {
      // Full-codegen collects information about lhs, rhs and result types
      // seperately. So just retain that information.
      *left_type = left_type_from_ic;
      *right_type = right_type_from_ic;
      *combined_type = combined_type_from_ic;
    } else {
      // Combine Ignition and Full-codegen feedbacks.
      *left_type = AstType::Union(*left_type, left_type_from_ic, zone());
      *right_type = AstType::Union(*right_type, right_type_from_ic, zone());
      *combined_type =
          AstType::Union(*combined_type, combined_type_from_ic, zone());
    }
299 300 301
  }
}

302 303 304
void TypeFeedbackOracle::BinaryType(TypeFeedbackId id, FeedbackVectorSlot slot,
                                    AstType** left, AstType** right,
                                    AstType** result,
305
                                    Maybe<int>* fixed_right_arg,
306
                                    Handle<AllocationSite>* allocation_site,
307
                                    Token::Value op) {
308
  Handle<Object> object = GetInfo(id);
309 310 311 312 313
  if (slot.IsInvalid()) {
    // For some binary ops we don't have ICs or feedback slots,
    // e.g. Token::COMMA, but for the operations covered by the BinaryOpIC we
    // should always have them.
    DCHECK(!object->IsCode());
314 315
    DCHECK(op < BinaryOpICState::FIRST_TOKEN ||
           op > BinaryOpICState::LAST_TOKEN);
316
    *left = *right = *result = AstType::None();
317
    *fixed_right_arg = Nothing<int>();
318
    *allocation_site = Handle<AllocationSite>::null();
319 320
    return;
  }
321 322 323 324 325 326 327

  // Feedback from Ignition. The feedback slot will be allocated and initialized
  // to AstType::None() even when ignition is not enabled. So it is safe to get
  // feedback from the type feedback vector.
  DCHECK(!slot.IsInvalid());
  BinaryOpICNexus nexus(feedback_vector_, slot);
  *left = *right = *result =
328
      BinaryOpFeedbackToType(Smi::cast(nexus.GetFeedback())->value());
329 330 331 332 333 334
  *fixed_right_arg = Nothing<int>();
  *allocation_site = Handle<AllocationSite>::null();

  if (!object->IsCode()) return;

  // Merge the feedback from full-codegen if available.
335
  Handle<Code> code = Handle<Code>::cast(object);
336
  DCHECK_EQ(Code::BINARY_OP_IC, code->kind());
337
  BinaryOpICState state(isolate(), code->extra_ic_state());
338
  DCHECK_EQ(op, state.op());
339

340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
  // Full-codegen collects lhs and rhs feedback seperately and Crankshaft
  // could use this information to optimize better. So if combining the
  // feedback has made the feedback less precise, we should use the feedback
  // only from Full-codegen. If the union of the feedback from Full-codegen
  // is same as that of Ignition, there is no need to combine feedback from
  // from Ignition.
  AstType* combined_type_from_fcg = AstType::Union(
      state.GetLeftType(),
      AstType::Union(state.GetRightType(), state.GetResultType(), zone()),
      zone());
  if (combined_type_from_fcg == *left) {
    // Full-codegen collects information about lhs, rhs and result types
    // seperately. So just retain that information.
    *left = state.GetLeftType();
    *right = state.GetRightType();
    *result = state.GetResultType();
  } else {
    // Combine Ignition and Full-codegen feedback.
    *left = AstType::Union(*left, state.GetLeftType(), zone());
    *right = AstType::Union(*right, state.GetRightType(), zone());
    *result = AstType::Union(*result, state.GetResultType(), zone());
  }
  // Ignition does not collect this feedback.
363
  *fixed_right_arg = state.fixed_right_arg();
364 365 366 367 368 369 370

  AllocationSite* first_allocation_site = code->FindFirstAllocationSite();
  if (first_allocation_site != NULL) {
    *allocation_site = handle(first_allocation_site);
  } else {
    *allocation_site = Handle<AllocationSite>::null();
  }
371 372
}

373 374
AstType* TypeFeedbackOracle::CountType(TypeFeedbackId id,
                                       FeedbackVectorSlot slot) {
375
  Handle<Object> object = GetInfo(id);
376 377 378 379 380 381 382
  if (slot.IsInvalid()) {
    DCHECK(!object->IsCode());
    return AstType::None();
  }

  DCHECK(!slot.IsInvalid());
  BinaryOpICNexus nexus(feedback_vector_, slot);
383 384
  AstType* type =
      BinaryOpFeedbackToType(Smi::cast(nexus.GetFeedback())->value());
385 386 387

  if (!object->IsCode()) return type;

388
  Handle<Code> code = Handle<Code>::cast(object);
389
  DCHECK_EQ(Code::BINARY_OP_IC, code->kind());
390
  BinaryOpICState state(isolate(), code->extra_ic_state());
391
  return AstType::Union(type, state.GetLeftType(), zone());
392 393 394
}


395 396 397 398 399 400 401 402 403
bool TypeFeedbackOracle::HasOnlyStringMaps(SmallMapList* receiver_types) {
  bool all_strings = receiver_types->length() > 0;
  for (int i = 0; i < receiver_types->length(); i++) {
    all_strings &= receiver_types->at(i)->IsStringMap();
  }
  return all_strings;
}


404
void TypeFeedbackOracle::PropertyReceiverTypes(FeedbackVectorSlot slot,
405
                                               Handle<Name> name,
406 407
                                               SmallMapList* receiver_types) {
  receiver_types->Clear();
408 409
  if (!slot.IsInvalid()) {
    LoadICNexus nexus(feedback_vector_, slot);
410
    CollectReceiverTypes(isolate()->load_stub_cache(), &nexus, name,
411
                         receiver_types);
412
  }
413 414 415 416
}


void TypeFeedbackOracle::KeyedPropertyReceiverTypes(
417
    FeedbackVectorSlot slot, SmallMapList* receiver_types, bool* is_string,
418
    IcCheckType* key_type) {
419
  receiver_types->Clear();
420 421 422 423 424
  if (slot.IsInvalid()) {
    *is_string = false;
    *key_type = ELEMENT;
  } else {
    KeyedLoadICNexus nexus(feedback_vector_, slot);
verwaest's avatar
verwaest committed
425
    CollectReceiverTypes(&nexus, receiver_types);
426
    *is_string = HasOnlyStringMaps(receiver_types);
427
    *key_type = nexus.GetKeyType();
428
  }
429 430 431
}


432
void TypeFeedbackOracle::AssignmentReceiverTypes(FeedbackVectorSlot slot,
433 434 435
                                                 Handle<Name> name,
                                                 SmallMapList* receiver_types) {
  receiver_types->Clear();
436
  CollectReceiverTypes(isolate()->store_stub_cache(), slot, name,
437
                       receiver_types);
438 439 440 441
}


void TypeFeedbackOracle::KeyedAssignmentReceiverTypes(
442
    FeedbackVectorSlot slot, SmallMapList* receiver_types,
443 444 445 446 447 448 449
    KeyedAccessStoreMode* store_mode, IcCheckType* key_type) {
  receiver_types->Clear();
  CollectReceiverTypes(slot, receiver_types);
  GetStoreModeAndKeyType(slot, store_mode, key_type);
}


450
void TypeFeedbackOracle::CountReceiverTypes(FeedbackVectorSlot slot,
451 452 453 454 455
                                            SmallMapList* receiver_types) {
  receiver_types->Clear();
  if (!slot.IsInvalid()) CollectReceiverTypes(slot, receiver_types);
}

456 457
void TypeFeedbackOracle::CollectReceiverTypes(StubCache* stub_cache,
                                              FeedbackVectorSlot slot,
458 459 460
                                              Handle<Name> name,
                                              SmallMapList* types) {
  StoreICNexus nexus(feedback_vector_, slot);
461
  CollectReceiverTypes(stub_cache, &nexus, name, types);
462 463
}

464 465
void TypeFeedbackOracle::CollectReceiverTypes(StubCache* stub_cache,
                                              FeedbackNexus* nexus,
verwaest's avatar
verwaest committed
466
                                              Handle<Name> name,
467
                                              SmallMapList* types) {
468
  if (FLAG_collect_megamorphic_maps_from_stub_cache &&
verwaest's avatar
verwaest committed
469
      nexus->ic_state() == MEGAMORPHIC) {
470
    types->Reserve(4, zone());
471
    stub_cache->CollectMatchingMaps(types, name, native_context_, zone());
472
  } else {
verwaest's avatar
verwaest committed
473
    CollectReceiverTypes(nexus, types);
474 475 476 477
  }
}


478
void TypeFeedbackOracle::CollectReceiverTypes(FeedbackVectorSlot slot,
479
                                              SmallMapList* types) {
480 481
  FeedbackVectorSlotKind kind = feedback_vector_->GetKind(slot);
  if (kind == FeedbackVectorSlotKind::STORE_IC) {
482
    StoreICNexus nexus(feedback_vector_, slot);
verwaest's avatar
verwaest committed
483
    CollectReceiverTypes(&nexus, types);
484
  } else {
485
    DCHECK_EQ(FeedbackVectorSlotKind::KEYED_STORE_IC, kind);
486
    KeyedStoreICNexus nexus(feedback_vector_, slot);
verwaest's avatar
verwaest committed
487
    CollectReceiverTypes(&nexus, types);
488
  }
489 490
}

verwaest's avatar
verwaest committed
491 492
void TypeFeedbackOracle::CollectReceiverTypes(FeedbackNexus* nexus,
                                              SmallMapList* types) {
493
  MapHandleList maps;
verwaest's avatar
verwaest committed
494 495
  if (nexus->ic_state() == MONOMORPHIC) {
    Map* map = nexus->FindFirstMap();
496
    if (map != NULL) maps.Add(handle(map));
verwaest's avatar
verwaest committed
497 498
  } else if (nexus->ic_state() == POLYMORPHIC) {
    nexus->FindAllMaps(&maps);
499 500
  } else {
    return;
501
  }
502 503 504
  types->Reserve(maps.length(), zone());
  for (int i = 0; i < maps.length(); i++) {
    Handle<Map> map(maps.at(i));
505 506
    if (IsRelevantFeedback(*map, *native_context_)) {
      types->AddMapIfMissing(maps.at(i), zone());
507
    }
508 509 510 511
  }
}


512
uint16_t TypeFeedbackOracle::ToBooleanTypes(TypeFeedbackId id) {
513
  Handle<Object> object = GetInfo(id);
514 515 516 517
  return object->IsCode() ? Handle<Code>::cast(object)->to_boolean_state() : 0;
}


518 519 520 521 522
// Things are a bit tricky here: The iterator for the RelocInfos and the infos
// themselves are not GC-safe, so we first get all infos, then we create the
// dictionary (possibly triggering GC), and finally we relocate the collected
// infos before we process them.
void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) {
523
  DisallowHeapAllocation no_allocation;
524
  ZoneList<RelocInfo> infos(16, zone());
525
  HandleScope scope(isolate());
526 527 528 529 530
  GetRelocInfos(code, &infos);
  CreateDictionary(code, &infos);
  ProcessRelocInfos(&infos);
  // Allocate handle in the parent scope.
  dictionary_ = scope.CloseAndEscape(dictionary_);
531 532 533
}


534 535 536 537
void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code,
                                       ZoneList<RelocInfo>* infos) {
  int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID);
  for (RelocIterator it(*code, mask); !it.done(); it.next()) {
538
    infos->Add(*it.rinfo(), zone());
539 540
  }
}
541 542


543 544
void TypeFeedbackOracle::CreateDictionary(Handle<Code> code,
                                          ZoneList<RelocInfo>* infos) {
545
  AllowHeapAllocation allocation_allowed;
546
  Code* old_code = *code;
547
  dictionary_ = UnseededNumberDictionary::New(isolate(), infos->length());
548
  RelocateRelocInfos(infos, old_code, *code);
549
}
550

551 552

void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos,
553 554
                                            Code* old_code,
                                            Code* new_code) {
555 556
  for (int i = 0; i < infos->length(); i++) {
    RelocInfo* info = &(*infos)[i];
557 558 559
    info->set_host(new_code);
    info->set_pc(new_code->instruction_start() +
                 (info->pc() - old_code->instruction_start()));
560 561 562 563
  }
}


564 565
void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) {
  for (int i = 0; i < infos->length(); i++) {
566 567
    RelocInfo reloc_entry = (*infos)[i];
    Address target_address = reloc_entry.target_address();
568 569
    TypeFeedbackId ast_id =
        TypeFeedbackId(static_cast<unsigned>((*infos)[i].data()));
570 571
    Code* target = Code::GetCodeFromTargetAddress(target_address);
    switch (target->kind()) {
572 573
      case Code::LOAD_IC:
      case Code::STORE_IC:
574 575 576 577 578
      case Code::KEYED_LOAD_IC:
      case Code::KEYED_STORE_IC:
      case Code::BINARY_OP_IC:
      case Code::COMPARE_IC:
      case Code::TO_BOOLEAN_IC:
579
        SetInfo(ast_id, target);
580 581 582 583 584
        break;

      default:
        break;
    }
585 586 587
  }
}

588

589
void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id, Object* target) {
590
  DCHECK(dictionary_->FindEntry(IdToKey(ast_id)) ==
591
         UnseededNumberDictionary::kNotFound);
592
  // Dictionary has been allocated with sufficient size for all elements.
593 594
  DisallowHeapAllocation no_need_to_resize_dictionary;
  HandleScope scope(isolate());
595 596
  USE(UnseededNumberDictionary::AtNumberPut(
      dictionary_, IdToKey(ast_id), handle(target, isolate())));
597 598
}

599

600 601
}  // namespace internal
}  // namespace v8