Commit f1fe1f95 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Tag normal as handlers, and make code handler-specific.

BUG=
R=ulan@chromium.org

Review URL: https://chromiumcodereview.appspot.com/25049003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17013 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0f715540
......@@ -1655,8 +1655,19 @@ void Builtins::InitBuiltinFunctionTable() {
functions->extra_args = NO_EXTRA_ARGUMENTS; \
++functions;
#define DEF_FUNCTION_PTR_H(aname, kind, extra) \
functions->generator = FUNCTION_ADDR(Generate_##aname); \
functions->c_code = NULL; \
functions->s_name = #aname; \
functions->name = k##aname; \
functions->flags = Code::ComputeFlags( \
Code::HANDLER, MONOMORPHIC, extra, Code::NORMAL, Code::kind); \
functions->extra_args = NO_EXTRA_ARGUMENTS; \
++functions;
BUILTIN_LIST_C(DEF_FUNCTION_PTR_C)
BUILTIN_LIST_A(DEF_FUNCTION_PTR_A)
BUILTIN_LIST_H(DEF_FUNCTION_PTR_H)
BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A)
#undef DEF_FUNCTION_PTR_C
......@@ -1781,8 +1792,15 @@ Handle<Code> Builtins::name() { \
reinterpret_cast<Code**>(builtin_address(k##name)); \
return Handle<Code>(code_address); \
}
#define DEFINE_BUILTIN_ACCESSOR_H(name, kind, extra) \
Handle<Code> Builtins::name() { \
Code** code_address = \
reinterpret_cast<Code**>(builtin_address(k##name)); \
return Handle<Code>(code_address); \
}
BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
#undef DEFINE_BUILTIN_ACCESSOR_C
#undef DEFINE_BUILTIN_ACCESSOR_A
......
......@@ -115,8 +115,6 @@ enum BuiltinExtraArguments {
Code::kNoExtraICState) \
V(KeyedLoadIC_MissForceGeneric, BUILTIN, UNINITIALIZED, \
Code::kNoExtraICState) \
V(KeyedLoadIC_Slow, HANDLER, MONOMORPHIC, \
Code::kNoExtraICState) \
V(StoreIC_Miss, BUILTIN, UNINITIALIZED, \
Code::kNoExtraICState) \
V(StoreIC_Slow, BUILTIN, UNINITIALIZED, \
......@@ -131,13 +129,9 @@ enum BuiltinExtraArguments {
Code::kNoExtraICState) \
V(LoadIC_PreMonomorphic, LOAD_IC, PREMONOMORPHIC, \
Code::kNoExtraICState) \
V(LoadIC_Normal, LOAD_IC, MONOMORPHIC, \
Code::kNoExtraICState) \
V(LoadIC_Megamorphic, LOAD_IC, MEGAMORPHIC, \
Code::kNoExtraICState) \
V(LoadIC_Getter_ForDeopt, LOAD_IC, MONOMORPHIC, \
Code::kNoExtraICState) \
V(LoadIC_Slow, HANDLER, MONOMORPHIC, \
Code::kNoExtraICState) \
\
V(KeyedLoadIC_Initialize, KEYED_LOAD_IC, UNINITIALIZED, \
......@@ -157,8 +151,6 @@ enum BuiltinExtraArguments {
Code::kNoExtraICState) \
V(StoreIC_PreMonomorphic, STORE_IC, PREMONOMORPHIC, \
Code::kNoExtraICState) \
V(StoreIC_Normal, STORE_IC, MONOMORPHIC, \
Code::kNoExtraICState) \
V(StoreIC_Megamorphic, STORE_IC, MEGAMORPHIC, \
Code::kNoExtraICState) \
V(StoreIC_Generic, STORE_IC, GENERIC, \
......@@ -171,8 +163,6 @@ enum BuiltinExtraArguments {
kStrictMode) \
V(StoreIC_PreMonomorphic_Strict, STORE_IC, PREMONOMORPHIC, \
kStrictMode) \
V(StoreIC_Normal_Strict, STORE_IC, MONOMORPHIC, \
kStrictMode) \
V(StoreIC_Megamorphic_Strict, STORE_IC, MEGAMORPHIC, \
kStrictMode) \
V(StoreIC_GlobalProxy_Strict, STORE_IC, GENERIC, \
......@@ -220,6 +210,14 @@ enum BuiltinExtraArguments {
Code::kNoExtraICState) \
CODE_AGE_LIST_WITH_ARG(DECLARE_CODE_AGE_BUILTIN, V)
// Define list of builtin handlers implemented in assembly.
#define BUILTIN_LIST_H(V) \
V(LoadIC_Slow, LOAD_IC, Code::kNoExtraICState) \
V(KeyedLoadIC_Slow, KEYED_LOAD_IC, Code::kNoExtraICState) \
V(LoadIC_Normal, LOAD_IC, Code::kNoExtraICState) \
V(StoreIC_Normal, STORE_IC, Code::kNoExtraICState) \
V(StoreIC_Normal_Strict, STORE_IC, kStrictMode)
#ifdef ENABLE_DEBUGGER_SUPPORT
// Define list of builtins used by the debugger implemented in assembly.
#define BUILTIN_LIST_DEBUG_A(V) \
......@@ -307,8 +305,10 @@ class Builtins {
enum Name {
#define DEF_ENUM_C(name, ignore) k##name,
#define DEF_ENUM_A(name, kind, state, extra) k##name,
#define DEF_ENUM_H(name, kind, extra) k##name,
BUILTIN_LIST_C(DEF_ENUM_C)
BUILTIN_LIST_A(DEF_ENUM_A)
BUILTIN_LIST_H(DEF_ENUM_H)
BUILTIN_LIST_DEBUG_A(DEF_ENUM_A)
#undef DEF_ENUM_C
#undef DEF_ENUM_A
......@@ -332,8 +332,10 @@ class Builtins {
#define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name();
#define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \
Handle<Code> name();
#define DECLARE_BUILTIN_ACCESSOR_H(name, kind, extra) Handle<Code> name();
BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C)
BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A)
BUILTIN_LIST_H(DECLARE_BUILTIN_ACCESSOR_H)
BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A)
#undef DECLARE_BUILTIN_ACCESSOR_C
#undef DECLARE_BUILTIN_ACCESSOR_A
......
......@@ -217,12 +217,9 @@ static bool TryRemoveInvalidPrototypeDependentStub(Code* target,
int index = map->IndexInCodeCache(name, target);
if (index >= 0) {
map->RemoveFromCodeCache(String::cast(name), target, index);
// For loads and stores, handlers are stored in addition to the ICs on the
// map. Remove those, too.
if ((target->is_load_stub() || target->is_keyed_load_stub() ||
target->is_store_stub() || target->is_keyed_store_stub()) &&
target->type() != Code::NORMAL) {
Code* handler = target->FindFirstCode();
// Handlers are stored in addition to the ICs on the map. Remove those, too.
Code* handler = target->FindFirstHandler();
if (handler != NULL) {
index = map->IndexInCodeCache(name, handler);
if (index >= 0) {
map->RemoveFromCodeCache(String::cast(name), handler, index);
......@@ -1000,10 +997,6 @@ bool IC::UpdatePolymorphicIC(State state,
Handle<Code> code,
StrictModeFlag strict_mode) {
if (code->kind() != Code::HANDLER) return false;
if (target()->ic_state() == MONOMORPHIC &&
target()->type() == Code::NORMAL) {
return false;
}
MapHandleList receiver_maps;
CodeHandleList handlers;
......@@ -1038,7 +1031,10 @@ bool IC::UpdatePolymorphicIC(State state,
if (number_of_maps == 0 && target()->ic_state() != UNINITIALIZED) {
return false;
}
target()->FindAllCode(&handlers, receiver_maps.length());
if (!target()->FindHandlers(&handlers, receiver_maps.length())) {
return false;
}
}
number_of_valid_maps++;
......@@ -1126,7 +1122,7 @@ void IC::CopyICToMegamorphicCache(Handle<String> name) {
{
DisallowHeapAllocation no_gc;
target()->FindAllMaps(&receiver_maps);
target()->FindAllCode(&handlers, receiver_maps.length());
if (!target()->FindHandlers(&handlers, receiver_maps.length())) return;
}
for (int i = 0; i < receiver_maps.length(); i++) {
UpdateMegamorphicCache(*receiver_maps.at(i), *name, *handlers.at(i));
......@@ -1170,7 +1166,7 @@ void IC::PatchCache(State state,
bool is_same_handler = false;
{
DisallowHeapAllocation no_allocation;
Code* old_handler = target()->FindFirstCode();
Code* old_handler = target()->FindFirstHandler();
is_same_handler = old_handler == *code;
}
if (is_same_handler
......@@ -1182,9 +1178,7 @@ void IC::PatchCache(State state,
break;
}
if (target()->type() != Code::NORMAL) {
CopyICToMegamorphicCache(name);
}
CopyICToMegamorphicCache(name);
}
UpdateMegamorphicCache(receiver->map(), *name, *code);
......
......@@ -10363,31 +10363,35 @@ void Code::ReplaceFirstMap(Map* replace_with) {
}
Code* Code::FindFirstCode() {
Code* Code::FindFirstHandler() {
ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
return Code::GetCodeFromTargetAddress(info->target_address());
Code* code = Code::GetCodeFromTargetAddress(info->target_address());
if (code->kind() == Code::HANDLER) return code;
}
return NULL;
}
void Code::FindAllCode(CodeHandleList* code_list, int length) {
bool Code::FindHandlers(CodeHandleList* code_list, int length) {
ASSERT(is_inline_cache_stub());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET);
int i = 0;
for (RelocIterator it(this, mask); !it.done(); it.next()) {
if (i++ == length) return;
if (i == length) return true;
RelocInfo* info = it.rinfo();
Code* code = Code::GetCodeFromTargetAddress(info->target_address());
ASSERT(code->kind() == Code::HANDLER);
// IC stubs with handlers never contain non-handler code objects before
// handler targets.
if (code->kind() != Code::HANDLER) break;
code_list->Add(Handle<Code>(code));
i++;
}
UNREACHABLE();
return i == length;
}
......
......@@ -4998,9 +4998,12 @@ class Code: public HeapObject {
void FindAllMaps(MapHandleList* maps);
void ReplaceFirstMap(Map* replace);
// Find the first code in an IC stub.
Code* FindFirstCode();
void FindAllCode(CodeHandleList* code_list, int length);
// Find the first handler in an IC stub.
Code* FindFirstHandler();
// Find |length| handlers and put them into |code_list|. Returns false if not
// enough handlers can be found.
MUST_USE_RESULT bool FindHandlers(CodeHandleList* code_list, int length);
// Find the first name in an IC stub.
Name* FindFirstName();
......
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