Simplify include dependencies.

Try to make sure that accessors.h, data-flow.h, list-inl.h, and
scopeinfo.h are included only where needed, but without introducing
implicit dependencies.

Review URL: http://codereview.chromium.org/6903175

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7756 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
kmillikin@chromium.org 2011-05-03 08:23:58 +00:00
parent d1411602a7
commit d0fcbb4ece
31 changed files with 102 additions and 192 deletions

View File

@ -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"

View File

@ -31,6 +31,7 @@
#include "v8.h"
#include "ast.h"
#include "scopes.h"
namespace v8 {
namespace internal {

View File

@ -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 {

View File

@ -34,7 +34,6 @@
#include "prettyprinter.h"
#include "rewriter.h"
#include "runtime.h"
#include "scopeinfo.h"
#include "stub-cache.h"
namespace v8 {

View File

@ -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"

View File

@ -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<int>(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<int> 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<typename T>
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<T*> queue_;
};
} } // namespace v8::internal

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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;

View File

@ -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 {

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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"

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

48
src/utils-inl.h Normal file
View File

@ -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<typename T, int growth_factor, int max_growth>
void Collector<T, growth_factor, max_growth>::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_

View File

@ -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_; }

View File

@ -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"

View File

@ -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;

View File

@ -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',