bool Call::ComputeGlobalTarget(Handle<GlobalObject> global,
- LookupResult* lookup) {
+ LookupIterator* it) {
target_ = Handle<JSFunction>::null();
cell_ = Handle<Cell>::null();
- DCHECK(lookup->IsFound() &&
- lookup->type() == NORMAL &&
- lookup->holder() == *global);
- cell_ = Handle<Cell>(global->GetPropertyCell(lookup));
+ DCHECK(it->IsFound() && it->GetHolder<JSObject>().is_identical_to(global));
+ cell_ = it->GetPropertyCell();
if (cell_->value()->IsJSFunction()) {
Handle<JSFunction> candidate(JSFunction::cast(cell_->value()));
// If the function is in new space we assume it's more likely to
// change and thus prefer the general IC code.
- if (!lookup->isolate()->heap()->InNewSpace(*candidate)) {
+ if (!it->isolate()->heap()->InNewSpace(*candidate)) {
target_ = candidate;
return true;
}
HOptimizedGraphBuilder::GlobalPropertyAccess
- HOptimizedGraphBuilder::LookupGlobalProperty(
- Variable* var, LookupResult* lookup, PropertyAccessType access_type) {
+HOptimizedGraphBuilder::LookupGlobalProperty(Variable* var, LookupIterator* it,
+ PropertyAccessType access_type) {
+ DCHECK_EQ(*var->name(), *it->name());
if (var->is_this() || !current_info()->has_global_object()) {
return kUseGeneric;
}
- Handle<GlobalObject> global(current_info()->global_object());
- global->Lookup(var->name(), lookup);
- if (!lookup->IsNormal() ||
- (access_type == STORE && lookup->IsReadOnly()) ||
- lookup->holder() != *global) {
+ if (!it->HasProperty() || it->property_kind() != LookupIterator::DATA ||
+ (access_type == STORE && it->IsReadOnly())) {
return kUseGeneric;
}
return ast_context()->ReturnInstruction(instr, expr->id());
}
- LookupResult lookup(isolate());
- GlobalPropertyAccess type = LookupGlobalProperty(variable, &lookup, LOAD);
+ Handle<GlobalObject> global(current_info()->global_object());
+ LookupIterator it(global, variable->name(),
+ LookupIterator::CHECK_PROPERTY);
+ GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD);
if (type == kUseCell &&
current_info()->global_object()->IsAccessCheckNeeded()) {
}
if (type == kUseCell) {
- Handle<GlobalObject> global(current_info()->global_object());
- Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
+ Handle<PropertyCell> cell = it.GetPropertyCell();
if (cell->type()->IsConstant()) {
PropertyCell::AddDependentCompilationInfo(cell, top_info());
Handle<Object> constant_object = cell->type()->AsConstant()->Value();
return ast_context()->ReturnInstruction(constant, expr->id());
} else {
HLoadGlobalCell* instr =
- New<HLoadGlobalCell>(cell, lookup.GetPropertyDetails());
+ New<HLoadGlobalCell>(cell, it.property_details());
return ast_context()->ReturnInstruction(instr, expr->id());
}
} else {
Variable* var,
HValue* value,
BailoutId ast_id) {
- LookupResult lookup(isolate());
- GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, STORE);
+ Handle<GlobalObject> global(current_info()->global_object());
+ LookupIterator it(global, var->name(), LookupIterator::CHECK_PROPERTY);
+ GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE);
if (type == kUseCell) {
- Handle<GlobalObject> global(current_info()->global_object());
- Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
+ Handle<PropertyCell> cell = it.GetPropertyCell();
if (cell->type()->IsConstant()) {
Handle<Object> constant = cell->type()->AsConstant()->Value();
if (value->IsConstant()) {
}
}
HInstruction* instr =
- Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails());
+ Add<HStoreGlobalCell>(value, cell, it.property_details());
if (instr->HasObservableSideEffects()) {
Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
}
// If there is a global property cell for the name at compile time and
// access check is not enabled we assume that the function will not change
// and generate optimized code for calling the function.
- LookupResult lookup(isolate());
- GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, LOAD);
+ Handle<GlobalObject> global(current_info()->global_object());
+ LookupIterator it(global, var->name(), LookupIterator::CHECK_PROPERTY);
+ GlobalPropertyAccess type = LookupGlobalProperty(var, &it, LOAD);
if (type == kUseCell &&
!current_info()->global_object()->IsAccessCheckNeeded()) {
Handle<GlobalObject> global(current_info()->global_object());
- known_global_function = expr->ComputeGlobalTarget(global, &lookup);
+ known_global_function = expr->ComputeGlobalTarget(global, &it);
}
if (known_global_function) {
Add<HCheckValue>(function, expr->target());