Index: src/ic/x64/ic-compiler-x64.cc |
diff --git a/src/x64/stub-cache-x64.cc b/src/ic/x64/ic-compiler-x64.cc |
similarity index 79% |
rename from src/x64/stub-cache-x64.cc |
rename to src/ic/x64/ic-compiler-x64.cc |
index 3619a9b092c8a322e63d2744414328c80ecbebbe..5e6f2254660504e5a776716b658ace24c98017bc 100644 |
--- a/src/x64/stub-cache-x64.cc |
+++ b/src/ic/x64/ic-compiler-x64.cc |
@@ -1,4 +1,4 @@ |
-// Copyright 2012 the V8 project authors. All rights reserved. |
+// Copyright 2014 the V8 project authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -6,10 +6,7 @@ |
#if V8_TARGET_ARCH_X64 |
-#include "src/arguments.h" |
-#include "src/codegen.h" |
-#include "src/ic-inl.h" |
-#include "src/stub-cache.h" |
+#include "src/ic/ic-compiler.h" |
namespace v8 { |
namespace internal { |
@@ -17,75 +14,6 @@ namespace internal { |
#define __ ACCESS_MASM(masm) |
-static void ProbeTable(Isolate* isolate, |
- MacroAssembler* masm, |
- Code::Flags flags, |
- StubCache::Table table, |
- Register receiver, |
- Register name, |
- // The offset is scaled by 4, based on |
- // kCacheIndexShift, which is two bits |
- Register offset) { |
- // We need to scale up the pointer by 2 when the offset is scaled by less |
- // than the pointer size. |
- DCHECK(kPointerSize == kInt64Size |
- ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1 |
- : kPointerSizeLog2 == StubCache::kCacheIndexShift); |
- ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1; |
- |
- DCHECK_EQ(3 * kPointerSize, sizeof(StubCache::Entry)); |
- // The offset register holds the entry offset times four (due to masking |
- // and shifting optimizations). |
- ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
- ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
- Label miss; |
- |
- // Multiply by 3 because there are 3 fields per entry (name, code, map). |
- __ leap(offset, Operand(offset, offset, times_2, 0)); |
- |
- __ LoadAddress(kScratchRegister, key_offset); |
- |
- // Check that the key in the entry matches the name. |
- // Multiply entry offset by 16 to get the entry address. Since the |
- // offset register already holds the entry offset times four, multiply |
- // by a further four. |
- __ cmpl(name, Operand(kScratchRegister, offset, scale_factor, 0)); |
- __ j(not_equal, &miss); |
- |
- // Get the map entry from the cache. |
- // Use key_offset + kPointerSize * 2, rather than loading map_offset. |
- __ movp(kScratchRegister, |
- Operand(kScratchRegister, offset, scale_factor, kPointerSize * 2)); |
- __ cmpp(kScratchRegister, FieldOperand(receiver, HeapObject::kMapOffset)); |
- __ j(not_equal, &miss); |
- |
- // Get the code entry from the cache. |
- __ LoadAddress(kScratchRegister, value_offset); |
- __ movp(kScratchRegister, |
- Operand(kScratchRegister, offset, scale_factor, 0)); |
- |
- // Check that the flags match what we're looking for. |
- __ movl(offset, FieldOperand(kScratchRegister, Code::kFlagsOffset)); |
- __ andp(offset, Immediate(~Code::kFlagsNotUsedInLookup)); |
- __ cmpl(offset, Immediate(flags)); |
- __ j(not_equal, &miss); |
- |
-#ifdef DEBUG |
- if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
- __ jmp(&miss); |
- } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
- __ jmp(&miss); |
- } |
-#endif |
- |
- // Jump to the first instruction in the code stub. |
- __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
- __ jmp(kScratchRegister); |
- |
- __ bind(&miss); |
-} |
- |
- |
void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup( |
MacroAssembler* masm, Label* miss_label, Register receiver, |
Handle<Name> name, Register scratch0, Register scratch1) { |
@@ -119,83 +47,13 @@ void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup( |
__ j(not_equal, miss_label); |
Label done; |
- NameDictionaryLookupStub::GenerateNegativeLookup(masm, |
- miss_label, |
- &done, |
- properties, |
- name, |
- scratch1); |
+ NameDictionaryLookupStub::GenerateNegativeLookup(masm, miss_label, &done, |
+ properties, name, scratch1); |
__ bind(&done); |
__ DecrementCounter(counters->negative_lookups_miss(), 1); |
} |
-void StubCache::GenerateProbe(MacroAssembler* masm, |
- Code::Flags flags, |
- Register receiver, |
- Register name, |
- Register scratch, |
- Register extra, |
- Register extra2, |
- Register extra3) { |
- Isolate* isolate = masm->isolate(); |
- Label miss; |
- USE(extra); // The register extra is not used on the X64 platform. |
- USE(extra2); // The register extra2 is not used on the X64 platform. |
- USE(extra3); // The register extra2 is not used on the X64 platform. |
- // Make sure that code is valid. The multiplying code relies on the |
- // entry size being 3 * kPointerSize. |
- DCHECK(sizeof(Entry) == 3 * kPointerSize); |
- |
- // Make sure the flags do not name a specific type. |
- DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
- |
- // Make sure that there are no register conflicts. |
- DCHECK(!scratch.is(receiver)); |
- DCHECK(!scratch.is(name)); |
- |
- // Check scratch register is valid, extra and extra2 are unused. |
- DCHECK(!scratch.is(no_reg)); |
- DCHECK(extra2.is(no_reg)); |
- DCHECK(extra3.is(no_reg)); |
- |
- Counters* counters = masm->isolate()->counters(); |
- __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1); |
- |
- // Check that the receiver isn't a smi. |
- __ JumpIfSmi(receiver, &miss); |
- |
- // Get the map of the receiver and compute the hash. |
- __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
- // Use only the low 32 bits of the map pointer. |
- __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
- __ xorp(scratch, Immediate(flags)); |
- // We mask out the last two bits because they are not part of the hash and |
- // they are always 01 for maps. Also in the two 'and' instructions below. |
- __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
- |
- // Probe the primary table. |
- ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch); |
- |
- // Primary miss: Compute hash for secondary probe. |
- __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); |
- __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
- __ xorp(scratch, Immediate(flags)); |
- __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); |
- __ subl(scratch, name); |
- __ addl(scratch, Immediate(flags)); |
- __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); |
- |
- // Probe the secondary table. |
- ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch); |
- |
- // Cache miss: Fall-through and let caller handle the miss by |
- // entering the runtime system. |
- __ bind(&miss); |
- __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); |
-} |
- |
- |
void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
MacroAssembler* masm, int index, Register prototype, Label* miss) { |
Isolate* isolate = masm->isolate(); |
@@ -227,10 +85,8 @@ void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype( |
} |
-static void PushInterceptorArguments(MacroAssembler* masm, |
- Register receiver, |
- Register holder, |
- Register name, |
+static void PushInterceptorArguments(MacroAssembler* masm, Register receiver, |
+ Register holder, Register name, |
Handle<JSObject> holder_obj) { |
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0); |
STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1); |
@@ -248,12 +104,8 @@ static void PushInterceptorArguments(MacroAssembler* masm, |
static void CompileCallLoadPropertyWithInterceptor( |
- MacroAssembler* masm, |
- Register receiver, |
- Register holder, |
- Register name, |
- Handle<JSObject> holder_obj, |
- IC::UtilityId id) { |
+ MacroAssembler* masm, Register receiver, Register holder, Register name, |
+ Handle<JSObject> holder_obj, IC::UtilityId id) { |
PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
__ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()), |
NamedLoadHandlerCompiler::kInterceptorArgsLength); |
@@ -272,7 +124,7 @@ void PropertyHandlerCompiler::GenerateFastApiCall( |
__ Push(receiver); |
// Write the arguments to stack frame. |
for (int i = 0; i < argc; i++) { |
- Register arg = values[argc-1-i]; |
+ Register arg = values[argc - 1 - i]; |
DCHECK(!receiver.is(arg)); |
DCHECK(!scratch_in.is(arg)); |
__ Push(arg); |
@@ -289,16 +141,15 @@ void PropertyHandlerCompiler::GenerateFastApiCall( |
// Put holder in place. |
CallOptimization::HolderLookup holder_lookup; |
- Handle<JSObject> api_holder = optimization.LookupHolderOfExpectedType( |
- receiver_map, |
- &holder_lookup); |
+ Handle<JSObject> api_holder = |
+ optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup); |
switch (holder_lookup) { |
case CallOptimization::kHolderIsReceiver: |
__ Move(holder, receiver); |
break; |
case CallOptimization::kHolderFound: |
__ Move(holder, api_holder); |
- break; |
+ break; |
case CallOptimization::kHolderNotFound: |
UNREACHABLE(); |
break; |
@@ -326,8 +177,8 @@ void PropertyHandlerCompiler::GenerateFastApiCall( |
// Put api_function_address in place. |
Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
- __ Move( |
- api_function_address, function_address, RelocInfo::EXTERNAL_REFERENCE); |
+ __ Move(api_function_address, function_address, |
+ RelocInfo::EXTERNAL_REFERENCE); |
// Jump to stub. |
CallApiFunctionStub stub(isolate, is_store, call_data_undefined, argc); |
@@ -338,8 +189,7 @@ void PropertyHandlerCompiler::GenerateFastApiCall( |
void PropertyHandlerCompiler::GenerateCheckPropertyCell( |
MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name, |
Register scratch, Label* miss) { |
- Handle<PropertyCell> cell = |
- JSGlobalObject::EnsurePropertyCell(global, name); |
+ Handle<PropertyCell> cell = JSGlobalObject::EnsurePropertyCell(global, name); |
DCHECK(cell->value()->IsTheHole()); |
__ Move(scratch, cell); |
__ Cmp(FieldOperand(scratch, Cell::kValueOffset), |
@@ -445,13 +295,8 @@ void NamedStoreHandlerCompiler::GenerateStoreTransition( |
__ movp(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1); |
// Update the write barrier for the map field. |
- __ RecordWriteField(receiver_reg, |
- HeapObject::kMapOffset, |
- scratch1, |
- scratch2, |
- kDontSaveFPRegs, |
- OMIT_REMEMBERED_SET, |
- OMIT_SMI_CHECK); |
+ __ RecordWriteField(receiver_reg, HeapObject::kMapOffset, scratch1, scratch2, |
+ kDontSaveFPRegs, OMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
if (details.type() == CONSTANT) { |
DCHECK(value_reg.is(rax)); |
@@ -468,8 +313,8 @@ void NamedStoreHandlerCompiler::GenerateStoreTransition( |
index -= transition->inobject_properties(); |
// TODO(verwaest): Share this code as a code stub. |
- SmiCheck smi_check = representation.IsTagged() |
- ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; |
+ SmiCheck smi_check = |
+ representation.IsTagged() ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; |
if (index < 0) { |
// Set the property straight into the object. |
int offset = transition->instance_size() + (index * kPointerSize); |
@@ -484,9 +329,8 @@ void NamedStoreHandlerCompiler::GenerateStoreTransition( |
if (!representation.IsDouble()) { |
__ movp(storage_reg, value_reg); |
} |
- __ RecordWriteField( |
- receiver_reg, offset, storage_reg, scratch1, kDontSaveFPRegs, |
- EMIT_REMEMBERED_SET, smi_check); |
+ __ RecordWriteField(receiver_reg, offset, storage_reg, scratch1, |
+ kDontSaveFPRegs, EMIT_REMEMBERED_SET, smi_check); |
} |
} else { |
// Write to the properties array. |
@@ -504,9 +348,8 @@ void NamedStoreHandlerCompiler::GenerateStoreTransition( |
if (!representation.IsDouble()) { |
__ movp(storage_reg, value_reg); |
} |
- __ RecordWriteField( |
- scratch1, offset, storage_reg, receiver_reg, kDontSaveFPRegs, |
- EMIT_REMEMBERED_SET, smi_check); |
+ __ RecordWriteField(scratch1, offset, storage_reg, receiver_reg, |
+ kDontSaveFPRegs, EMIT_REMEMBERED_SET, smi_check); |
} |
} |
@@ -548,8 +391,8 @@ Register PropertyHandlerCompiler::CheckPrototypes( |
// Make sure there's no overlap between holder and object registers. |
DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); |
- DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) |
- && !scratch2.is(scratch1)); |
+ DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) && |
+ !scratch2.is(scratch1)); |
// Keep track of the current object in register reg. On the first |
// iteration, reg is an alias for object_reg, on later iterations, |
@@ -584,10 +427,10 @@ Register PropertyHandlerCompiler::CheckPrototypes( |
} |
DCHECK(current.is_null() || |
current->property_dictionary()->FindEntry(name) == |
- NameDictionary::kNotFound); |
+ NameDictionary::kNotFound); |
- GenerateDictionaryNegativeLookup(masm(), miss, reg, name, |
- scratch1, scratch2); |
+ GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, |
+ scratch2); |
__ movp(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); |
reg = holder_reg; // From now on the object will be in holder_reg. |
@@ -616,9 +459,8 @@ Register PropertyHandlerCompiler::CheckPrototypes( |
if (current_map->IsJSGlobalProxyMap()) { |
__ CheckAccessGlobalProxy(reg, scratch2, miss); |
} else if (current_map->IsJSGlobalObjectMap()) { |
- GenerateCheckPropertyCell( |
- masm(), Handle<JSGlobalObject>::cast(current), name, |
- scratch2, miss); |
+ GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), |
+ name, scratch2, miss); |
} |
reg = holder_reg; // From now on the object will be in holder_reg. |
@@ -703,7 +545,7 @@ void NamedLoadHandlerCompiler::GenerateLoadCallback( |
__ Push(kScratchRegister); // return value |
__ Push(kScratchRegister); // return value default |
__ PushAddress(ExternalReference::isolate_address(isolate())); |
- __ Push(reg); // holder |
+ __ Push(reg); // holder |
__ Push(name()); // name |
// Save a pointer to where we pushed the arguments pointer. This will be |
// passed as the const PropertyAccessorInfo& to the C++ callback. |
@@ -854,8 +696,8 @@ void NamedStoreHandlerCompiler::GenerateStoreViaSetter( |
__ Push(value()); |
ParameterCount actual(1); |
ParameterCount expected(setter); |
- __ InvokeFunction(setter, expected, actual, |
- CALL_FUNCTION, NullCallWrapper()); |
+ __ InvokeFunction(setter, expected, actual, CALL_FUNCTION, |
+ NullCallWrapper()); |
} else { |
// If we generate a global code snippet for deoptimization only, remember |
// the place to continue after deoptimization. |
@@ -910,8 +752,7 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( |
} else { |
Label next_map; |
__ j(not_equal, &next_map, Label::kNear); |
- __ Move(transition_map(), |
- transitioned_maps->at(i), |
+ __ Move(transition_map(), transitioned_maps->at(i), |
RelocInfo::EMBEDDED_OBJECT); |
__ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET); |
__ bind(&next_map); |
@@ -931,7 +772,7 @@ Register* PropertyAccessCompiler::load_calling_convention() { |
// receiver, name, scratch1, scratch2, scratch3, scratch4. |
Register receiver = LoadIC::ReceiverRegister(); |
Register name = LoadIC::NameRegister(); |
- static Register registers[] = { receiver, name, rax, rbx, rdi, r8 }; |
+ static Register registers[] = {receiver, name, rax, rbx, rdi, r8}; |
return registers; |
} |
@@ -941,7 +782,7 @@ Register* PropertyAccessCompiler::store_calling_convention() { |
Register receiver = KeyedStoreIC::ReceiverRegister(); |
Register name = KeyedStoreIC::NameRegister(); |
DCHECK(rbx.is(KeyedStoreIC::MapRegister())); |
- static Register registers[] = { receiver, name, rbx, rdi, r8 }; |
+ static Register registers[] = {receiver, name, rbx, rdi, r8}; |
return registers; |
} |
@@ -974,8 +815,8 @@ void NamedLoadHandlerCompiler::GenerateLoadViaGetter( |
__ Push(receiver); |
ParameterCount actual(0); |
ParameterCount expected(getter); |
- __ InvokeFunction(getter, expected, actual, |
- CALL_FUNCTION, NullCallWrapper()); |
+ __ InvokeFunction(getter, expected, actual, CALL_FUNCTION, |
+ NullCallWrapper()); |
} else { |
// If we generate a global code snippet for deoptimization only, remember |
// the place to continue after deoptimization. |
@@ -1069,7 +910,7 @@ Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types, |
} |
DCHECK(number_of_handled_maps > 0); |
- __ bind(&miss); |
+ __ bind(&miss); |
TailCallBuiltin(masm(), MissBuiltin(kind())); |
// Return the generated code. |
@@ -1128,7 +969,7 @@ void ElementHandlerCompiler::GenerateLoadDictionaryElement( |
#undef __ |
- |
-} } // namespace v8::internal |
+} |
+} // namespace v8::internal |
#endif // V8_TARGET_ARCH_X64 |