From: yangguo@chromium.org Date: Wed, 16 Jul 2014 09:55:34 +0000 (+0000) Subject: Store builtin index on the builtin code object. X-Git-Tag: upstream/4.7.83~8199 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a211a52a6eb949b6c6df07a8f9860b20c3e16ef3;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/builtins.cc b/src/builtins.cc index 925e8a9..ddaea59 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -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()); diff --git a/src/objects-inl.h b/src/objects-inl.h index dc235df..b81921e 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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( diff --git a/src/objects.h b/src/objects.h index 4dfed65..74b4264 100644 --- a/src/objects.h +++ b/src/objects.h @@ -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(); diff --git a/src/serialize.cc b/src/serialize.cc index 6937e5b..c35464e 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -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(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"); }