Reviewers: mvstanton,
Description:
Store builtin index on the builtin code object.
[email protected]
Please review this at https://codereview.chromium.org/395823002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+22, -8 lines):
M src/builtins.cc
M src/objects.h
M src/objects-inl.h
M src/serialize.cc
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index
925e8a97b8029b4713adc5abc4cc15c402dadf51..ddaea59abf991f1ad1e5e95f7fe0aaf039e0894e
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());
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
b750b71a88b75ba5395c4913b7a95c4a5cd04416..192473c86e099f741f509621534e4cbd1806eda6
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(
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
e13a90a89515d5ec03b0644b63d27fe669820320..09240bc2b5a3a56ebee899d0cd483db4d9cca55b
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();
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index
eedbab4cd6e0f50053288dfa73d2f69056f9a2da..37c21bc550726b851015ae6711b68795f27cd9f8
100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -1937,6 +1937,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_) {
@@ -1964,15 +1965,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");
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.