Commit a211a52a authored by yangguo@chromium.org's avatar yangguo@chromium.org

Store builtin index on the builtin code object.

R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/395823002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22429 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ba37e4f9
......@@ -1638,6 +1638,7 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
PROFILE(isolate,
CodeCreateEvent(Logger::BUILTIN_TAG, *code, functions[i].s_name));
builtins_[i] = *code;
if (code->kind() == Code::BUILTIN) code->set_builtin_index(i);
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_builtin_code) {
CodeTracer::Scope trace_scope(isolate->GetCodeTracer());
......
......@@ -4800,6 +4800,18 @@ void Code::set_profiler_ticks(int ticks) {
}
int Code::builtin_index() {
ASSERT_EQ(BUILTIN, kind());
return READ_INT32_FIELD(this, kKindSpecificFlags1Offset);
}
void Code::set_builtin_index(int index) {
ASSERT_EQ(BUILTIN, kind());
WRITE_INT32_FIELD(this, kKindSpecificFlags1Offset, index);
}
unsigned Code::stack_slots() {
ASSERT(is_crankshafted());
return StackSlotsField::decode(
......
......@@ -5608,6 +5608,10 @@ class Code: public HeapObject {
inline int profiler_ticks();
inline void set_profiler_ticks(int ticks);
// [builtin_index]: For BUILTIN kind, tells which builtin index it has.
inline int builtin_index();
inline void set_builtin_index(int id);
// [stack_slots]: For kind OPTIMIZED_FUNCTION, the number of stack slots
// reserved in the code prologue.
inline unsigned stack_slots();
......
......@@ -1938,6 +1938,7 @@ void CodeSerializer::SerializeObject(Object* o, HowToCode how_to_code,
SerializeBuiltin(code_object, how_to_code, where_to_point, skip);
return;
}
// TODO(yangguo) figure out whether other code kinds can be handled smarter.
}
if (heap_object == source_) {
......@@ -1965,15 +1966,11 @@ void CodeSerializer::SerializeBuiltin(Code* builtin, HowToCode how_to_code,
ASSERT((how_to_code == kPlain && where_to_point == kStartOfObject) ||
(how_to_code == kFromCode && where_to_point == kInnerPointer));
int id = 0;
do { // Look for existing builtins in the list.
Code* b = isolate()->builtins()->builtin(static_cast<Builtins::Name>(id));
if (builtin == b) break;
} while (++id < Builtins::builtin_count);
ASSERT(id < Builtins::builtin_count); // We must have found a one.
int builtin_index = builtin->builtin_index();
ASSERT_LT(builtin_index, Builtins::builtin_count);
ASSERT_LE(0, builtin_index);
sink_->Put(kBuiltin + how_to_code + where_to_point, "Builtin");
sink_->PutInt(id, "builtin_index");
sink_->PutInt(builtin_index, "builtin_index");
}
......
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