2012-02-10 12:36:05 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#ifndef V8_IC_H_
|
|
|
|
#define V8_IC_H_
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
#include "macro-assembler.h"
|
2011-05-24 14:01:36 +00:00
|
|
|
#include "type-info.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-12-10 15:10:50 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// IC_UTIL_LIST defines all utility functions called from generated
|
|
|
|
// inline caching code. The argument for the macro, ICU, is the function name.
|
2009-07-29 12:34:21 +00:00
|
|
|
#define IC_UTIL_LIST(ICU) \
|
|
|
|
ICU(LoadIC_Miss) \
|
|
|
|
ICU(KeyedLoadIC_Miss) \
|
2011-05-18 13:17:29 +00:00
|
|
|
ICU(KeyedLoadIC_MissForceGeneric) \
|
2009-07-29 12:34:21 +00:00
|
|
|
ICU(CallIC_Miss) \
|
2010-06-07 08:27:32 +00:00
|
|
|
ICU(KeyedCallIC_Miss) \
|
2009-07-29 12:34:21 +00:00
|
|
|
ICU(StoreIC_Miss) \
|
2010-02-18 17:30:32 +00:00
|
|
|
ICU(StoreIC_ArrayLength) \
|
2013-05-08 15:02:08 +00:00
|
|
|
ICU(StoreIC_Slow) \
|
2009-07-29 12:34:21 +00:00
|
|
|
ICU(SharedStoreIC_ExtendStorage) \
|
|
|
|
ICU(KeyedStoreIC_Miss) \
|
2011-05-18 13:17:29 +00:00
|
|
|
ICU(KeyedStoreIC_MissForceGeneric) \
|
|
|
|
ICU(KeyedStoreIC_Slow) \
|
2009-07-29 12:34:21 +00:00
|
|
|
/* Utilities for IC stubs. */ \
|
|
|
|
ICU(StoreCallbackProperty) \
|
|
|
|
ICU(LoadPropertyWithInterceptorOnly) \
|
|
|
|
ICU(LoadPropertyWithInterceptorForLoad) \
|
|
|
|
ICU(LoadPropertyWithInterceptorForCall) \
|
2010-02-12 14:21:18 +00:00
|
|
|
ICU(KeyedLoadPropertyWithInterceptor) \
|
2010-03-01 16:24:05 +00:00
|
|
|
ICU(StoreInterceptorProperty) \
|
2011-05-24 12:20:16 +00:00
|
|
|
ICU(UnaryOp_Patch) \
|
|
|
|
ICU(BinaryOp_Patch) \
|
2011-07-21 13:51:04 +00:00
|
|
|
ICU(CompareIC_Miss) \
|
2013-04-24 11:32:17 +00:00
|
|
|
ICU(CompareNilIC_Miss) \
|
2013-04-18 20:37:27 +00:00
|
|
|
ICU(Unreachable) \
|
2013-05-29 14:49:28 +00:00
|
|
|
ICU(ToBooleanIC_Miss)
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
2009-07-15 12:30:28 +00:00
|
|
|
// IC is the base class for LoadIC, StoreIC, CallIC, KeyedLoadIC,
|
|
|
|
// and KeyedStoreIC.
|
2008-07-03 15:10:15 +00:00
|
|
|
//
|
|
|
|
class IC {
|
|
|
|
public:
|
|
|
|
// The ids for utility called from the generated code.
|
|
|
|
enum UtilityId {
|
|
|
|
#define CONST_NAME(name) k##name,
|
|
|
|
IC_UTIL_LIST(CONST_NAME)
|
|
|
|
#undef CONST_NAME
|
|
|
|
kUtilityCount
|
|
|
|
};
|
|
|
|
|
|
|
|
// Looks up the address of the named utility.
|
|
|
|
static Address AddressFromUtilityId(UtilityId id);
|
|
|
|
|
|
|
|
// Alias the inline cache state type to make the IC code more readable.
|
|
|
|
typedef InlineCacheState State;
|
|
|
|
|
|
|
|
// The IC code is either invoked with no extra frames on the stack
|
|
|
|
// or with a single extra frame for supporting calls.
|
|
|
|
enum FrameDepth {
|
|
|
|
NO_EXTRA_FRAME = 0,
|
|
|
|
EXTRA_CALL_FRAME = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
// Construct the IC structure with the given number of extra
|
|
|
|
// JavaScript frames on the stack.
|
2011-03-18 20:35:07 +00:00
|
|
|
IC(FrameDepth depth, Isolate* isolate);
|
2011-12-05 21:54:45 +00:00
|
|
|
virtual ~IC() {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Get the call-site target; used for determining the state.
|
2011-12-05 21:54:45 +00:00
|
|
|
Code* target() const { return GetTargetAtAddress(address()); }
|
|
|
|
inline Address address() const;
|
|
|
|
|
2010-03-09 10:49:41 +00:00
|
|
|
// Compute the current IC state based on the target stub, receiver and name.
|
|
|
|
static State StateFrom(Code* target, Object* receiver, Object* name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Clear the inline cache to initial state.
|
|
|
|
static void Clear(Address address);
|
|
|
|
|
|
|
|
// Computes the reloc info for this IC. This is a fairly expensive
|
|
|
|
// operation as it has to search through the heap to find the code
|
|
|
|
// object that contains this IC site.
|
2008-09-22 13:57:03 +00:00
|
|
|
RelocInfo::Mode ComputeMode();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Returns if this IC is for contextual (no explicit receiver)
|
|
|
|
// access to properties.
|
2013-01-23 16:04:19 +00:00
|
|
|
bool IsUndeclaredGlobal(Handle<Object> receiver) {
|
2009-12-14 09:54:13 +00:00
|
|
|
if (receiver->IsGlobalObject()) {
|
2013-01-23 16:04:19 +00:00
|
|
|
return SlowIsUndeclaredGlobal();
|
2009-12-14 09:54:13 +00:00
|
|
|
} else {
|
2013-01-23 16:04:19 +00:00
|
|
|
ASSERT(!SlowIsUndeclaredGlobal());
|
2009-12-14 09:54:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-23 16:04:19 +00:00
|
|
|
bool SlowIsUndeclaredGlobal() {
|
2008-09-22 13:57:03 +00:00
|
|
|
return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT;
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-07-02 14:15:04 +00:00
|
|
|
// Determines which map must be used for keeping the code stub.
|
|
|
|
// These methods should not be called with undefined or null.
|
|
|
|
static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object,
|
|
|
|
JSObject* holder);
|
|
|
|
static inline InlineCacheHolderFlag GetCodeCacheForObject(JSObject* object,
|
|
|
|
JSObject* holder);
|
2013-02-27 13:22:29 +00:00
|
|
|
static inline JSObject* GetCodeCacheHolder(Isolate* isolate,
|
|
|
|
Object* object,
|
2010-08-25 13:25:54 +00:00
|
|
|
InlineCacheHolderFlag holder);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Address fp() const { return fp_; }
|
|
|
|
Address pc() const { return *pc_address_; }
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate* isolate() const { return isolate_; }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2009-04-20 16:36:13 +00:00
|
|
|
#ifdef ENABLE_DEBUGGER_SUPPORT
|
2008-07-03 15:10:15 +00:00
|
|
|
// Computes the address in the original code when the code running is
|
|
|
|
// containing break points (calls to DebugBreakXXX builtins).
|
2011-12-05 21:54:45 +00:00
|
|
|
Address OriginalCodeAddress() const;
|
2009-04-20 16:36:13 +00:00
|
|
|
#endif
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Set the call-site target.
|
|
|
|
void set_target(Code* code) { SetTargetAtAddress(address(), code); }
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-12-05 21:54:45 +00:00
|
|
|
char TransitionMarkFromState(IC::State state);
|
|
|
|
|
2011-05-18 13:17:29 +00:00
|
|
|
void TraceIC(const char* type,
|
|
|
|
Handle<Object> name,
|
|
|
|
State old_state,
|
2011-09-13 12:53:28 +00:00
|
|
|
Code* new_target);
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Failure* TypeError(const char* type,
|
|
|
|
Handle<Object> object,
|
|
|
|
Handle<Object> key);
|
|
|
|
Failure* ReferenceError(const char* type, Handle<String> name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Access the target code for the given IC address.
|
|
|
|
static inline Code* GetTargetAtAddress(Address address);
|
|
|
|
static inline void SetTargetAtAddress(Address address, Code* target);
|
2012-02-20 12:57:23 +00:00
|
|
|
static void PostPatching(Address address, Code* target, Code* old_target);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-03-04 14:03:27 +00:00
|
|
|
virtual void UpdateMonomorphicIC(Handle<JSObject> receiver,
|
|
|
|
Handle<Code> handler,
|
|
|
|
Handle<String> name) {
|
|
|
|
set_target(*handler);
|
|
|
|
}
|
|
|
|
bool UpdatePolymorphicIC(State state,
|
|
|
|
StrictModeFlag strict_mode,
|
|
|
|
Handle<JSObject> receiver,
|
|
|
|
Handle<String> name,
|
|
|
|
Handle<Code> code);
|
2013-03-11 15:11:39 +00:00
|
|
|
void CopyICToMegamorphicCache(Handle<String> name);
|
2013-03-28 12:43:19 +00:00
|
|
|
bool IsTransitionedMapOfMonomorphicTarget(Map* receiver_map);
|
2013-01-25 10:34:17 +00:00
|
|
|
void PatchCache(State state,
|
|
|
|
StrictModeFlag strict_mode,
|
|
|
|
Handle<JSObject> receiver,
|
|
|
|
Handle<String> name,
|
|
|
|
Handle<Code> code);
|
2013-05-02 15:42:22 +00:00
|
|
|
virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code);
|
2013-01-25 10:34:17 +00:00
|
|
|
virtual Handle<Code> megamorphic_stub() {
|
|
|
|
UNREACHABLE();
|
|
|
|
return Handle<Code>::null();
|
|
|
|
}
|
|
|
|
virtual Handle<Code> megamorphic_stub_strict() {
|
|
|
|
UNREACHABLE();
|
|
|
|
return Handle<Code>::null();
|
|
|
|
}
|
2013-01-28 14:41:55 +00:00
|
|
|
virtual Handle<Code> generic_stub() const {
|
|
|
|
UNREACHABLE();
|
|
|
|
return Handle<Code>::null();
|
|
|
|
}
|
|
|
|
virtual Handle<Code> generic_stub_strict() const {
|
|
|
|
UNREACHABLE();
|
|
|
|
return Handle<Code>::null();
|
|
|
|
}
|
2013-01-25 10:34:17 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
private:
|
|
|
|
// Frame pointer for the frame that uses (calls) the IC.
|
|
|
|
Address fp_;
|
|
|
|
|
|
|
|
// All access to the program counter of an IC structure is indirect
|
|
|
|
// to make the code GC safe. This feature is crucial since
|
|
|
|
// GetProperty and SetProperty are called and they in turn might
|
|
|
|
// invoke the garbage collector.
|
|
|
|
Address* pc_address_;
|
2008-08-13 09:32:07 +00:00
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
Isolate* isolate_;
|
|
|
|
|
2008-08-13 09:32:07 +00:00
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(IC);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// An IC_Utility encapsulates IC::UtilityId. It exists mainly because you
|
|
|
|
// cannot make forward declarations to an enum.
|
|
|
|
class IC_Utility {
|
|
|
|
public:
|
|
|
|
explicit IC_Utility(IC::UtilityId id)
|
|
|
|
: address_(IC::AddressFromUtilityId(id)), id_(id) {}
|
|
|
|
|
|
|
|
Address address() const { return address_; }
|
|
|
|
|
|
|
|
IC::UtilityId id() const { return id_; }
|
|
|
|
private:
|
|
|
|
Address address_;
|
|
|
|
IC::UtilityId id_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-06-07 08:27:32 +00:00
|
|
|
class CallICBase: public IC {
|
2011-05-24 14:01:36 +00:00
|
|
|
public:
|
|
|
|
class Contextual: public BitField<bool, 0, 1> {};
|
|
|
|
class StringStubState: public BitField<StringStubFeedback, 1, 1> {};
|
|
|
|
|
2011-10-19 12:04:16 +00:00
|
|
|
// Returns a JSFunction or a Failure.
|
2010-10-25 15:22:03 +00:00
|
|
|
MUST_USE_RESULT MaybeObject* LoadFunction(State state,
|
2011-01-18 16:54:48 +00:00
|
|
|
Code::ExtraICState extra_ic_state,
|
2010-10-25 15:22:03 +00:00
|
|
|
Handle<Object> object,
|
|
|
|
Handle<String> name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-06-07 08:27:32 +00:00
|
|
|
protected:
|
2011-10-21 10:19:16 +00:00
|
|
|
CallICBase(Code::Kind kind, Isolate* isolate)
|
|
|
|
: IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-01-18 16:54:48 +00:00
|
|
|
bool TryUpdateExtraICState(LookupResult* lookup,
|
|
|
|
Handle<Object> object,
|
|
|
|
Code::ExtraICState* extra_ic_state);
|
|
|
|
|
2011-10-20 17:08:53 +00:00
|
|
|
// Compute a monomorphic stub if possible, otherwise return a null handle.
|
|
|
|
Handle<Code> ComputeMonomorphicStub(LookupResult* lookup,
|
|
|
|
State state,
|
|
|
|
Code::ExtraICState extra_state,
|
|
|
|
Handle<Object> object,
|
|
|
|
Handle<String> name);
|
2011-01-18 16:54:48 +00:00
|
|
|
|
2011-10-19 12:04:16 +00:00
|
|
|
// Update the inline cache and the global stub cache based on the lookup
|
|
|
|
// result.
|
2008-07-03 15:10:15 +00:00
|
|
|
void UpdateCaches(LookupResult* lookup,
|
2008-09-18 10:22:46 +00:00
|
|
|
State state,
|
2011-01-18 16:54:48 +00:00
|
|
|
Code::ExtraICState extra_ic_state,
|
2008-07-03 15:10:15 +00:00
|
|
|
Handle<Object> object,
|
|
|
|
Handle<String> name);
|
|
|
|
|
2011-10-19 12:04:16 +00:00
|
|
|
// Returns a JSFunction if the object can be called as a function, and
|
|
|
|
// patches the stack to be ready for the call. Otherwise, it returns the
|
|
|
|
// undefined value.
|
|
|
|
Handle<Object> TryCallAsFunction(Handle<Object> object);
|
2008-09-08 16:47:23 +00:00
|
|
|
|
2011-02-22 00:39:21 +00:00
|
|
|
void ReceiverToObjectIfRequired(Handle<Object> callee, Handle<Object> object);
|
2010-01-15 13:42:32 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
static void Clear(Address address, Code* target);
|
2011-05-24 14:01:36 +00:00
|
|
|
|
2011-10-24 09:33:11 +00:00
|
|
|
// Platform-specific code generation functions used by both call and
|
|
|
|
// keyed call.
|
2011-10-21 10:19:16 +00:00
|
|
|
static void GenerateMiss(MacroAssembler* masm,
|
|
|
|
int argc,
|
|
|
|
IC::UtilityId id,
|
|
|
|
Code::ExtraICState extra_state);
|
|
|
|
|
2011-10-24 09:33:11 +00:00
|
|
|
static void GenerateNormal(MacroAssembler* masm, int argc);
|
|
|
|
|
2011-10-24 10:55:00 +00:00
|
|
|
static void GenerateMonomorphicCacheProbe(MacroAssembler* masm,
|
|
|
|
int argc,
|
|
|
|
Code::Kind kind,
|
|
|
|
Code::ExtraICState extra_state);
|
|
|
|
|
2011-10-21 10:19:16 +00:00
|
|
|
Code::Kind kind_;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class IC;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-06-07 08:27:32 +00:00
|
|
|
class CallIC: public CallICBase {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit CallIC(Isolate* isolate) : CallICBase(Code::CALL_IC, isolate) {
|
|
|
|
ASSERT(target()->is_call_stub());
|
|
|
|
}
|
2010-06-07 08:27:32 +00:00
|
|
|
|
|
|
|
// Code generator routines.
|
2011-05-24 14:01:36 +00:00
|
|
|
static void GenerateInitialize(MacroAssembler* masm,
|
|
|
|
int argc,
|
2011-10-21 10:19:16 +00:00
|
|
|
Code::ExtraICState extra_state) {
|
|
|
|
GenerateMiss(masm, argc, extra_state);
|
2010-06-07 08:27:32 +00:00
|
|
|
}
|
2011-10-21 10:19:16 +00:00
|
|
|
|
2011-05-24 14:01:36 +00:00
|
|
|
static void GenerateMiss(MacroAssembler* masm,
|
|
|
|
int argc,
|
2011-10-21 10:19:16 +00:00
|
|
|
Code::ExtraICState extra_state) {
|
|
|
|
CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state);
|
|
|
|
}
|
|
|
|
|
2011-05-24 14:01:36 +00:00
|
|
|
static void GenerateMegamorphic(MacroAssembler* masm,
|
|
|
|
int argc,
|
|
|
|
Code::ExtraICState extra_ic_state);
|
2011-10-21 10:19:16 +00:00
|
|
|
|
2011-10-24 09:33:11 +00:00
|
|
|
static void GenerateNormal(MacroAssembler* masm, int argc) {
|
|
|
|
CallICBase::GenerateNormal(masm, argc);
|
|
|
|
GenerateMiss(masm, argc, Code::kNoExtraICState);
|
|
|
|
}
|
2010-06-07 08:27:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class KeyedCallIC: public CallICBase {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit KeyedCallIC(Isolate* isolate)
|
|
|
|
: CallICBase(Code::KEYED_CALL_IC, isolate) {
|
2010-06-07 08:27:32 +00:00
|
|
|
ASSERT(target()->is_keyed_call_stub());
|
|
|
|
}
|
|
|
|
|
2010-10-25 15:22:03 +00:00
|
|
|
MUST_USE_RESULT MaybeObject* LoadFunction(State state,
|
|
|
|
Handle<Object> object,
|
|
|
|
Handle<Object> key);
|
2010-06-07 08:27:32 +00:00
|
|
|
|
|
|
|
// Code generator routines.
|
|
|
|
static void GenerateInitialize(MacroAssembler* masm, int argc) {
|
|
|
|
GenerateMiss(masm, argc);
|
|
|
|
}
|
2011-10-21 10:19:16 +00:00
|
|
|
|
|
|
|
static void GenerateMiss(MacroAssembler* masm, int argc) {
|
|
|
|
CallICBase::GenerateMiss(masm, argc, IC::kKeyedCallIC_Miss,
|
|
|
|
Code::kNoExtraICState);
|
|
|
|
}
|
|
|
|
|
2010-06-07 08:27:32 +00:00
|
|
|
static void GenerateMegamorphic(MacroAssembler* masm, int argc);
|
|
|
|
static void GenerateNormal(MacroAssembler* masm, int argc);
|
2011-06-16 14:12:58 +00:00
|
|
|
static void GenerateNonStrictArguments(MacroAssembler* masm, int argc);
|
2010-06-07 08:27:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
class LoadIC: public IC {
|
|
|
|
public:
|
2013-01-30 14:25:34 +00:00
|
|
|
explicit LoadIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) {
|
2013-01-23 15:35:43 +00:00
|
|
|
ASSERT(target()->is_load_stub() || target()->is_keyed_load_stub());
|
2011-03-18 20:35:07 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Code generator routines.
|
2010-02-08 16:08:26 +00:00
|
|
|
static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
|
|
|
|
static void GeneratePreMonomorphic(MacroAssembler* masm) {
|
|
|
|
GenerateMiss(masm);
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
static void GenerateMiss(MacroAssembler* masm);
|
|
|
|
static void GenerateMegamorphic(MacroAssembler* masm);
|
|
|
|
static void GenerateNormal(MacroAssembler* masm);
|
2013-06-05 11:12:49 +00:00
|
|
|
static void GenerateRuntimeGetProperty(MacroAssembler* masm);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-01-23 15:35:43 +00:00
|
|
|
MUST_USE_RESULT MaybeObject* Load(State state,
|
|
|
|
Handle<Object> object,
|
|
|
|
Handle<String> name);
|
|
|
|
|
2013-01-21 14:53:29 +00:00
|
|
|
protected:
|
|
|
|
virtual Code::Kind kind() const { return Code::LOAD_IC; }
|
|
|
|
|
2013-01-23 15:35:43 +00:00
|
|
|
virtual Handle<Code> generic_stub() const {
|
2013-06-05 11:12:49 +00:00
|
|
|
return isolate()->builtins()->LoadIC_Slow();
|
2013-01-23 15:35:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 14:53:29 +00:00
|
|
|
virtual Handle<Code> megamorphic_stub() {
|
|
|
|
return isolate()->builtins()->LoadIC_Megamorphic();
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Update the inline cache and the global stub cache based on the
|
|
|
|
// lookup result.
|
2013-01-24 13:02:45 +00:00
|
|
|
void UpdateCaches(LookupResult* lookup,
|
|
|
|
State state,
|
|
|
|
Handle<Object> object,
|
|
|
|
Handle<String> name);
|
2013-03-04 14:03:27 +00:00
|
|
|
virtual void UpdateMonomorphicIC(Handle<JSObject> receiver,
|
|
|
|
Handle<Code> handler,
|
|
|
|
Handle<String> name);
|
|
|
|
virtual Handle<Code> ComputeLoadHandler(LookupResult* lookup,
|
|
|
|
Handle<JSObject> receiver,
|
|
|
|
Handle<String> name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-01-22 09:35:14 +00:00
|
|
|
private:
|
2008-07-03 15:10:15 +00:00
|
|
|
// Stub accessors.
|
2013-01-22 09:48:59 +00:00
|
|
|
static Handle<Code> initialize_stub() {
|
|
|
|
return Isolate::Current()->builtins()->LoadIC_Initialize();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2013-01-21 14:53:29 +00:00
|
|
|
virtual Handle<Code> pre_monomorphic_stub() {
|
2011-10-18 12:19:18 +00:00
|
|
|
return isolate()->builtins()->LoadIC_PreMonomorphic();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Clear(Address address, Code* target);
|
2009-04-28 10:40:36 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class IC;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-04 15:37:59 +00:00
|
|
|
enum ICMissMode {
|
|
|
|
MISS_FORCE_GENERIC,
|
|
|
|
MISS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-23 15:35:43 +00:00
|
|
|
class KeyedLoadIC: public LoadIC {
|
2011-05-18 13:17:29 +00:00
|
|
|
public:
|
2013-01-30 14:25:34 +00:00
|
|
|
explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate)
|
|
|
|
: LoadIC(depth, isolate) {
|
2011-05-18 13:17:29 +00:00
|
|
|
ASSERT(target()->is_keyed_load_stub());
|
2011-03-18 20:35:07 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-10-25 15:22:03 +00:00
|
|
|
MUST_USE_RESULT MaybeObject* Load(State state,
|
|
|
|
Handle<Object> object,
|
2011-05-18 13:17:29 +00:00
|
|
|
Handle<Object> key,
|
2013-01-04 15:37:59 +00:00
|
|
|
ICMissMode force_generic);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Code generator routines.
|
2013-01-04 15:37:59 +00:00
|
|
|
static void GenerateMiss(MacroAssembler* masm, ICMissMode force_generic);
|
2010-02-08 16:08:26 +00:00
|
|
|
static void GenerateRuntimeGetProperty(MacroAssembler* masm);
|
2011-05-18 13:17:29 +00:00
|
|
|
static void GenerateInitialize(MacroAssembler* masm) {
|
2013-01-04 15:37:59 +00:00
|
|
|
GenerateMiss(masm, MISS);
|
2011-05-18 13:17:29 +00:00
|
|
|
}
|
2010-02-08 16:08:26 +00:00
|
|
|
static void GeneratePreMonomorphic(MacroAssembler* masm) {
|
2013-01-04 15:37:59 +00:00
|
|
|
GenerateMiss(masm, MISS);
|
2010-02-08 16:08:26 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
static void GenerateGeneric(MacroAssembler* masm);
|
2010-01-07 10:25:20 +00:00
|
|
|
static void GenerateString(MacroAssembler* masm);
|
2010-02-12 14:21:18 +00:00
|
|
|
static void GenerateIndexedInterceptor(MacroAssembler* masm);
|
2011-06-16 14:12:58 +00:00
|
|
|
static void GenerateNonStrictArguments(MacroAssembler* masm);
|
2009-10-20 15:26:17 +00:00
|
|
|
|
2010-01-22 13:56:12 +00:00
|
|
|
// Bit mask to be tested against bit field for the cases when
|
|
|
|
// generic stub should go into slow case.
|
|
|
|
// Access check is necessary explicitly since generic stub does not perform
|
|
|
|
// map checks.
|
|
|
|
static const int kSlowCaseBitFieldMask =
|
|
|
|
(1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor);
|
|
|
|
|
2011-05-18 13:17:29 +00:00
|
|
|
protected:
|
|
|
|
virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; }
|
|
|
|
|
2013-01-23 15:35:43 +00:00
|
|
|
Handle<Code> LoadElementStub(Handle<JSObject> receiver);
|
|
|
|
|
2013-01-21 14:53:29 +00:00
|
|
|
virtual Handle<Code> megamorphic_stub() {
|
|
|
|
return isolate()->builtins()->KeyedLoadIC_Generic();
|
|
|
|
}
|
2013-01-22 09:35:14 +00:00
|
|
|
virtual Handle<Code> generic_stub() const {
|
|
|
|
return isolate()->builtins()->KeyedLoadIC_Generic();
|
|
|
|
}
|
2013-01-21 14:53:29 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Update the inline cache.
|
2013-03-04 14:03:27 +00:00
|
|
|
virtual void UpdateMonomorphicIC(Handle<JSObject> receiver,
|
|
|
|
Handle<Code> handler,
|
|
|
|
Handle<String> name);
|
|
|
|
virtual Handle<Code> ComputeLoadHandler(LookupResult* lookup,
|
|
|
|
Handle<JSObject> receiver,
|
|
|
|
Handle<String> name);
|
2013-05-02 15:42:22 +00:00
|
|
|
virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { }
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-01-22 09:35:14 +00:00
|
|
|
private:
|
2008-07-03 15:10:15 +00:00
|
|
|
// Stub accessors.
|
2013-01-22 09:48:59 +00:00
|
|
|
static Handle<Code> initialize_stub() {
|
|
|
|
return Isolate::Current()->builtins()->KeyedLoadIC_Initialize();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2013-01-21 14:53:29 +00:00
|
|
|
virtual Handle<Code> pre_monomorphic_stub() {
|
2011-10-20 09:35:47 +00:00
|
|
|
return isolate()->builtins()->KeyedLoadIC_PreMonomorphic();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-10-20 09:35:47 +00:00
|
|
|
Handle<Code> indexed_interceptor_stub() {
|
|
|
|
return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor();
|
2010-02-12 14:21:18 +00:00
|
|
|
}
|
2011-10-20 09:35:47 +00:00
|
|
|
Handle<Code> non_strict_arguments_stub() {
|
|
|
|
return isolate()->builtins()->KeyedLoadIC_NonStrictArguments();
|
2011-06-16 14:12:58 +00:00
|
|
|
}
|
2013-01-23 15:35:43 +00:00
|
|
|
Handle<Code> string_stub() {
|
|
|
|
return isolate()->builtins()->KeyedLoadIC_String();
|
|
|
|
}
|
2010-02-12 14:21:18 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
static void Clear(Address address, Code* target);
|
2008-12-22 12:56:32 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class IC;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class StoreIC: public IC {
|
|
|
|
public:
|
2013-03-20 10:37:13 +00:00
|
|
|
StoreIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) {
|
2013-01-23 15:35:43 +00:00
|
|
|
ASSERT(target()->is_store_stub() || target()->is_keyed_store_stub());
|
2011-03-18 20:35:07 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Code generators for stub routines. Only called once at startup.
|
2013-05-08 15:02:08 +00:00
|
|
|
static void GenerateSlow(MacroAssembler* masm);
|
2010-02-01 11:07:41 +00:00
|
|
|
static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
|
2008-07-03 15:10:15 +00:00
|
|
|
static void GenerateMiss(MacroAssembler* masm);
|
2011-02-13 16:19:53 +00:00
|
|
|
static void GenerateMegamorphic(MacroAssembler* masm,
|
2011-03-02 04:53:43 +00:00
|
|
|
StrictModeFlag strict_mode);
|
2010-06-30 12:27:49 +00:00
|
|
|
static void GenerateNormal(MacroAssembler* masm);
|
2011-03-02 04:53:43 +00:00
|
|
|
static void GenerateGlobalProxy(MacroAssembler* masm,
|
|
|
|
StrictModeFlag strict_mode);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-01-23 15:35:43 +00:00
|
|
|
MUST_USE_RESULT MaybeObject* Store(
|
|
|
|
State state,
|
|
|
|
StrictModeFlag strict_mode,
|
|
|
|
Handle<Object> object,
|
|
|
|
Handle<String> name,
|
|
|
|
Handle<Object> value,
|
|
|
|
JSReceiver::StoreFromKeyed store_mode =
|
|
|
|
JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED);
|
|
|
|
|
2013-01-21 14:53:29 +00:00
|
|
|
protected:
|
|
|
|
virtual Code::Kind kind() const { return Code::STORE_IC; }
|
|
|
|
virtual Handle<Code> megamorphic_stub() {
|
|
|
|
return isolate()->builtins()->StoreIC_Megamorphic();
|
|
|
|
}
|
2013-01-22 09:48:59 +00:00
|
|
|
// Stub accessors.
|
|
|
|
virtual Handle<Code> megamorphic_stub_strict() {
|
|
|
|
return isolate()->builtins()->StoreIC_Megamorphic_Strict();
|
|
|
|
}
|
|
|
|
virtual Handle<Code> global_proxy_stub() {
|
|
|
|
return isolate()->builtins()->StoreIC_GlobalProxy();
|
|
|
|
}
|
|
|
|
virtual Handle<Code> global_proxy_stub_strict() {
|
|
|
|
return isolate()->builtins()->StoreIC_GlobalProxy_Strict();
|
|
|
|
}
|
|
|
|
|
2013-01-21 14:53:29 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Update the inline cache and the global stub cache based on the
|
|
|
|
// lookup result.
|
2013-01-25 10:34:17 +00:00
|
|
|
void UpdateCaches(LookupResult* lookup,
|
|
|
|
State state,
|
|
|
|
StrictModeFlag strict_mode,
|
|
|
|
Handle<JSObject> receiver,
|
|
|
|
Handle<String> name,
|
|
|
|
Handle<Object> value);
|
|
|
|
// Compute the code stub for this store; used for rewriting to
|
|
|
|
// monomorphic state and making sure that the code stub is in the
|
|
|
|
// stub cache.
|
|
|
|
virtual Handle<Code> ComputeStoreMonomorphic(LookupResult* lookup,
|
|
|
|
StrictModeFlag strict_mode,
|
|
|
|
Handle<JSObject> receiver,
|
|
|
|
Handle<String> name);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-01-22 09:48:59 +00:00
|
|
|
private:
|
2011-03-02 04:53:43 +00:00
|
|
|
void set_target(Code* code) {
|
|
|
|
// Strict mode must be preserved across IC patching.
|
2012-02-10 12:36:05 +00:00
|
|
|
ASSERT(Code::GetStrictMode(code->extra_ic_state()) ==
|
|
|
|
Code::GetStrictMode(target()->extra_ic_state()));
|
2011-03-02 04:53:43 +00:00
|
|
|
IC::set_target(code);
|
|
|
|
}
|
|
|
|
|
2013-01-22 09:48:59 +00:00
|
|
|
static Handle<Code> initialize_stub() {
|
|
|
|
return Isolate::Current()->builtins()->StoreIC_Initialize();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2013-01-22 09:48:59 +00:00
|
|
|
static Handle<Code> initialize_stub_strict() {
|
|
|
|
return Isolate::Current()->builtins()->StoreIC_Initialize_Strict();
|
2011-02-13 16:19:53 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
static void Clear(Address address, Code* target);
|
2010-07-21 06:59:34 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class IC;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-09-25 13:35:42 +00:00
|
|
|
enum KeyedStoreCheckMap {
|
|
|
|
kDontCheckMap,
|
|
|
|
kCheckMap
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum KeyedStoreIncrementLength {
|
|
|
|
kDontIncrementLength,
|
|
|
|
kIncrementLength
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-23 15:35:43 +00:00
|
|
|
class KeyedStoreIC: public StoreIC {
|
2008-07-03 15:10:15 +00:00
|
|
|
public:
|
2013-03-20 10:37:13 +00:00
|
|
|
KeyedStoreIC(FrameDepth depth, Isolate* isolate)
|
|
|
|
: StoreIC(depth, isolate) {
|
2011-05-18 13:17:29 +00:00
|
|
|
ASSERT(target()->is_keyed_store_stub());
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-10-25 15:22:03 +00:00
|
|
|
MUST_USE_RESULT MaybeObject* Store(State state,
|
2012-09-27 11:31:26 +00:00
|
|
|
StrictModeFlag strict_mode,
|
2010-10-25 15:22:03 +00:00
|
|
|
Handle<Object> object,
|
|
|
|
Handle<Object> name,
|
2011-05-18 13:17:29 +00:00
|
|
|
Handle<Object> value,
|
2013-01-04 15:37:59 +00:00
|
|
|
ICMissMode force_generic);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Code generators for stub routines. Only called once at startup.
|
2011-05-18 13:17:29 +00:00
|
|
|
static void GenerateInitialize(MacroAssembler* masm) {
|
2013-01-04 15:37:59 +00:00
|
|
|
GenerateMiss(masm, MISS);
|
2011-05-18 13:17:29 +00:00
|
|
|
}
|
2013-01-04 15:37:59 +00:00
|
|
|
static void GenerateMiss(MacroAssembler* masm, ICMissMode force_generic);
|
2011-05-18 13:17:29 +00:00
|
|
|
static void GenerateSlow(MacroAssembler* masm);
|
2011-03-02 04:53:43 +00:00
|
|
|
static void GenerateRuntimeSetProperty(MacroAssembler* masm,
|
|
|
|
StrictModeFlag strict_mode);
|
|
|
|
static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode);
|
2011-06-16 14:12:58 +00:00
|
|
|
static void GenerateNonStrictArguments(MacroAssembler* masm);
|
2011-10-19 12:10:18 +00:00
|
|
|
static void GenerateTransitionElementsSmiToDouble(MacroAssembler* masm);
|
|
|
|
static void GenerateTransitionElementsDoubleToObject(MacroAssembler* masm);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-05-18 13:17:29 +00:00
|
|
|
protected:
|
|
|
|
virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; }
|
|
|
|
|
2013-01-25 10:34:17 +00:00
|
|
|
virtual Handle<Code> ComputeStoreMonomorphic(LookupResult* lookup,
|
|
|
|
StrictModeFlag strict_mode,
|
|
|
|
Handle<JSObject> receiver,
|
|
|
|
Handle<String> name);
|
2013-05-02 15:42:22 +00:00
|
|
|
virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { }
|
2013-01-22 09:48:59 +00:00
|
|
|
|
|
|
|
virtual Handle<Code> megamorphic_stub() {
|
|
|
|
return isolate()->builtins()->KeyedStoreIC_Generic();
|
|
|
|
}
|
|
|
|
virtual Handle<Code> megamorphic_stub_strict() {
|
|
|
|
return isolate()->builtins()->KeyedStoreIC_Generic_Strict();
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-01-23 15:35:43 +00:00
|
|
|
Handle<Code> StoreElementStub(Handle<JSObject> receiver,
|
2013-03-06 21:51:07 +00:00
|
|
|
KeyedAccessStoreMode store_mode,
|
2013-01-23 15:35:43 +00:00
|
|
|
StrictModeFlag strict_mode);
|
|
|
|
|
2013-01-22 09:48:59 +00:00
|
|
|
private:
|
2011-03-02 04:53:43 +00:00
|
|
|
void set_target(Code* code) {
|
|
|
|
// Strict mode must be preserved across IC patching.
|
2012-02-10 12:36:05 +00:00
|
|
|
ASSERT(Code::GetStrictMode(code->extra_ic_state()) ==
|
|
|
|
Code::GetStrictMode(target()->extra_ic_state()));
|
2011-03-02 04:53:43 +00:00
|
|
|
IC::set_target(code);
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// Stub accessors.
|
2013-01-22 09:48:59 +00:00
|
|
|
static Handle<Code> initialize_stub() {
|
|
|
|
return Isolate::Current()->builtins()->KeyedStoreIC_Initialize();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2013-01-22 09:48:59 +00:00
|
|
|
static Handle<Code> initialize_stub_strict() {
|
|
|
|
return Isolate::Current()->builtins()->KeyedStoreIC_Initialize_Strict();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-12-05 21:54:45 +00:00
|
|
|
Handle<Code> generic_stub() const {
|
2011-10-20 13:54:16 +00:00
|
|
|
return isolate()->builtins()->KeyedStoreIC_Generic();
|
2011-03-02 04:53:43 +00:00
|
|
|
}
|
2011-12-05 21:54:45 +00:00
|
|
|
Handle<Code> generic_stub_strict() const {
|
2011-10-20 13:54:16 +00:00
|
|
|
return isolate()->builtins()->KeyedStoreIC_Generic_Strict();
|
|
|
|
}
|
|
|
|
Handle<Code> non_strict_arguments_stub() {
|
|
|
|
return isolate()->builtins()->KeyedStoreIC_NonStrictArguments();
|
2011-06-16 14:12:58 +00:00
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
static void Clear(Address address, Code* target);
|
2009-06-12 11:24:13 +00:00
|
|
|
|
2013-03-06 21:51:07 +00:00
|
|
|
KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver,
|
|
|
|
Handle<Object> key,
|
|
|
|
Handle<Object> value);
|
2013-01-23 15:35:43 +00:00
|
|
|
|
|
|
|
Handle<Map> ComputeTransitionedMap(Handle<JSObject> receiver,
|
2013-03-06 21:51:07 +00:00
|
|
|
KeyedAccessStoreMode store_mode);
|
2013-01-23 15:35:43 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
friend class IC;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-05-24 12:20:16 +00:00
|
|
|
class UnaryOpIC: public IC {
|
2011-04-28 17:49:55 +00:00
|
|
|
public:
|
|
|
|
// sorted: increasingly more unspecific (ignoring UNINITIALIZED)
|
|
|
|
// TODO(svenpanne) Using enums+switch is an antipattern, use a class instead.
|
|
|
|
enum TypeInfo {
|
|
|
|
UNINITIALIZED,
|
|
|
|
SMI,
|
2013-02-28 14:43:57 +00:00
|
|
|
NUMBER,
|
2011-04-28 17:49:55 +00:00
|
|
|
GENERIC
|
|
|
|
};
|
|
|
|
|
2011-05-24 12:20:16 +00:00
|
|
|
explicit UnaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { }
|
2011-04-28 17:49:55 +00:00
|
|
|
|
|
|
|
void patch(Code* code);
|
|
|
|
|
|
|
|
static const char* GetName(TypeInfo type_info);
|
|
|
|
|
|
|
|
static State ToState(TypeInfo type_info);
|
|
|
|
|
|
|
|
static TypeInfo GetTypeInfo(Handle<Object> operand);
|
|
|
|
|
2011-05-18 17:32:36 +00:00
|
|
|
static TypeInfo ComputeNewType(TypeInfo type, TypeInfo previous);
|
2011-04-28 17:49:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Type Recording BinaryOpIC, that records the types of the inputs and outputs.
|
2011-05-24 12:20:16 +00:00
|
|
|
class BinaryOpIC: public IC {
|
2010-12-07 11:31:57 +00:00
|
|
|
public:
|
|
|
|
enum TypeInfo {
|
|
|
|
UNINITIALIZED,
|
|
|
|
SMI,
|
|
|
|
INT32,
|
2013-02-28 14:43:57 +00:00
|
|
|
NUMBER,
|
2011-03-28 16:36:08 +00:00
|
|
|
ODDBALL,
|
2012-11-14 15:59:45 +00:00
|
|
|
STRING, // Only used for addition operation.
|
2010-12-07 11:31:57 +00:00
|
|
|
GENERIC
|
|
|
|
};
|
|
|
|
|
2011-05-24 12:20:16 +00:00
|
|
|
explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { }
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
void patch(Code* code);
|
|
|
|
|
|
|
|
static const char* GetName(TypeInfo type_info);
|
|
|
|
|
|
|
|
static State ToState(TypeInfo type_info);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CompareIC: public IC {
|
|
|
|
public:
|
2013-02-28 14:43:57 +00:00
|
|
|
// The type/state lattice is defined by the following inequations:
|
|
|
|
// UNINITIALIZED < ...
|
|
|
|
// ... < GENERIC
|
|
|
|
// SMI < NUMBER
|
2013-02-28 17:03:34 +00:00
|
|
|
// INTERNALIZED_STRING < STRING
|
2013-02-28 14:43:57 +00:00
|
|
|
// KNOWN_OBJECT < OBJECT
|
2010-12-07 11:31:57 +00:00
|
|
|
enum State {
|
|
|
|
UNINITIALIZED,
|
2012-11-14 15:59:45 +00:00
|
|
|
SMI,
|
2013-02-28 14:43:57 +00:00
|
|
|
NUMBER,
|
2012-11-14 15:59:45 +00:00
|
|
|
STRING,
|
2013-02-28 17:03:34 +00:00
|
|
|
INTERNALIZED_STRING,
|
2013-03-01 13:28:55 +00:00
|
|
|
UNIQUE_NAME, // Symbol or InternalizedString
|
2013-02-28 14:43:57 +00:00
|
|
|
OBJECT, // JSObject
|
|
|
|
KNOWN_OBJECT, // JSObject with specific map (faster check)
|
2010-12-07 11:31:57 +00:00
|
|
|
GENERIC
|
|
|
|
};
|
|
|
|
|
2013-06-12 17:20:37 +00:00
|
|
|
static Handle<Type> StateToType(
|
|
|
|
Isolate* isolate, State state, Handle<Map> map = Handle<Map>());
|
|
|
|
|
2011-03-18 20:35:07 +00:00
|
|
|
CompareIC(Isolate* isolate, Token::Value op)
|
|
|
|
: IC(EXTRA_CALL_FRAME, isolate), op_(op) { }
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
// Update the inline cache for the given operands.
|
|
|
|
void UpdateCaches(Handle<Object> x, Handle<Object> y);
|
|
|
|
|
2012-11-14 15:59:45 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Factory method for getting an uninitialized compare stub.
|
2013-02-27 12:33:24 +00:00
|
|
|
static Handle<Code> GetUninitialized(Isolate* isolate, Token::Value op);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
// Helper function for computing the condition for a compare operation.
|
|
|
|
static Condition ComputeCondition(Token::Value op);
|
|
|
|
|
|
|
|
static const char* GetStateName(State state);
|
|
|
|
|
|
|
|
private:
|
2012-11-14 15:59:45 +00:00
|
|
|
static bool HasInlinedSmiCode(Address address);
|
|
|
|
|
|
|
|
State TargetState(State old_state,
|
|
|
|
State old_left,
|
|
|
|
State old_right,
|
|
|
|
bool has_inlined_smi_code,
|
|
|
|
Handle<Object> x,
|
|
|
|
Handle<Object> y);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
bool strict() const { return op_ == Token::EQ_STRICT; }
|
|
|
|
Condition GetCondition() const { return ComputeCondition(op_); }
|
|
|
|
|
2012-05-03 10:54:17 +00:00
|
|
|
static Code* GetRawUninitialized(Token::Value op);
|
|
|
|
|
|
|
|
static void Clear(Address address, Code* target);
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
Token::Value op_;
|
2012-05-03 10:54:17 +00:00
|
|
|
|
|
|
|
friend class IC;
|
2010-12-07 11:31:57 +00:00
|
|
|
};
|
|
|
|
|
2011-07-21 13:51:04 +00:00
|
|
|
|
2013-04-24 11:32:17 +00:00
|
|
|
class CompareNilIC: public IC {
|
|
|
|
public:
|
|
|
|
explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {}
|
|
|
|
|
|
|
|
MUST_USE_RESULT MaybeObject* CompareNil(Handle<Object> object);
|
|
|
|
|
|
|
|
static Handle<Code> GetUninitialized();
|
|
|
|
|
|
|
|
static void Clear(Address address, Code* target);
|
|
|
|
|
2013-06-10 15:47:23 +00:00
|
|
|
static MUST_USE_RESULT MaybeObject* DoCompareNilSlow(NilValue nil,
|
2013-04-24 11:32:17 +00:00
|
|
|
Handle<Object> object);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-21 13:51:04 +00:00
|
|
|
class ToBooleanIC: public IC {
|
|
|
|
public:
|
2013-05-29 14:49:28 +00:00
|
|
|
explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { }
|
2011-07-21 13:51:04 +00:00
|
|
|
|
2013-05-29 14:49:28 +00:00
|
|
|
MaybeObject* ToBoolean(Handle<Object> object, Code::ExtraICState state);
|
2011-07-21 13:51:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-05-24 12:20:16 +00:00
|
|
|
// Helper for BinaryOpIC and CompareIC.
|
2012-05-03 10:54:17 +00:00
|
|
|
enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK };
|
|
|
|
void PatchInlinedSmiCode(Address address, InlinedSmiCheck check);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2013-01-30 14:25:34 +00:00
|
|
|
DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure);
|
2013-03-20 10:37:13 +00:00
|
|
|
DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure);
|
2013-04-24 11:32:17 +00:00
|
|
|
DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss);
|
2013-05-29 14:49:28 +00:00
|
|
|
DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss);
|
2013-04-24 11:32:17 +00:00
|
|
|
|
2013-01-07 10:06:11 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_IC_H_
|