Commit d495f493 authored by ager@chromium.org's avatar ager@chromium.org

Cleanup usage of HEAP and FACTORY in the cache stub compiler.

Review URL: http://codereview.chromium.org/6770011
Patch from Karl Klose <karlklose@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7423 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ecc21b99
......@@ -555,7 +555,7 @@ static void PushInterceptorArguments(MacroAssembler* masm,
JSObject* holder_obj) {
__ push(name);
InterceptorInfo* interceptor = holder_obj->GetNamedInterceptor();
ASSERT(!HEAP->InNewSpace(interceptor));
ASSERT(!masm->isolate()->heap()->InNewSpace(interceptor));
Register scratch = name;
__ mov(scratch, Operand(Handle<Object>(interceptor)));
__ push(scratch);
......@@ -624,7 +624,7 @@ static MaybeObject* GenerateFastApiDirectCall(MacroAssembler* masm,
// Pass the additional arguments FastHandleApiCall expects.
Object* call_data = optimization.api_call_info()->data();
Handle<CallHandlerInfo> api_call_info_handle(optimization.api_call_info());
if (HEAP->InNewSpace(call_data)) {
if (masm->isolate()->heap()->InNewSpace(call_data)) {
__ Move(r0, api_call_info_handle);
__ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kDataOffset));
} else {
......@@ -719,7 +719,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
name,
holder,
miss);
return HEAP->undefined_value();
return masm->isolate()->heap()->undefined_value();
}
}
......@@ -822,7 +822,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
FreeSpaceForFastApiCall(masm);
}
return HEAP->undefined_value();
return masm->isolate()->heap()->undefined_value();
}
void CompileRegular(MacroAssembler* masm,
......@@ -1091,7 +1091,7 @@ Register StubCompiler::CheckPrototypes(JSObject* object,
!current->IsJSGlobalObject() &&
!current->IsJSGlobalProxy()) {
if (!name->IsSymbol()) {
MaybeObject* maybe_lookup_result = HEAP->LookupSymbol(name);
MaybeObject* maybe_lookup_result = heap()->LookupSymbol(name);
Object* lookup_result = NULL; // Initialization to please compiler.
if (!maybe_lookup_result->ToObject(&lookup_result)) {
set_failure(Failure::cast(maybe_lookup_result));
......@@ -1111,7 +1111,7 @@ Register StubCompiler::CheckPrototypes(JSObject* object,
__ ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
reg = holder_reg; // from now the object is in holder_reg
__ ldr(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset));
} else if (HEAP->InNewSpace(prototype)) {
} else if (heap()->InNewSpace(prototype)) {
// Get the map of the current object.
__ ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
__ cmp(scratch1, Operand(Handle<Map>(current->map())));
......@@ -1259,7 +1259,7 @@ MaybeObject* StubCompiler::GenerateLoadCallback(JSObject* object,
__ push(receiver);
__ mov(scratch2, sp); // scratch2 = AccessorInfo::args_
Handle<AccessorInfo> callback_handle(callback);
if (HEAP->InNewSpace(callback_handle->data())) {
if (heap()->InNewSpace(callback_handle->data())) {
__ Move(scratch3, callback_handle);
__ ldr(scratch3, FieldMemOperand(scratch3, AccessorInfo::kDataOffset));
} else {
......@@ -1477,7 +1477,7 @@ void CallStubCompiler::GenerateLoadFunctionFromCell(JSGlobalPropertyCell* cell,
__ ldr(r1, FieldMemOperand(r3, JSGlobalPropertyCell::kValueOffset));
// Check that the cell contains the same function.
if (HEAP->InNewSpace(function)) {
if (heap()->InNewSpace(function)) {
// We can't embed a pointer to a function in new space so we have
// to verify that the shared function info is unchanged. This has
// the nice side effect that multiple closures based on the same
......@@ -1560,7 +1560,7 @@ MaybeObject* CallStubCompiler::CompileArrayPushCall(Object* object,
// -----------------------------------
// If object is not an array, bail out to regular call.
if (!object->IsJSArray() || cell != NULL) return HEAP->undefined_value();
if (!object->IsJSArray() || cell != NULL) return heap()->undefined_value();
Label miss;
......@@ -1720,7 +1720,7 @@ MaybeObject* CallStubCompiler::CompileArrayPopCall(Object* object,
// -----------------------------------
// If object is not an array, bail out to regular call.
if (!object->IsJSArray() || cell != NULL) return HEAP->undefined_value();
if (!object->IsJSArray() || cell != NULL) return heap()->undefined_value();
Label miss, return_undefined, call_builtin;
......@@ -1806,7 +1806,7 @@ MaybeObject* CallStubCompiler::CompileStringCharCodeAtCall(
// -----------------------------------
// If object is not a string, bail out to regular call.
if (!object->IsString() || cell != NULL) return HEAP->undefined_value();
if (!object->IsString() || cell != NULL) return heap()->undefined_value();
const int argc = arguments().immediate();
......@@ -1890,7 +1890,7 @@ MaybeObject* CallStubCompiler::CompileStringCharAtCall(
// -----------------------------------
// If object is not a string, bail out to regular call.
if (!object->IsString() || cell != NULL) return HEAP->undefined_value();
if (!object->IsString() || cell != NULL) return heap()->undefined_value();
const int argc = arguments().immediate();
......@@ -1979,7 +1979,7 @@ MaybeObject* CallStubCompiler::CompileStringFromCharCodeCall(
// If the object is not a JSObject or we got an unexpected number of
// arguments, bail out to the regular call.
if (!object->IsJSObject() || argc != 1) return HEAP->undefined_value();
if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
Label miss;
GenerateNameCheck(name, &miss);
......@@ -2048,8 +2048,9 @@ MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object,
// -- sp[argc * 4] : receiver
// -----------------------------------
if (!masm()->isolate()->cpu_features()->IsSupported(VFP3))
return HEAP->undefined_value();
if (!masm()->isolate()->cpu_features()->IsSupported(VFP3)) {
return heap()->undefined_value();
}
CpuFeatures::Scope scope_vfp3(VFP3);
......@@ -2057,7 +2058,7 @@ MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object,
// If the object is not a JSObject or we got an unexpected number of
// arguments, bail out to the regular call.
if (!object->IsJSObject() || argc != 1) return HEAP->undefined_value();
if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
Label miss, slow;
GenerateNameCheck(name, &miss);
......@@ -2199,7 +2200,7 @@ MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object,
// If the object is not a JSObject or we got an unexpected number of
// arguments, bail out to the regular call.
if (!object->IsJSObject() || argc != 1) return HEAP->undefined_value();
if (!object->IsJSObject() || argc != 1) return heap()->undefined_value();
Label miss;
GenerateNameCheck(name, &miss);
......@@ -2291,18 +2292,16 @@ MaybeObject* CallStubCompiler::CompileFastApiCall(
JSGlobalPropertyCell* cell,
JSFunction* function,
String* name) {
Isolate* isolate = masm()->isolate();
Heap* heap = isolate->heap();
Counters* counters = isolate->counters();
Counters* counters = isolate()->counters();
ASSERT(optimization.is_simple_api_call());
// Bail out if object is a global object as we don't want to
// repatch it to global receiver.
if (object->IsGlobalObject()) return heap->undefined_value();
if (cell != NULL) return heap->undefined_value();
if (object->IsGlobalObject()) return heap()->undefined_value();
if (cell != NULL) return heap()->undefined_value();
int depth = optimization.GetPrototypeDepthOfExpectedType(
JSObject::cast(object), holder);
if (depth == kInvalidProtoDepth) return heap->undefined_value();
if (depth == kInvalidProtoDepth) return heap()->undefined_value();
Label miss, miss_before_stack_reserved;
......@@ -2802,7 +2801,7 @@ MaybeObject* LoadStubCompiler::CompileLoadNonexistent(String* name,
GenerateLoadMiss(masm(), Code::LOAD_IC);
// Return the generated code.
return GetCode(NONEXISTENT, HEAP->empty_string());
return GetCode(NONEXISTENT, heap()->empty_string());
}
......@@ -3251,7 +3250,7 @@ MaybeObject* KeyedStoreStubCompiler::CompileStoreSpecialized(
__ ldr(elements_reg,
FieldMemOperand(receiver_reg, JSObject::kElementsOffset));
__ ldr(scratch, FieldMemOperand(elements_reg, HeapObject::kMapOffset));
__ cmp(scratch, Operand(Handle<Map>(FACTORY->fixed_array_map())));
__ cmp(scratch, Operand(Handle<Map>(factory()->fixed_array_map())));
__ b(ne, &miss);
// Check that the key is within bounds.
......
This diff is collapsed.
......@@ -64,7 +64,7 @@ Code* StubCache::Set(String* name, Map* map, Code* code) {
// Validate that the name does not move on scavenge, and that we
// can use identity checks instead of string equality checks.
ASSERT(!isolate_->heap()->InNewSpace(name));
ASSERT(!heap()->InNewSpace(name));
ASSERT(name->IsSymbol());
// The state bits are not important to the hash function because
......@@ -108,10 +108,10 @@ MaybeObject* StubCache::ComputeLoadNonexistent(String* name,
// there are global objects involved, we need to check global
// property cells in the stub and therefore the stub will be
// specific to the name.
String* cache_name = isolate_->heap()->empty_string();
String* cache_name = heap()->empty_string();
if (receiver->IsGlobalObject()) cache_name = name;
JSObject* last = receiver;
while (last->GetPrototype() != isolate_->heap()->null_value()) {
while (last->GetPrototype() != heap()->null_value()) {
last = JSObject::cast(last->GetPrototype());
if (last->IsGlobalObject()) cache_name = name;
}
......@@ -466,7 +466,7 @@ MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) {
// keyed loads that are not array elements go through a generic builtin stub.
Code::Flags flags =
Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL);
String* name = isolate_->heap()->KeyedLoadSpecialized_symbol();
String* name = heap()->KeyedLoadSpecialized_symbol();
Object* code = receiver->map()->FindInCodeCache(name, flags);
if (code->IsUndefined()) {
KeyedLoadStubCompiler compiler;
......@@ -518,7 +518,7 @@ MaybeObject* StubCache::ComputeKeyedStoreSpecialized(
StrictModeFlag strict_mode) {
Code::Flags flags =
Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL, strict_mode);
String* name = isolate_->heap()->KeyedStoreSpecialized_symbol();
String* name = heap()->KeyedStoreSpecialized_symbol();
Object* code = receiver->map()->FindInCodeCache(name, flags);
if (code->IsUndefined()) {
KeyedStoreStubCompiler compiler(strict_mode);
......@@ -563,26 +563,27 @@ ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) {
}
}
String* ExternalArrayTypeToStubName(ExternalArrayType array_type,
String* ExternalArrayTypeToStubName(Heap* heap,
ExternalArrayType array_type,
bool is_store) {
if (is_store) {
switch (array_type) {
case kExternalByteArray:
return HEAP->KeyedStoreExternalByteArray_symbol();
return heap->KeyedStoreExternalByteArray_symbol();
case kExternalUnsignedByteArray:
return HEAP->KeyedStoreExternalUnsignedByteArray_symbol();
return heap->KeyedStoreExternalUnsignedByteArray_symbol();
case kExternalShortArray:
return HEAP->KeyedStoreExternalShortArray_symbol();
return heap->KeyedStoreExternalShortArray_symbol();
case kExternalUnsignedShortArray:
return HEAP->KeyedStoreExternalUnsignedShortArray_symbol();
return heap->KeyedStoreExternalUnsignedShortArray_symbol();
case kExternalIntArray:
return HEAP->KeyedStoreExternalIntArray_symbol();
return heap->KeyedStoreExternalIntArray_symbol();
case kExternalUnsignedIntArray:
return HEAP->KeyedStoreExternalUnsignedIntArray_symbol();
return heap->KeyedStoreExternalUnsignedIntArray_symbol();
case kExternalFloatArray:
return HEAP->KeyedStoreExternalFloatArray_symbol();
return heap->KeyedStoreExternalFloatArray_symbol();
case kExternalPixelArray:
return HEAP->KeyedStoreExternalPixelArray_symbol();
return heap->KeyedStoreExternalPixelArray_symbol();
default:
UNREACHABLE();
return NULL;
......@@ -590,21 +591,21 @@ String* ExternalArrayTypeToStubName(ExternalArrayType array_type,
} else {
switch (array_type) {
case kExternalByteArray:
return HEAP->KeyedLoadExternalByteArray_symbol();
return heap->KeyedLoadExternalByteArray_symbol();
case kExternalUnsignedByteArray:
return HEAP->KeyedLoadExternalUnsignedByteArray_symbol();
return heap->KeyedLoadExternalUnsignedByteArray_symbol();
case kExternalShortArray:
return HEAP->KeyedLoadExternalShortArray_symbol();
return heap->KeyedLoadExternalShortArray_symbol();
case kExternalUnsignedShortArray:
return HEAP->KeyedLoadExternalUnsignedShortArray_symbol();
return heap->KeyedLoadExternalUnsignedShortArray_symbol();
case kExternalIntArray:
return HEAP->KeyedLoadExternalIntArray_symbol();
return heap->KeyedLoadExternalIntArray_symbol();
case kExternalUnsignedIntArray:
return HEAP->KeyedLoadExternalUnsignedIntArray_symbol();
return heap->KeyedLoadExternalUnsignedIntArray_symbol();
case kExternalFloatArray:
return HEAP->KeyedLoadExternalFloatArray_symbol();
return heap->KeyedLoadExternalFloatArray_symbol();
case kExternalPixelArray:
return HEAP->KeyedLoadExternalPixelArray_symbol();
return heap->KeyedLoadExternalPixelArray_symbol();
default:
UNREACHABLE();
return NULL;
......@@ -627,7 +628,7 @@ MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray(
strict_mode);
ExternalArrayType array_type =
ElementsKindToExternalArrayType(receiver->GetElementsKind());
String* name = ExternalArrayTypeToStubName(array_type, is_store);
String* name = ExternalArrayTypeToStubName(heap(), array_type, is_store);
Object* code = receiver->map()->FindInCodeCache(name, flags);
if (code->IsUndefined()) {
ExternalArrayStubCompiler compiler;
......@@ -759,7 +760,7 @@ MaybeObject* StubCache::ComputeKeyedStoreField(String* name,
compiler.CompileStoreField(receiver, field_index, transition, name);
if (!maybe_code->ToObject(&code)) return maybe_code;
}
PROFILE(isolate_,
PROFILE(isolate(),
CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
Code::cast(code), name));
GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code)));
......@@ -917,7 +918,7 @@ MaybeObject* StubCache::ComputeCallInterceptor(int argc,
if (!maybe_code->ToObject(&code)) return maybe_code;
}
ASSERT_EQ(flags, Code::cast(code)->flags());
PROFILE(isolate_,
PROFILE(isolate(),
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
Code::cast(code), name));
GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
......@@ -975,7 +976,7 @@ MaybeObject* StubCache::ComputeCallGlobal(int argc,
if (!maybe_code->ToObject(&code)) return maybe_code;
}
ASSERT_EQ(flags, Code::cast(code)->flags());
PROFILE(isolate_,
PROFILE(isolate(),
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
Code::cast(code), name));
GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
......@@ -1046,8 +1047,8 @@ Code* StubCache::FindCallInitialize(int argc,
Code::kNoExtraICState,
NORMAL,
argc);
Object* result = ProbeCache(isolate_, flags)->ToObjectUnchecked();
ASSERT(result != isolate_->heap()->undefined_value());
Object* result = ProbeCache(isolate(), flags)->ToObjectUnchecked();
ASSERT(result != heap()->undefined_value());
// This might be called during the marking phase of the collector
// hence the unchecked cast.
return reinterpret_cast<Code*>(result);
......@@ -1219,12 +1220,12 @@ MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc,
void StubCache::Clear() {
for (int i = 0; i < kPrimaryTableSize; i++) {
primary_[i].key = isolate_->heap()->empty_string();
primary_[i].key = heap()->empty_string();
primary_[i].value = isolate_->builtins()->builtin(
Builtins::kIllegal);
}
for (int j = 0; j < kSecondaryTableSize; j++) {
secondary_[j].key = isolate_->heap()->empty_string();
secondary_[j].key = heap()->empty_string();
secondary_[j].value = isolate_->builtins()->builtin(
Builtins::kIllegal);
}
......@@ -1668,7 +1669,7 @@ MaybeObject* StubCompiler::GetCodeWithFlags(Code::Flags flags,
// Create code object in the heap.
CodeDesc desc;
masm_.GetCode(&desc);
MaybeObject* result = HEAP->CreateCode(desc, flags, masm_.CodeObject());
MaybeObject* result = heap()->CreateCode(desc, flags, masm_.CodeObject());
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code_stubs && !result->IsFailure()) {
Code::cast(result->ToObjectUnchecked())->Disassemble(name);
......
......@@ -322,6 +322,8 @@ class StubCache {
return NULL;
}
Isolate* isolate() { return isolate_; }
Heap* heap() { return isolate()->heap(); };
private:
explicit StubCache(Isolate* isolate);
......@@ -559,6 +561,8 @@ class StubCompiler BASE_EMBEDDED {
LookupResult* lookup);
Isolate* isolate() { return scope_.isolate(); }
Heap* heap() { return isolate()->heap(); }
Factory* factory() { return isolate()->factory(); }
private:
HandleScope scope_;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment