diff --git a/src/accessors.cc b/src/accessors.cc index 5f9bf744af..d8df05e2a5 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -1,4 +1,4 @@ -// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -32,6 +32,7 @@ #include "deoptimizer.h" #include "execution.h" #include "factory.h" +#include "list-inl.h" #include "safepoint-table.h" #include "scopeinfo.h" diff --git a/src/ast-inl.h b/src/ast-inl.h index d80684a432..c2bd613444 100644 --- a/src/ast-inl.h +++ b/src/ast-inl.h @@ -31,6 +31,7 @@ #include "v8.h" #include "ast.h" +#include "scopes.h" namespace v8 { namespace internal { diff --git a/src/char-predicates.h b/src/char-predicates.h index dac1eb8fef..5a901a26aa 100644 --- a/src/char-predicates.h +++ b/src/char-predicates.h @@ -1,4 +1,4 @@ -// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -28,6 +28,8 @@ #ifndef V8_CHAR_PREDICATES_H_ #define V8_CHAR_PREDICATES_H_ +#include "unicode.h" + namespace v8 { namespace internal { diff --git a/src/codegen.cc b/src/codegen.cc index 6d81415fd5..ad3cf1bf4c 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -34,7 +34,6 @@ #include "prettyprinter.h" #include "rewriter.h" #include "runtime.h" -#include "scopeinfo.h" #include "stub-cache.h" namespace v8 { diff --git a/src/compiler.cc b/src/compiler.cc index 16250af867..e9b48cb070 100755 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -32,7 +32,6 @@ #include "bootstrapper.h" #include "codegen.h" #include "compilation-cache.h" -#include "data-flow.h" #include "debug.h" #include "full-codegen.h" #include "gdb-jit.h" diff --git a/src/data-flow.h b/src/data-flow.h index 76cff8898b..da921029e7 100644 --- a/src/data-flow.h +++ b/src/data-flow.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -37,9 +37,6 @@ namespace v8 { namespace internal { -// Forward declarations. -class Node; - class BitVector: public ZoneObject { public: // Iterator for the elements of this BitVector. @@ -201,140 +198,6 @@ class BitVector: public ZoneObject { uint32_t* data_; }; - -// An implementation of a sparse set whose elements are drawn from integers -// in the range [0..universe_size[. It supports constant-time Contains, -// destructive Add, and destructuve Remove operations and linear-time (in -// the number of elements) destructive Union. -class SparseSet: public ZoneObject { - public: - // Iterator for sparse set elements. Elements should not be added or - // removed during iteration. - class Iterator BASE_EMBEDDED { - public: - explicit Iterator(SparseSet* target) : target_(target), current_(0) { - ASSERT(++target->iterator_count_ > 0); - } - ~Iterator() { - ASSERT(target_->iterator_count_-- > 0); - } - bool Done() const { return current_ >= target_->dense_.length(); } - void Advance() { - ASSERT(!Done()); - ++current_; - } - int Current() { - ASSERT(!Done()); - return target_->dense_[current_]; - } - - private: - SparseSet* target_; - int current_; - - friend class SparseSet; - }; - - explicit SparseSet(int universe_size) - : dense_(4), - sparse_(ZONE->NewArray(universe_size)) { -#ifdef DEBUG - size_ = universe_size; - iterator_count_ = 0; -#endif - } - - bool Contains(int n) const { - ASSERT(0 <= n && n < size_); - int dense_index = sparse_[n]; - return (0 <= dense_index) && - (dense_index < dense_.length()) && - (dense_[dense_index] == n); - } - - void Add(int n) { - ASSERT(0 <= n && n < size_); - ASSERT(iterator_count_ == 0); - if (!Contains(n)) { - sparse_[n] = dense_.length(); - dense_.Add(n); - } - } - - void Remove(int n) { - ASSERT(0 <= n && n < size_); - ASSERT(iterator_count_ == 0); - if (Contains(n)) { - int dense_index = sparse_[n]; - int last = dense_.RemoveLast(); - if (dense_index < dense_.length()) { - dense_[dense_index] = last; - sparse_[last] = dense_index; - } - } - } - - void Union(const SparseSet& other) { - for (int i = 0; i < other.dense_.length(); ++i) { - Add(other.dense_[i]); - } - } - - private: - // The set is implemented as a pair of a growable dense list and an - // uninitialized sparse array. - ZoneList dense_; - int* sparse_; -#ifdef DEBUG - int size_; - int iterator_count_; -#endif -}; - - -// Simple fixed-capacity list-based worklist (managed as a queue) of -// pointers to T. -template -class WorkList BASE_EMBEDDED { - public: - // The worklist cannot grow bigger than size. We keep one item empty to - // distinguish between empty and full. - explicit WorkList(int size) - : capacity_(size + 1), head_(0), tail_(0), queue_(capacity_) { - for (int i = 0; i < capacity_; i++) queue_.Add(NULL); - } - - bool is_empty() { return head_ == tail_; } - - bool is_full() { - // The worklist is full if head is at 0 and tail is at capacity - 1: - // head == 0 && tail == capacity-1 ==> tail - head == capacity - 1 - // or if tail is immediately to the left of head: - // tail+1 == head ==> tail - head == -1 - int diff = tail_ - head_; - return (diff == -1 || diff == capacity_ - 1); - } - - void Insert(T* item) { - ASSERT(!is_full()); - queue_[tail_++] = item; - if (tail_ == capacity_) tail_ = 0; - } - - T* Remove() { - ASSERT(!is_empty()); - T* item = queue_[head_++]; - if (head_ == capacity_) head_ = 0; - return item; - } - - private: - int capacity_; // Including one empty slot. - int head_; // Where the first item is. - int tail_; // Where the next inserted item will go. - List queue_; -}; - } } // namespace v8::internal diff --git a/src/func-name-inferrer.cc b/src/func-name-inferrer.cc index c094251fa5..ebac4b9bff 100644 --- a/src/func-name-inferrer.cc +++ b/src/func-name-inferrer.cc @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -29,6 +29,7 @@ #include "ast.h" #include "func-name-inferrer.h" +#include "list-inl.h" namespace v8 { namespace internal { diff --git a/src/global-handles.h b/src/global-handles.h index 2171b2cf56..c89a2aacdd 100644 --- a/src/global-handles.h +++ b/src/global-handles.h @@ -1,4 +1,4 @@ -// Copyright 2007-2008 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -30,7 +30,7 @@ #include "../include/v8-profiler.h" -#include "list-inl.h" +#include "list.h" namespace v8 { namespace internal { diff --git a/src/hashmap.h b/src/hashmap.h index bb3e3ceb44..5c13212eba 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -1,4 +1,4 @@ -// Copyright 2008 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -28,6 +28,8 @@ #ifndef V8_HASHMAP_H_ #define V8_HASHMAP_H_ +#include "allocation.h" + namespace v8 { namespace internal { diff --git a/src/heap-inl.h b/src/heap-inl.h index 99737ed9b3..44faf751ab 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -1,4 +1,4 @@ -// Copyright 2006-2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -29,8 +29,9 @@ #define V8_HEAP_INL_H_ #include "heap.h" -#include "objects.h" #include "isolate.h" +#include "list-inl.h" +#include "objects.h" #include "v8-counters.h" namespace v8 { diff --git a/src/heap.cc b/src/heap.cc index ac00c01c46..64489a1cce 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -33,8 +33,8 @@ #include "codegen.h" #include "compilation-cache.h" #include "debug.h" -#include "heap-profiler.h" #include "global-handles.h" +#include "heap-profiler.h" #include "liveobjectlist-inl.h" #include "mark-compact.h" #include "natives.h" diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 4fb7fec438..0fe4a0ed20 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -31,6 +31,7 @@ #include "v8.h" #include "code-stubs.h" +#include "data-flow.h" #include "small-pointer-list.h" #include "string-stream.h" #include "zone.h" diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 67ff14d931..4de8305a24 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -29,7 +29,6 @@ #include "hydrogen.h" #include "codegen.h" -#include "data-flow.h" #include "full-codegen.h" #include "hashmap.h" #include "lithium-allocator.h" diff --git a/src/hydrogen.h b/src/hydrogen.h index f65386fc48..22b82d73ae 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -32,7 +32,6 @@ #include "ast.h" #include "compiler.h" -#include "data-flow.h" #include "hydrogen-instructions.h" #include "zone.h" @@ -40,6 +39,7 @@ namespace v8 { namespace internal { // Forward declarations. +class BitVector; class HEnvironment; class HGraph; class HLoopInformation; diff --git a/src/list.h b/src/list.h index ccb095c49b..ef795578b2 100644 --- a/src/list.h +++ b/src/list.h @@ -1,4 +1,4 @@ -// Copyright 2006-2009 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -28,6 +28,8 @@ #ifndef V8_LIST_H_ #define V8_LIST_H_ +#include "utils.h" + namespace v8 { namespace internal { diff --git a/src/lithium-allocator.h b/src/lithium-allocator.h index f109c45491..7fff294bd1 100644 --- a/src/lithium-allocator.h +++ b/src/lithium-allocator.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -30,7 +30,6 @@ #include "v8.h" -#include "data-flow.h" #include "lithium.h" #include "zone.h" diff --git a/src/liveedit.cc b/src/liveedit.cc index 8488170117..3754fa25b0 100644 --- a/src/liveedit.cc +++ b/src/liveedit.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -30,8 +30,8 @@ #include "liveedit.h" -#include "compiler.h" #include "compilation-cache.h" +#include "compiler.h" #include "debug.h" #include "deoptimizer.h" #include "global-handles.h" diff --git a/src/objects.cc b/src/objects.cc index 7c2097fa30..f42be65a1c 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -41,7 +41,6 @@ #include "macro-assembler.h" #include "safepoint-table.h" #include "scanner-base.h" -#include "scopeinfo.h" #include "string-stream.h" #include "utils.h" #include "vm-state-inl.h" diff --git a/src/parser.cc b/src/parser.cc index 14eb534b8c..f983437183 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -28,7 +28,7 @@ #include "v8.h" #include "api.h" -#include "ast.h" +#include "ast-inl.h" #include "bootstrapper.h" #include "codegen.h" #include "compiler.h" @@ -41,8 +41,6 @@ #include "scopeinfo.h" #include "string-stream.h" -#include "ast-inl.h" - namespace v8 { namespace internal { diff --git a/src/preparse-data.cc b/src/preparse-data.cc index 92a0338a65..5cb0a883ee 100644 --- a/src/preparse-data.cc +++ b/src/preparse-data.cc @@ -26,15 +26,12 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../include/v8stdint.h" -#include "globals.h" -#include "checks.h" -#include "allocation.h" -#include "utils.h" -#include "list-inl.h" -#include "hashmap.h" #include "preparse-data.h" +#include "checks.h" +#include "globals.h" +#include "hashmap.h" namespace v8 { namespace internal { diff --git a/src/preparse-data.h b/src/preparse-data.h index bb5707b61d..e12203a631 100644 --- a/src/preparse-data.h +++ b/src/preparse-data.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -29,6 +29,7 @@ #define V8_PREPARSER_DATA_H_ #include "hashmap.h" +#include "utils-inl.h" namespace v8 { namespace internal { diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 4cf62e256d..099977c16f 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -28,14 +28,15 @@ #ifdef ENABLE_LOGGING_AND_PROFILING #include "v8.h" + +#include "profile-generator-inl.h" + #include "global-handles.h" #include "heap-profiler.h" #include "scopeinfo.h" #include "unicode.h" #include "zone-inl.h" -#include "profile-generator-inl.h" - namespace v8 { namespace internal { diff --git a/src/runtime.cc b/src/runtime.cc index efb4be7033..6738213f9b 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -46,8 +46,8 @@ #include "liveobjectlist-inl.h" #include "parser.h" #include "platform.h" -#include "runtime.h" #include "runtime-profiler.h" +#include "runtime.h" #include "scopeinfo.h" #include "smart-pointer.h" #include "string-search.h" diff --git a/src/scanner-base.h b/src/scanner-base.h index 60b97d229c..a2fbd82d67 100644 --- a/src/scanner-base.h +++ b/src/scanner-base.h @@ -30,14 +30,13 @@ #ifndef V8_SCANNER_BASE_H_ #define V8_SCANNER_BASE_H_ -#include "globals.h" -#include "checks.h" #include "allocation.h" +#include "char-predicates.h" +#include "checks.h" +#include "globals.h" #include "token.h" #include "unicode-inl.h" -#include "char-predicates.h" #include "utils.h" -#include "list-inl.h" namespace v8 { namespace internal { diff --git a/src/serialize.cc b/src/serialize.cc index 12e9613e3e..a64fba3096 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -1,4 +1,4 @@ -// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -29,6 +29,7 @@ #include "accessors.h" #include "api.h" +#include "bootstrapper.h" #include "execution.h" #include "global-handles.h" #include "ic-inl.h" @@ -38,7 +39,6 @@ #include "serialize.h" #include "stub-cache.h" #include "v8threads.h" -#include "bootstrapper.h" namespace v8 { namespace internal { diff --git a/src/spaces.h b/src/spaces.h index bd939d1e44..8269ea6a27 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -1,4 +1,4 @@ -// Copyright 2006-2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -28,7 +28,7 @@ #ifndef V8_SPACES_H_ #define V8_SPACES_H_ -#include "list-inl.h" +#include "list.h" #include "log.h" namespace v8 { diff --git a/src/utils-inl.h b/src/utils-inl.h new file mode 100644 index 0000000000..76a3c104ef --- /dev/null +++ b/src/utils-inl.h @@ -0,0 +1,48 @@ +// Copyright 2011 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. + +#ifndef V8_UTILS_INL_H_ +#define V8_UTILS_INL_H_ + +#include "list-inl.h" + +namespace v8 { +namespace internal { + +template +void Collector::Reset() { + for (int i = chunks_.length() - 1; i >= 0; i--) { + chunks_.at(i).Dispose(); + } + chunks_.Rewind(0); + index_ = 0; + size_ = 0; +} + +} } // namespace v8::internal + +#endif // V8_UTILS_INL_H_ diff --git a/src/utils.h b/src/utils.h index 6f89766c16..e2ce7d68d8 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1,4 +1,4 @@ -// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -582,14 +582,7 @@ class Collector { } // Resets the collector to be empty. - virtual void Reset() { - for (int i = chunks_.length() - 1; i >= 0; i--) { - chunks_.at(i).Dispose(); - } - chunks_.Rewind(0); - index_ = 0; - size_ = 0; - } + virtual void Reset(); // Total number of elements added to collector so far. inline int size() { return size_; } diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index bd08d4cec6..ee9ee26a2c 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -1,14 +1,16 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // // Tests for heap profiler #ifdef ENABLE_LOGGING_AND_PROFILING #include "v8.h" + +#include "cctest.h" #include "heap-profiler.h" #include "snapshot.h" #include "string-stream.h" -#include "cctest.h" +#include "utils-inl.h" #include "zone-inl.h" #include "../include/v8-profiler.h" diff --git a/test/cctest/test-utils.cc b/test/cctest/test-utils.cc index ce53f8e429..e136858300 100644 --- a/test/cctest/test-utils.cc +++ b/test/cctest/test-utils.cc @@ -1,4 +1,4 @@ -// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -29,8 +29,9 @@ #include "v8.h" -#include "platform.h" #include "cctest.h" +#include "platform.h" +#include "utils-inl.h" using namespace v8::internal; diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index a590d9890d..95b0b1cff8 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -554,6 +554,7 @@ '../../src/unicode-inl.h', '../../src/unicode.cc', '../../src/unicode.h', + '../../src/utils-inl.h', '../../src/utils.cc', '../../src/utils.h', '../../src/v8-counters.cc',