vendor/v8/src/stub-cache.h in mustang-0.0.1 vs vendor/v8/src/stub-cache.h in mustang-0.1.0
- old
+ new
@@ -26,10 +26,11 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_STUB_CACHE_H_
#define V8_STUB_CACHE_H_
+#include "arguments.h"
#include "macro-assembler.h"
#include "zone-inl.h"
namespace v8 {
namespace internal {
@@ -41,183 +42,193 @@
// The design of the table uses the inline cache stubs used for
// mono-morphic calls. The beauty of this, we do not have to
// invalidate the cache whenever a prototype map is changed. The stub
// validates the map chain as in the mono-morphic case.
-class SCTableReference;
+class StubCache;
+class SCTableReference {
+ public:
+ Address address() const { return address_; }
-class StubCache : public AllStatic {
+ private:
+ explicit SCTableReference(Address address) : address_(address) {}
+
+ Address address_;
+
+ friend class StubCache;
+};
+
+
+class StubCache {
public:
struct Entry {
String* key;
Code* value;
};
+ void Initialize(bool create_heap_objects);
- static void Initialize(bool create_heap_objects);
// Computes the right stub matching. Inserts the result in the
// cache before returning. This might compile a stub if needed.
- MUST_USE_RESULT static MaybeObject* ComputeLoadNonexistent(
+ MUST_USE_RESULT MaybeObject* ComputeLoadNonexistent(
String* name,
JSObject* receiver);
- MUST_USE_RESULT static MaybeObject* ComputeLoadField(String* name,
- JSObject* receiver,
- JSObject* holder,
- int field_index);
+ MUST_USE_RESULT MaybeObject* ComputeLoadField(String* name,
+ JSObject* receiver,
+ JSObject* holder,
+ int field_index);
- MUST_USE_RESULT static MaybeObject* ComputeLoadCallback(
+ MUST_USE_RESULT MaybeObject* ComputeLoadCallback(
String* name,
JSObject* receiver,
JSObject* holder,
AccessorInfo* callback);
- MUST_USE_RESULT static MaybeObject* ComputeLoadConstant(String* name,
- JSObject* receiver,
- JSObject* holder,
- Object* value);
+ MUST_USE_RESULT MaybeObject* ComputeLoadConstant(String* name,
+ JSObject* receiver,
+ JSObject* holder,
+ Object* value);
- MUST_USE_RESULT static MaybeObject* ComputeLoadInterceptor(
+ MUST_USE_RESULT MaybeObject* ComputeLoadInterceptor(
String* name,
JSObject* receiver,
JSObject* holder);
- MUST_USE_RESULT static MaybeObject* ComputeLoadNormal();
+ MUST_USE_RESULT MaybeObject* ComputeLoadNormal();
- MUST_USE_RESULT static MaybeObject* ComputeLoadGlobal(
+ MUST_USE_RESULT MaybeObject* ComputeLoadGlobal(
String* name,
JSObject* receiver,
GlobalObject* holder,
JSGlobalPropertyCell* cell,
bool is_dont_delete);
// ---
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadField(String* name,
- JSObject* receiver,
- JSObject* holder,
- int field_index);
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadField(String* name,
+ JSObject* receiver,
+ JSObject* holder,
+ int field_index);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadCallback(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadCallback(
String* name,
JSObject* receiver,
JSObject* holder,
AccessorInfo* callback);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadConstant(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadConstant(
String* name,
JSObject* receiver,
JSObject* holder,
Object* value);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadInterceptor(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadInterceptor(
String* name,
JSObject* receiver,
JSObject* holder);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadArrayLength(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadArrayLength(
String* name,
JSArray* receiver);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadStringLength(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadStringLength(
String* name,
String* receiver);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadFunctionPrototype(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadFunctionPrototype(
String* name,
JSFunction* receiver);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadSpecialized(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadSpecialized(
JSObject* receiver);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadPixelArray(
- JSObject* receiver);
-
// ---
- MUST_USE_RESULT static MaybeObject* ComputeStoreField(
+ MUST_USE_RESULT MaybeObject* ComputeStoreField(
String* name,
JSObject* receiver,
int field_index,
Map* transition,
- Code::ExtraICState extra_ic_state);
+ StrictModeFlag strict_mode);
- MUST_USE_RESULT static MaybeObject* ComputeStoreNormal(
- Code::ExtraICState extra_ic_state);
+ MUST_USE_RESULT MaybeObject* ComputeStoreNormal(
+ StrictModeFlag strict_mode);
- MUST_USE_RESULT static MaybeObject* ComputeStoreGlobal(
+ MUST_USE_RESULT MaybeObject* ComputeStoreGlobal(
String* name,
GlobalObject* receiver,
JSGlobalPropertyCell* cell,
- Code::ExtraICState extra_ic_state);
+ StrictModeFlag strict_mode);
- MUST_USE_RESULT static MaybeObject* ComputeStoreCallback(
+ MUST_USE_RESULT MaybeObject* ComputeStoreCallback(
String* name,
JSObject* receiver,
AccessorInfo* callback,
- Code::ExtraICState extra_ic_state);
+ StrictModeFlag strict_mode);
- MUST_USE_RESULT static MaybeObject* ComputeStoreInterceptor(
+ MUST_USE_RESULT MaybeObject* ComputeStoreInterceptor(
String* name,
JSObject* receiver,
- Code::ExtraICState extra_ic_state);
+ StrictModeFlag strict_mode);
// ---
- MUST_USE_RESULT static MaybeObject* ComputeKeyedStoreField(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedStoreField(
String* name,
JSObject* receiver,
int field_index,
- Map* transition = NULL);
+ Map* transition,
+ StrictModeFlag strict_mode);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedStoreSpecialized(
- JSObject* receiver);
+ MUST_USE_RESULT MaybeObject* ComputeKeyedStoreSpecialized(
+ JSObject* receiver,
+ StrictModeFlag strict_mode);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedStorePixelArray(
- JSObject* receiver);
- MUST_USE_RESULT static MaybeObject* ComputeKeyedLoadOrStoreExternalArray(
+ MUST_USE_RESULT MaybeObject* ComputeKeyedLoadOrStoreExternalArray(
JSObject* receiver,
- bool is_store);
+ bool is_store,
+ StrictModeFlag strict_mode);
// ---
- MUST_USE_RESULT static MaybeObject* ComputeCallField(int argc,
- InLoopFlag in_loop,
- Code::Kind,
- String* name,
- Object* object,
- JSObject* holder,
- int index);
+ MUST_USE_RESULT MaybeObject* ComputeCallField(int argc,
+ InLoopFlag in_loop,
+ Code::Kind,
+ String* name,
+ Object* object,
+ JSObject* holder,
+ int index);
- MUST_USE_RESULT static MaybeObject* ComputeCallConstant(
+ MUST_USE_RESULT MaybeObject* ComputeCallConstant(
int argc,
InLoopFlag in_loop,
Code::Kind,
Code::ExtraICState extra_ic_state,
String* name,
Object* object,
JSObject* holder,
JSFunction* function);
- MUST_USE_RESULT static MaybeObject* ComputeCallNormal(int argc,
- InLoopFlag in_loop,
- Code::Kind,
- String* name,
- JSObject* receiver);
+ MUST_USE_RESULT MaybeObject* ComputeCallNormal(int argc,
+ InLoopFlag in_loop,
+ Code::Kind,
+ String* name,
+ JSObject* receiver);
- MUST_USE_RESULT static MaybeObject* ComputeCallInterceptor(int argc,
- Code::Kind,
- String* name,
- Object* object,
- JSObject* holder);
+ MUST_USE_RESULT MaybeObject* ComputeCallInterceptor(int argc,
+ Code::Kind,
+ String* name,
+ Object* object,
+ JSObject* holder);
- MUST_USE_RESULT static MaybeObject* ComputeCallGlobal(
+ MUST_USE_RESULT MaybeObject* ComputeCallGlobal(
int argc,
InLoopFlag in_loop,
Code::Kind,
String* name,
JSObject* receiver,
@@ -225,84 +236,109 @@
JSGlobalPropertyCell* cell,
JSFunction* function);
// ---
- MUST_USE_RESULT static MaybeObject* ComputeCallInitialize(int argc,
- InLoopFlag in_loop,
- Code::Kind kind);
+ MUST_USE_RESULT MaybeObject* ComputeCallInitialize(int argc,
+ InLoopFlag in_loop,
+ Code::Kind kind);
- static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop);
+ Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop);
- static Handle<Code> ComputeKeyedCallInitialize(int argc, InLoopFlag in_loop);
+ Handle<Code> ComputeKeyedCallInitialize(int argc, InLoopFlag in_loop);
- MUST_USE_RESULT static MaybeObject* ComputeCallPreMonomorphic(
+ MUST_USE_RESULT MaybeObject* ComputeCallPreMonomorphic(
int argc,
InLoopFlag in_loop,
Code::Kind kind);
- MUST_USE_RESULT static MaybeObject* ComputeCallNormal(int argc,
- InLoopFlag in_loop,
- Code::Kind kind);
+ MUST_USE_RESULT MaybeObject* ComputeCallNormal(int argc,
+ InLoopFlag in_loop,
+ Code::Kind kind);
- MUST_USE_RESULT static MaybeObject* ComputeCallMegamorphic(int argc,
- InLoopFlag in_loop,
- Code::Kind kind);
-
- MUST_USE_RESULT static MaybeObject* ComputeCallMiss(int argc,
+ MUST_USE_RESULT MaybeObject* ComputeCallMegamorphic(int argc,
+ InLoopFlag in_loop,
Code::Kind kind);
+ MUST_USE_RESULT MaybeObject* ComputeCallMiss(int argc, Code::Kind kind);
+
// Finds the Code object stored in the Heap::non_monomorphic_cache().
- MUST_USE_RESULT static Code* FindCallInitialize(int argc,
- InLoopFlag in_loop,
- Code::Kind kind);
+ MUST_USE_RESULT Code* FindCallInitialize(int argc,
+ InLoopFlag in_loop,
+ Code::Kind kind);
#ifdef ENABLE_DEBUGGER_SUPPORT
- MUST_USE_RESULT static MaybeObject* ComputeCallDebugBreak(int argc,
- Code::Kind kind);
+ MUST_USE_RESULT MaybeObject* ComputeCallDebugBreak(int argc, Code::Kind kind);
- MUST_USE_RESULT static MaybeObject* ComputeCallDebugPrepareStepIn(
- int argc,
- Code::Kind kind);
+ MUST_USE_RESULT MaybeObject* ComputeCallDebugPrepareStepIn(int argc,
+ Code::Kind kind);
#endif
// Update cache for entry hash(name, map).
- static Code* Set(String* name, Map* map, Code* code);
+ Code* Set(String* name, Map* map, Code* code);
// Clear the lookup table (@ mark compact collection).
- static void Clear();
+ void Clear();
// Collect all maps that match the name and flags.
- static void CollectMatchingMaps(ZoneMapList* types,
- String* name,
- Code::Flags flags);
+ void CollectMatchingMaps(ZoneMapList* types,
+ String* name,
+ Code::Flags flags);
// Generate code for probing the stub cache table.
// Arguments extra and extra2 may be used to pass additional scratch
// registers. Set to no_reg if not needed.
- static void GenerateProbe(MacroAssembler* masm,
- Code::Flags flags,
- Register receiver,
- Register name,
- Register scratch,
- Register extra,
- Register extra2 = no_reg);
+ void GenerateProbe(MacroAssembler* masm,
+ Code::Flags flags,
+ Register receiver,
+ Register name,
+ Register scratch,
+ Register extra,
+ Register extra2 = no_reg);
enum Table {
kPrimary,
kSecondary
};
+
+ SCTableReference key_reference(StubCache::Table table) {
+ return SCTableReference(
+ reinterpret_cast<Address>(&first_entry(table)->key));
+ }
+
+
+ SCTableReference value_reference(StubCache::Table table) {
+ return SCTableReference(
+ reinterpret_cast<Address>(&first_entry(table)->value));
+ }
+
+
+ StubCache::Entry* first_entry(StubCache::Table table) {
+ switch (table) {
+ case StubCache::kPrimary: return StubCache::primary_;
+ case StubCache::kSecondary: return StubCache::secondary_;
+ }
+ UNREACHABLE();
+ return NULL;
+ }
+
+ Isolate* isolate() { return isolate_; }
+ Heap* heap() { return isolate()->heap(); }
+
private:
+ explicit StubCache(Isolate* isolate);
+
+ friend class Isolate;
friend class SCTableReference;
static const int kPrimaryTableSize = 2048;
static const int kSecondaryTableSize = 512;
- static Entry primary_[];
- static Entry secondary_[];
+ Entry primary_[kPrimaryTableSize];
+ Entry secondary_[kSecondaryTableSize];
// Computes the hashed offsets for primary and secondary caches.
- static int PrimaryOffset(String* name, Code::Flags flags, Map* map) {
+ RLYSTC int PrimaryOffset(String* name, Code::Flags flags, Map* map) {
// This works well because the heap object tag size and the hash
// shift are equal. Shifting down the length field to get the
// hash code would effectively throw away two bits of the hash
// code.
ASSERT(kHeapObjectTagSize == String::kHashShift);
@@ -321,11 +357,11 @@
// Base the offset on a simple combination of name, flags, and map.
uint32_t key = (map_low32bits + field) ^ iflags;
return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize);
}
- static int SecondaryOffset(String* name, Code::Flags flags, int seed) {
+ RLYSTC int SecondaryOffset(String* name, Code::Flags flags, int seed) {
// Use the seed from the primary cache in the secondary cache.
uint32_t string_low32bits =
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name));
// We always set the in_loop bit to zero when generating the lookup code
// so do it here too so the hash codes match.
@@ -338,69 +374,44 @@
// Compute the entry for a given offset in exactly the same way as
// we do in generated code. We generate an hash code that already
// ends in String::kHashShift 0s. Then we shift it so it is a multiple
// of sizeof(Entry). This makes it easier to avoid making mistakes
// in the hashed offset computations.
- static Entry* entry(Entry* table, int offset) {
+ RLYSTC Entry* entry(Entry* table, int offset) {
const int shift_amount = kPointerSizeLog2 + 1 - String::kHashShift;
return reinterpret_cast<Entry*>(
reinterpret_cast<Address>(table) + (offset << shift_amount));
}
-};
+ Isolate* isolate_;
-class SCTableReference {
- public:
- static SCTableReference keyReference(StubCache::Table table) {
- return SCTableReference(
- reinterpret_cast<Address>(&first_entry(table)->key));
- }
-
-
- static SCTableReference valueReference(StubCache::Table table) {
- return SCTableReference(
- reinterpret_cast<Address>(&first_entry(table)->value));
- }
-
- Address address() const { return address_; }
-
- private:
- explicit SCTableReference(Address address) : address_(address) {}
-
- static StubCache::Entry* first_entry(StubCache::Table table) {
- switch (table) {
- case StubCache::kPrimary: return StubCache::primary_;
- case StubCache::kSecondary: return StubCache::secondary_;
- }
- UNREACHABLE();
- return NULL;
- }
-
- Address address_;
+ DISALLOW_COPY_AND_ASSIGN(StubCache);
};
+
// ------------------------------------------------------------------------
// Support functions for IC stubs for callbacks.
-MaybeObject* LoadCallbackProperty(Arguments args);
-MaybeObject* StoreCallbackProperty(Arguments args);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadCallbackProperty);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreCallbackProperty);
// Support functions for IC stubs for interceptors.
-MaybeObject* LoadPropertyWithInterceptorOnly(Arguments args);
-MaybeObject* LoadPropertyWithInterceptorForLoad(Arguments args);
-MaybeObject* LoadPropertyWithInterceptorForCall(Arguments args);
-MaybeObject* StoreInterceptorProperty(Arguments args);
-MaybeObject* CallInterceptorProperty(Arguments args);
-MaybeObject* KeyedLoadPropertyWithInterceptor(Arguments args);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForLoad);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorForCall);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreInterceptorProperty);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, CallInterceptorProperty);
+DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadPropertyWithInterceptor);
// The stub compiler compiles stubs for the stub cache.
class StubCompiler BASE_EMBEDDED {
public:
- StubCompiler() : scope_(), masm_(NULL, 256), failure_(NULL) { }
+ StubCompiler()
+ : scope_(), masm_(Isolate::Current(), NULL, 256), failure_(NULL) { }
MUST_USE_RESULT MaybeObject* CompileCallInitialize(Code::Flags flags);
MUST_USE_RESULT MaybeObject* CompileCallPreMonomorphic(Code::Flags flags);
MUST_USE_RESULT MaybeObject* CompileCallNormal(Code::Flags flags);
MUST_USE_RESULT MaybeObject* CompileCallMegamorphic(Code::Flags flags);
@@ -548,10 +559,14 @@
static void LookupPostInterceptor(JSObject* holder,
String* name,
LookupResult* lookup);
+ Isolate* isolate() { return scope_.isolate(); }
+ Heap* heap() { return isolate()->heap(); }
+ Factory* factory() { return isolate()->factory(); }
+
private:
HandleScope scope_;
MacroAssembler masm_;
Failure* failure_;
};
@@ -617,21 +632,20 @@
MUST_USE_RESULT MaybeObject* CompileLoadArrayLength(String* name);
MUST_USE_RESULT MaybeObject* CompileLoadStringLength(String* name);
MUST_USE_RESULT MaybeObject* CompileLoadFunctionPrototype(String* name);
MUST_USE_RESULT MaybeObject* CompileLoadSpecialized(JSObject* receiver);
- MUST_USE_RESULT MaybeObject* CompileLoadPixelArray(JSObject* receiver);
private:
MaybeObject* GetCode(PropertyType type, String* name);
};
class StoreStubCompiler: public StubCompiler {
public:
- explicit StoreStubCompiler(Code::ExtraICState extra_ic_state)
- : extra_ic_state_(extra_ic_state) { }
+ explicit StoreStubCompiler(StrictModeFlag strict_mode)
+ : strict_mode_(strict_mode) { }
MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
int index,
Map* transition,
String* name);
@@ -647,27 +661,30 @@
private:
MaybeObject* GetCode(PropertyType type, String* name);
- Code::ExtraICState extra_ic_state_;
+ StrictModeFlag strict_mode_;
};
class KeyedStoreStubCompiler: public StubCompiler {
public:
+ explicit KeyedStoreStubCompiler(StrictModeFlag strict_mode)
+ : strict_mode_(strict_mode) { }
+
MUST_USE_RESULT MaybeObject* CompileStoreField(JSObject* object,
int index,
Map* transition,
String* name);
MUST_USE_RESULT MaybeObject* CompileStoreSpecialized(JSObject* receiver);
- MUST_USE_RESULT MaybeObject* CompileStorePixelArray(JSObject* receiver);
-
private:
MaybeObject* GetCode(PropertyType type, String* name);
+
+ StrictModeFlag strict_mode_;
};
// Subset of FUNCTIONS_WITH_ID_LIST with custom constant/global call
// IC stubs.
@@ -679,10 +696,12 @@
V(StringFromCharCode) \
V(MathFloor) \
V(MathAbs)
+class CallOptimization;
+
class CallStubCompiler: public StubCompiler {
public:
CallStubCompiler(int argc,
InLoopFlag in_loop,
Code::Kind kind,
@@ -705,18 +724,17 @@
GlobalObject* holder,
JSGlobalPropertyCell* cell,
JSFunction* function,
String* name);
- static bool HasCustomCallGenerator(BuiltinFunctionId id);
+ static bool HasCustomCallGenerator(JSFunction* function);
private:
// Compiles a custom call constant/global IC. For constant calls
// cell is NULL. Returns undefined if there is no custom call code
// for the given function or it can't be generated.
- MUST_USE_RESULT MaybeObject* CompileCustomCall(BuiltinFunctionId id,
- Object* object,
+ MUST_USE_RESULT MaybeObject* CompileCustomCall(Object* object,
JSObject* holder,
JSGlobalPropertyCell* cell,
JSFunction* function,
String* name);
@@ -727,10 +745,18 @@
JSFunction* function, \
String* fname);
CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR)
#undef DECLARE_CALL_GENERATOR
+ MUST_USE_RESULT MaybeObject* CompileFastApiCall(
+ const CallOptimization& optimization,
+ Object* object,
+ JSObject* holder,
+ JSGlobalPropertyCell* cell,
+ JSFunction* function,
+ String* name);
+
const ParameterCount arguments_;
const InLoopFlag in_loop_;
const Code::Kind kind_;
const Code::ExtraICState extra_ic_state_;
const InlineCacheHolderFlag cache_holder_;
@@ -824,13 +850,13 @@
class ExternalArrayStubCompiler: public StubCompiler {
public:
explicit ExternalArrayStubCompiler() {}
MUST_USE_RESULT MaybeObject* CompileKeyedLoadStub(
- ExternalArrayType array_type, Code::Flags flags);
+ JSObject* receiver, ExternalArrayType array_type, Code::Flags flags);
MUST_USE_RESULT MaybeObject* CompileKeyedStoreStub(
- ExternalArrayType array_type, Code::Flags flags);
+ JSObject* receiver, ExternalArrayType array_type, Code::Flags flags);
private:
MaybeObject* GetCode(Code::Flags flags);
};