From 116667f73e93fc1cdbcff101cbdc3b518110b905 Mon Sep 17 00:00:00 2001 From: jgruber Date: Thu, 18 Aug 2016 07:34:03 -0700 Subject: [PATCH] Explicitly initialize Code::builtin_index Initialize Code::builtin_index to -1. This ensures that it is non-negative for builtin code objects (since it is set by Builtins::SetUp), and -1 for everything else. BUG= Review-Url: https://codereview.chromium.org/2254193002 Cr-Commit-Position: refs/heads/master@{#38719} --- src/factory.cc | 1 + src/objects.h | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/factory.cc b/src/factory.cc index 571cd3ff9b..1124e63da9 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -1443,6 +1443,7 @@ Handle Factory::NewCode(const CodeDesc& desc, code->set_source_position_table(*empty_byte_array(), SKIP_WRITE_BARRIER); code->set_prologue_offset(prologue_offset); code->set_constant_pool_offset(desc.instr_size - desc.constant_pool_size); + code->set_builtin_index(-1); if (code->kind() == Code::OPTIMIZED_FUNCTION) { code->set_marked_for_deoptimization(false); diff --git a/src/objects.h b/src/objects.h index 0432b83d9f..0f836a4978 100644 --- a/src/objects.h +++ b/src/objects.h @@ -5179,11 +5179,9 @@ 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. - // For builtins, tells which builtin index it has. - // Note that builtins can have a code kind other than BUILTIN, which means - // that for arbitrary code objects, this index value may be random garbage. - // To verify in that case, compare the code object to the indexed builtin. + // [builtin_index]: For builtins, tells which builtin index the code object + // has. Note that builtins can have a code kind other than BUILTIN. The + // builtin index is a non-negative integer for builtins, and -1 otherwise. inline int builtin_index(); inline void set_builtin_index(int id);