Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Unified Diff: src/ic.cc

Issue 8068026: Begin to handlify the stub cache. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic.h ('k') | src/runtime.cc » ('j') | src/stub-cache.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index 50b1cde888d769b675d6eee89d5a27819d77c1c0..35e81d4464b905b1ca67a52a99e6602b065483b4 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -849,7 +849,7 @@ MaybeObject* LoadIC::Load(State state,
AssertNoAllocation no_allocation;
Code* stub = NULL;
if (state == UNINITIALIZED) {
- stub = pre_monomorphic_stub();
+ stub = *pre_monomorphic_stub();
} else if (state == PREMONOMORPHIC) {
if (object->IsString()) {
stub = isolate()->builtins()->builtin(
@@ -862,7 +862,7 @@ MaybeObject* LoadIC::Load(State state,
stub = isolate()->builtins()->builtin(
Builtins::kLoadIC_StringWrapperLength);
} else if (state != MEGAMORPHIC) {
- stub = megamorphic_stub();
+ stub = *megamorphic_stub();
}
if (stub != NULL) {
set_target(stub);
@@ -884,12 +884,12 @@ MaybeObject* LoadIC::Load(State state,
AssertNoAllocation no_allocation;
Code* stub = NULL;
if (state == UNINITIALIZED) {
- stub = pre_monomorphic_stub();
+ stub = *pre_monomorphic_stub();
} else if (state == PREMONOMORPHIC) {
stub = isolate()->builtins()->builtin(
Builtins::kLoadIC_ArrayLength);
} else if (state != MEGAMORPHIC) {
- stub = megamorphic_stub();
+ stub = *megamorphic_stub();
}
if (stub != NULL) {
set_target(stub);
@@ -907,12 +907,12 @@ MaybeObject* LoadIC::Load(State state,
{ AssertNoAllocation no_allocation;
Code* stub = NULL;
if (state == UNINITIALIZED) {
- stub = pre_monomorphic_stub();
+ stub = *pre_monomorphic_stub();
} else if (state == PREMONOMORPHIC) {
stub = isolate()->builtins()->builtin(
Builtins::kLoadIC_FunctionPrototype);
} else if (state != MEGAMORPHIC) {
- stub = megamorphic_stub();
+ stub = *megamorphic_stub();
}
if (stub != NULL) {
set_target(stub);
@@ -984,91 +984,76 @@ void LoadIC::UpdateCaches(LookupResult* lookup,
if (HasNormalObjectsInPrototypeChain(isolate(), lookup, *object)) return;
// Compute the code stub for this load.
- MaybeObject* maybe_code = NULL;
- Object* code;
+ HandleScope scope(isolate());
Kevin Millikin (Chromium) 2011/09/29 09:21:32 Before, we created this handle scope only in the c
+ Handle<Code> code;
if (state == UNINITIALIZED) {
// This is the first time we execute this inline cache.
// Set the target to the pre monomorphic stub to delay
// setting the monomorphic state.
- maybe_code = pre_monomorphic_stub();
+ code = pre_monomorphic_stub();
} else if (!lookup->IsProperty()) {
// Nonexistent property. The result is undefined.
- maybe_code = isolate()->stub_cache()->ComputeLoadNonexistent(*name,
- *receiver);
+ code = isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver);
} else {
// Compute monomorphic stub.
+ Handle<JSObject> holder(lookup->holder());
switch (lookup->type()) {
- case FIELD: {
- maybe_code = isolate()->stub_cache()->ComputeLoadField(
- *name,
- *receiver,
- lookup->holder(),
- lookup->GetFieldIndex());
+ case FIELD:
+ code = isolate()->stub_cache()->ComputeLoadField(
+ name, receiver, holder, lookup->GetFieldIndex());
break;
- }
case CONSTANT_FUNCTION: {
- Object* constant = lookup->GetConstantFunction();
- maybe_code = isolate()->stub_cache()->ComputeLoadConstant(
- *name, *receiver, lookup->holder(), constant);
+ Handle<Object> constant(lookup->GetConstantFunction());
+ code = isolate()->stub_cache()->ComputeLoadConstant(
+ name, receiver, holder, constant);
break;
}
- case NORMAL: {
- if (lookup->holder()->IsGlobalObject()) {
- GlobalObject* global = GlobalObject::cast(lookup->holder());
- JSGlobalPropertyCell* cell =
- JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
- maybe_code = isolate()->stub_cache()->ComputeLoadGlobal(*name,
- *receiver,
- global,
- cell,
- lookup->IsDontDelete());
+ case NORMAL:
+ if (holder->IsGlobalObject()) {
+ Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder);
+ Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(lookup));
+ code = isolate()->stub_cache()->ComputeLoadGlobal(
+ name, receiver, global, cell, lookup->IsDontDelete());
} else {
// There is only one shared stub for loading normalized
// properties. It does not traverse the prototype chain, so the
// property must be found in the receiver for the stub to be
// applicable.
- if (lookup->holder() != *receiver) return;
- maybe_code = isolate()->stub_cache()->ComputeLoadNormal();
+ if (!holder.is_identical_to(receiver)) return;
+ code = isolate()->stub_cache()->ComputeLoadNormal();
}
break;
- }
case CALLBACKS: {
- if (!lookup->GetCallbackObject()->IsAccessorInfo()) return;
- AccessorInfo* callback =
- AccessorInfo::cast(lookup->GetCallbackObject());
+ Handle<Object> callback_object(lookup->GetCallbackObject());
+ if (!callback_object->IsAccessorInfo()) return;
+ Handle<AccessorInfo> callback =
+ Handle<AccessorInfo>::cast(callback_object);
if (v8::ToCData<Address>(callback->getter()) == 0) return;
- maybe_code = isolate()->stub_cache()->ComputeLoadCallback(
- *name, *receiver, lookup->holder(), callback);
+ code = isolate()->stub_cache()->ComputeLoadCallback(
+ name, receiver, holder, callback);
break;
}
- case INTERCEPTOR: {
- ASSERT(HasInterceptorGetter(lookup->holder()));
- maybe_code = isolate()->stub_cache()->ComputeLoadInterceptor(
- *name, *receiver, lookup->holder());
+ case INTERCEPTOR:
+ ASSERT(HasInterceptorGetter(*holder));
+ code = isolate()->stub_cache()->ComputeLoadInterceptor(
+ name, receiver, holder);
break;
- }
default:
return;
}
}
- // If we're unable to compute the stub (not enough memory left), we
- // simply avoid updating the caches.
- if (maybe_code == NULL || !maybe_code->ToObject(&code)) return;
-
// Patch the call site depending on the state of the cache.
- if (state == UNINITIALIZED || state == PREMONOMORPHIC ||
+ if (state == UNINITIALIZED ||
+ state == PREMONOMORPHIC ||
state == MONOMORPHIC_PROTOTYPE_FAILURE) {
- set_target(Code::cast(code));
+ set_target(*code);
} else if (state == MONOMORPHIC) {
- set_target(megamorphic_stub());
+ set_target(*megamorphic_stub());
} else if (state == MEGAMORPHIC) {
// Cache code holding map should be consistent with
// GenerateMonomorphicCacheProbe.
- Map* map = JSObject::cast(object->IsJSObject() ? *object :
- object->GetPrototype())->map();
-
- isolate()->stub_cache()->Set(*name, map, Code::cast(code));
+ isolate()->stub_cache()->Set(*name, receiver->map(), *code);
}
#ifdef DEBUG
@@ -1089,7 +1074,8 @@ MaybeObject* KeyedLoadIC::ConstructMegamorphicStub(
CodeList* targets,
StrictModeFlag strict_mode) {
Object* object;
- KeyedLoadStubCompiler compiler;
+ HandleScope scope(isolate());
+ KeyedLoadStubCompiler compiler(isolate());
MaybeObject* maybe_code = compiler.CompileLoadMegamorphic(receiver_maps,
targets);
if (!maybe_code->ToObject(&object)) return maybe_code;
@@ -1716,7 +1702,8 @@ MaybeObject* KeyedStoreIC::ConstructMegamorphicStub(
CodeList* targets,
StrictModeFlag strict_mode) {
Object* object;
- KeyedStoreStubCompiler compiler(strict_mode);
+ HandleScope scope(isolate());
+ KeyedStoreStubCompiler compiler(isolate(), strict_mode);
MaybeObject* maybe_code = compiler.CompileStoreMegamorphic(receiver_maps,
targets);
if (!maybe_code->ToObject(&object)) return maybe_code;
« no previous file with comments | « src/ic.h ('k') | src/runtime.cc » ('j') | src/stub-cache.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698