void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
+ allocation_info_cell_ = oracle->GetCallNewAllocationInfoCell(this);
is_monomorphic_ = oracle->CallNewIsMonomorphic(this);
if (is_monomorphic_) {
target_ = oracle->GetCallNewTarget(this);
- elements_kind_ = oracle->GetCallNewElementsKind(this);
+ Object* value = allocation_info_cell_->value();
+ if (value->IsSmi()) {
+ elements_kind_ = static_cast<ElementsKind>(Smi::cast(value)->value());
+ }
}
- Handle<Object> alloc_elements_kind = oracle->GetInfo(CallNewFeedbackId());
-// if (alloc_elements_kind->IsSmi())
-// alloc_elements_kind_ = Handle<Smi>::cast(alloc_elements_kind);
- alloc_elements_kind_ = alloc_elements_kind->IsSmi()
- ? Handle<Smi>::cast(alloc_elements_kind)
- : handle(Smi::FromInt(GetInitialFastElementsKind()), oracle->isolate());
}
virtual bool IsMonomorphic() { return is_monomorphic_; }
Handle<JSFunction> target() const { return target_; }
ElementsKind elements_kind() const { return elements_kind_; }
- Handle<Smi> allocation_elements_kind() const { return alloc_elements_kind_; }
+ Handle<JSGlobalPropertyCell> allocation_info_cell() const {
+ return allocation_info_cell_;
+ }
BailoutId ReturnId() const { return return_id_; }
bool is_monomorphic_;
Handle<JSFunction> target_;
ElementsKind elements_kind_;
- Handle<Smi> alloc_elements_kind_;
+ Handle<JSGlobalPropertyCell> allocation_info_cell_;
const BailoutId return_id_;
};
CHECK_ALIVE(VisitArgumentList(expr->arguments()));
HCallNew* call;
if (use_call_new_array) {
- // TODO(mvstanton): It would be better to use the already created global
- // property cell that is shared by full code gen. That way, any transition
- // information that happened after crankshaft won't be lost. The right
- // way to do that is to begin passing the cell to the type feedback oracle
- // instead of just the value in the cell. Do this in a follow-up checkin.
- Handle<Smi> feedback = expr->allocation_elements_kind();
- Handle<JSGlobalPropertyCell> cell =
- isolate()->factory()->NewJSGlobalPropertyCell(feedback);
-
- // TODO(mvstanton): Here we should probably insert code to check if the
- // type cell elements kind is different from when we compiled, and deopt
- // in that case. Do this in a follow-up checin.
+ Handle<JSGlobalPropertyCell> cell = expr->allocation_info_cell();
call = new(zone()) HCallNewArray(context, constructor, argument_count,
cell);
} else {
Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) {
int entry = dictionary_->FindEntry(IdToKey(ast_id));
- return entry != UnseededNumberDictionary::kNotFound
- ? Handle<Object>(dictionary_->ValueAt(entry), isolate_)
- : Handle<Object>::cast(isolate_->factory()->undefined_value());
+ if (entry != UnseededNumberDictionary::kNotFound) {
+ Object* value = dictionary_->ValueAt(entry);
+ if (value->IsJSGlobalPropertyCell()) {
+ JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(value);
+ return Handle<Object>(cell->value(), isolate_);
+ } else {
+ return Handle<Object>(value, isolate_);
+ }
+ }
+ return Handle<Object>::cast(isolate_->factory()->undefined_value());
+}
+
+
+Handle<JSGlobalPropertyCell> TypeFeedbackOracle::GetInfoCell(
+ TypeFeedbackId ast_id) {
+ int entry = dictionary_->FindEntry(IdToKey(ast_id));
+ if (entry != UnseededNumberDictionary::kNotFound) {
+ JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(
+ dictionary_->ValueAt(entry));
+ return Handle<JSGlobalPropertyCell>(cell, isolate_);
+ }
+ return Handle<JSGlobalPropertyCell>::null();
}
}
-ElementsKind TypeFeedbackOracle::GetCallNewElementsKind(CallNew* expr) {
- Handle<Object> info = GetInfo(expr->CallNewFeedbackId());
- if (info->IsSmi()) {
- return static_cast<ElementsKind>(Smi::cast(*info)->value());
- } else {
- // TODO(mvstanton): avoided calling GetInitialFastElementsKind() for perf
- // reasons. Is there a better fix?
- if (FLAG_packed_arrays) {
- return FAST_SMI_ELEMENTS;
- } else {
- return FAST_HOLEY_SMI_ELEMENTS;
- }
- }
+Handle<JSGlobalPropertyCell> TypeFeedbackOracle::GetCallNewAllocationInfoCell(
+ CallNew* expr) {
+ return GetInfoCell(expr->CallNewFeedbackId());
}
+
Handle<Map> TypeFeedbackOracle::GetObjectLiteralStoreMap(
ObjectLiteral::Property* prop) {
ASSERT(ObjectLiteralStoreIsMonomorphic(prop));
TypeFeedbackInfo::cast(raw_info)->type_feedback_cells());
for (int i = 0; i < cache->CellCount(); i++) {
TypeFeedbackId ast_id = cache->AstId(i);
- Object* value = cache->Cell(i)->value();
+ JSGlobalPropertyCell* cell = cache->Cell(i);
+ Object* value = cell->value();
if (value->IsSmi() ||
(value->IsJSFunction() &&
!CanRetainOtherContext(JSFunction::cast(value),
*native_context_))) {
- SetInfo(ast_id, value);
+ SetInfo(ast_id, cell);
}
}
}
CheckType GetCallCheckType(Call* expr);
Handle<JSFunction> GetCallTarget(Call* expr);
Handle<JSFunction> GetCallNewTarget(CallNew* expr);
- ElementsKind GetCallNewElementsKind(CallNew* expr);
+ Handle<JSGlobalPropertyCell> GetCallNewAllocationInfoCell(CallNew* expr);
Handle<Map> GetObjectLiteralStoreMap(ObjectLiteralProperty* prop);
// Returns an element from the backing store. Returns undefined if
// there is no information.
- public:
- // TODO(mvstanton): how to get this information without making the method
- // public?
Handle<Object> GetInfo(TypeFeedbackId ast_id);
+ // Return the cell that contains type feedback.
+ Handle<JSGlobalPropertyCell> GetInfoCell(TypeFeedbackId ast_id);
+
private:
Handle<Context> native_context_;
Isolate* isolate_;