From 124ef540c08f2412b4dac23b4735fef5948d9315 Mon Sep 17 00:00:00 2001 From: "kasperl@chromium.org" Date: Fri, 17 Jul 2009 05:37:09 +0000 Subject: [PATCH] Patch by Mark Mentovai. Don't put static variables inline. Original review: http://codereview.chromium.org/149768 TBR=kmillikin@chromium.org Review URL: http://codereview.chromium.org/155679 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2492 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/SConscript | 2 +- src/frame-element.cc | 45 ++++++++++++++++++++++++++++++++++ src/frame-element.h | 5 +--- src/ia32/register-allocator-ia32-inl.h | 2 +- src/parser.cc | 15 +++++++----- src/register-allocator.cc | 6 +++++ src/register-allocator.h | 5 +--- tools/gyp/v8.gyp | 1 + tools/visual_studio/v8_base.vcproj | 12 ++++++--- tools/visual_studio/v8_base_arm.vcproj | 8 ++++++ 10 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 src/frame-element.cc diff --git a/src/SConscript b/src/SConscript index f1ca875..f9f9634 100755 --- a/src/SConscript +++ b/src/SConscript @@ -40,7 +40,7 @@ SOURCES = { 'codegen.cc', 'compilation-cache.cc', 'compiler.cc', 'contexts.cc', 'conversions.cc', 'counters.cc', 'dateparser.cc', 'debug.cc', 'debug-agent.cc', 'disassembler.cc', 'execution.cc', 'factory.cc', - 'flags.cc', 'frames.cc', 'func-name-inferrer.cc', + 'flags.cc', 'frame-element.cc', 'frames.cc', 'func-name-inferrer.cc', 'global-handles.cc', 'handles.cc', 'hashmap.cc', 'heap.cc', 'ic.cc', 'interpreter-irregexp.cc', 'jsregexp.cc', 'jump-target.cc', 'log.cc', 'log-utils.cc', 'mark-compact.cc', 'messages.cc', diff --git a/src/frame-element.cc b/src/frame-element.cc new file mode 100644 index 0000000..e6bc2ea --- /dev/null +++ b/src/frame-element.cc @@ -0,0 +1,45 @@ +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "v8.h" + +#include "frame-element.h" + +namespace v8 { +namespace internal { + +// ------------------------------------------------------------------------- +// FrameElement implementation. + + +FrameElement::ZoneObjectList* FrameElement::ConstantList() { + static ZoneObjectList list(10); + return &list; +} + + +} } // namespace v8::internal diff --git a/src/frame-element.h b/src/frame-element.h index 666aabb..ccdecf1 100644 --- a/src/frame-element.h +++ b/src/frame-element.h @@ -91,10 +91,7 @@ class FrameElement BASE_EMBEDDED { // this table of handles to the actual constants. typedef ZoneList > ZoneObjectList; - static ZoneObjectList* ConstantList() { - static ZoneObjectList list(10); - return &list; - } + static ZoneObjectList* ConstantList(); // Clear the constants indirection table. static void ClearConstantList() { diff --git a/src/ia32/register-allocator-ia32-inl.h b/src/ia32/register-allocator-ia32-inl.h index ddee472..9ab4568 100644 --- a/src/ia32/register-allocator-ia32-inl.h +++ b/src/ia32/register-allocator-ia32-inl.h @@ -65,7 +65,7 @@ int RegisterAllocator::ToNumber(Register reg) { Register RegisterAllocator::ToRegister(int num) { ASSERT(num >= 0 && num < kNumRegisters); - static Register registers[] = { eax, ebx, ecx, edx, edi }; + const Register registers[] = { eax, ebx, ecx, edx, edi }; return registers[num]; } diff --git a/src/parser.cc b/src/parser.cc index a5ccb3f..6ec1af6 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -834,12 +834,7 @@ class AstBuildingParserFactory : public ParserFactory { return new CallEval(expression, arguments, pos); } - virtual Statement* EmptyStatement() { - // Use a statically allocated empty statement singleton to avoid - // allocating lots and lots of empty statements. - static v8::internal::EmptyStatement empty; - return ∅ - } + virtual Statement* EmptyStatement(); }; @@ -1032,6 +1027,14 @@ Scope* AstBuildingParserFactory::NewScope(Scope* parent, Scope::Type type, } +Statement* AstBuildingParserFactory::EmptyStatement() { + // Use a statically allocated empty statement singleton to avoid + // allocating lots and lots of empty statements. + static v8::internal::EmptyStatement empty; + return ∅ +} + + Scope* ParserFactory::NewScope(Scope* parent, Scope::Type type, bool inside_with) { ASSERT(parent != NULL); diff --git a/src/register-allocator.cc b/src/register-allocator.cc index d1b08bb..d55f949 100644 --- a/src/register-allocator.cc +++ b/src/register-allocator.cc @@ -44,6 +44,12 @@ Result::Result(Register reg) { } +Result::ZoneObjectList* Result::ConstantList() { + static ZoneObjectList list(10); + return &list; +} + + // ------------------------------------------------------------------------- // RegisterAllocator implementation. diff --git a/src/register-allocator.h b/src/register-allocator.h index f7167d9..1765633 100644 --- a/src/register-allocator.h +++ b/src/register-allocator.h @@ -92,10 +92,7 @@ class Result BASE_EMBEDDED { // of handles to the actual constants. typedef ZoneList > ZoneObjectList; - static ZoneObjectList* ConstantList() { - static ZoneObjectList list(10); - return &list; - } + static ZoneObjectList* ConstantList(); // Clear the constants indirection table. static void ClearConstantList() { diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index b11a7ff..fc49620 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -254,6 +254,7 @@ '../../src/frames-inl.h', '../../src/frames.cc', '../../src/frames.h', + '../../src/frame-element.cc', '../../src/frame-element.h', '../../src/func-name-inferrer.cc', '../../src/func-name-inferrer.h', diff --git a/tools/visual_studio/v8_base.vcproj b/tools/visual_studio/v8_base.vcproj index bfdcec9..ece631a 100644 --- a/tools/visual_studio/v8_base.vcproj +++ b/tools/visual_studio/v8_base.vcproj @@ -397,19 +397,23 @@ > + + + + + + -- 2.7.4