static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
Isolate* isolate = info->isolate();
- ZoneScope zone_scope(info->zone());
PostponeInterruptsScope postpone(isolate);
ASSERT(!isolate->native_context().is_null());
bool Compiler::CompileLazy(CompilationInfo* info) {
Isolate* isolate = info->isolate();
- ZoneScope zone_scope(info->zone());
-
// The VM is in the COMPILER state until exiting this function.
VMState<COMPILER> state(isolate);
CompilationPhase::CompilationPhase(const char* name,
Isolate* isolate,
Zone* zone)
- : name_(name), isolate_(isolate), zone_scope_(zone) {
+ : name_(name), isolate_(isolate), zone_(zone) {
if (FLAG_hydrogen_stats) {
start_allocation_size_ = zone->allocation_size();
start_ticks_ = OS::Ticks();
explicit CompilationInfoWithZone(Handle<Script> script)
: CompilationInfo(script, &zone_, &phase_zone_),
zone_(script->GetIsolate()),
- zone_scope_(&zone_),
phase_zone_(script->GetIsolate()) {}
explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
: CompilationInfo(shared_info, &zone_, &phase_zone_),
zone_(shared_info->GetIsolate()),
- zone_scope_(&zone_),
phase_zone_(shared_info->GetIsolate()) {}
explicit CompilationInfoWithZone(Handle<JSFunction> closure)
: CompilationInfo(closure, &zone_, &phase_zone_),
zone_(closure->GetIsolate()),
- zone_scope_(&zone_),
phase_zone_(closure->GetIsolate()) {}
CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
: CompilationInfo(stub, isolate, &zone_, &phase_zone_),
zone_(isolate),
- zone_scope_(&zone_),
phase_zone_(isolate) {}
// Virtual destructor because a CompilationInfoWithZone has to exit the
private:
Zone zone_;
- ZoneScope zone_scope_;
Zone phase_zone_;
};
const char* name() const { return name_; }
Isolate* isolate() const { return isolate_; }
- Zone* zone() const { return zone_scope_.zone(); }
+ Zone* zone() const { return zone_; }
private:
const char* name_;
Isolate* isolate_;
- ZoneScope zone_scope_;
+ Zone* zone_;
unsigned start_allocation_size_;
int64_t start_ticks_;
void Deoptimizer::VisitAllOptimizedFunctionsForContext(
Context* context, OptimizedFunctionVisitor* visitor) {
Isolate* isolate = context->GetIsolate();
- ZoneScope zone_scope(isolate->runtime_zone());
+ Zone zone(isolate);
DisallowHeapAllocation no_allocation;
ASSERT(context->IsNativeContext());
// Create a snapshot of the optimized functions list. This is needed because
// visitors might remove more than one link from the list at once.
- ZoneList<JSFunction*> snapshot(1, isolate->runtime_zone());
+ ZoneList<JSFunction*> snapshot(1, &zone);
Object* element = context->OptimizedFunctionsListHead();
while (!element->IsUndefined()) {
JSFunction* element_function = JSFunction::cast(element);
- snapshot.Add(element_function, isolate->runtime_zone());
+ snapshot.Add(element_function, &zone);
element = element_function->next_function_link();
}
Context* context = function->context()->native_context();
Isolate* isolate = context->GetIsolate();
Object* undefined = isolate->heap()->undefined_value();
- Zone* zone = isolate->runtime_zone();
- ZoneScope zone_scope(zone);
- ZoneList<Code*> codes(1, zone);
+ Zone zone(isolate);
+ ZoneList<Code*> codes(1, &zone);
DeoptimizeWithMatchingCodeFilter filter(code);
- PartitionOptimizedFunctions(context, &filter, &codes, zone, undefined);
+ PartitionOptimizedFunctions(context, &filter, &codes, &zone, undefined);
ASSERT_EQ(1, codes.length());
DeoptimizeFunctionWithPreparedFunctionList(
JSFunction::cast(codes.at(0)->deoptimizing_functions()));
ASSERT(context->IsNativeContext());
Isolate* isolate = context->GetIsolate();
Object* undefined = isolate->heap()->undefined_value();
- Zone* zone = isolate->runtime_zone();
- ZoneScope zone_scope(zone);
- ZoneList<Code*> codes(1, zone);
- PartitionOptimizedFunctions(context, filter, &codes, zone, undefined);
+ Zone zone(isolate);
+ ZoneList<Code*> codes(1, &zone);
+ PartitionOptimizedFunctions(context, filter, &codes, &zone, undefined);
for (int i = 0; i < codes.length(); ++i) {
DeoptimizeFunctionWithPreparedFunctionList(
JSFunction::cast(codes.at(i)->deoptimizing_functions()));
}
-static JITCodeEntry* CreateELFObject(CodeDescription* desc, Zone* zone) {
- ZoneScope zone_scope(zone);
+static JITCodeEntry* CreateELFObject(CodeDescription* desc, Isolate* isolate) {
#ifdef __MACH_O
MachO mach_o;
Writer w(&mach_o);
mach_o.Write(&w, desc->CodeStart(), desc->CodeSize());
#else
- ELF elf(zone);
+ Zone zone(isolate);
+ ELF elf(&zone);
Writer w(&elf);
int text_section_index = elf.AddSection(
- new(zone) FullHeaderELFSection(
+ new(&zone) FullHeaderELFSection(
".text",
ELFSection::TYPE_NOBITS,
kCodeAlignment,
0,
desc->CodeSize(),
ELFSection::FLAG_ALLOC | ELFSection::FLAG_EXEC),
- zone);
+ &zone);
- CreateSymbolsTable(desc, zone, &elf, text_section_index);
+ CreateSymbolsTable(desc, &zone, &elf, text_section_index);
- CreateDWARFSections(desc, zone, &elf);
+ CreateDWARFSections(desc, &zone, &elf);
elf.Write(&w);
#endif
}
AddUnwindInfo(&code_desc);
+ Isolate* isolate = code->GetIsolate();
Zone* zone = code->GetIsolate()->runtime_zone();
- JITCodeEntry* entry = CreateELFObject(&code_desc, zone);
+ JITCodeEntry* entry = CreateELFObject(&code_desc, isolate);
ASSERT(!IsLineInfoTagged(entry));
delete lineinfo;
HGraph* graph)
: graph_(graph),
zone_(graph->isolate()),
- zone_scope_(&zone_),
block_count_(graph->blocks()->length()),
maximum_environment_size_(graph->maximum_environment_size()),
collect_markers_(true),
}
if (collect_markers_) {
// Populate |markers_| list during the first pass.
- markers_->Add(marker, &zone_);
+ markers_->Add(marker, zone());
}
break;
}
// Use a dedicated Zone for this phase, with a ZoneScope to ensure it
// gets freed.
Zone zone_;
- ZoneScope zone_scope_;
int block_count_;
: graph_(graph),
info_(info),
removed_side_effects_(false),
- phase_zone_(info->phase_zone()),
- phase_zone_scope_(phase_zone_),
- block_side_effects_(graph->blocks()->length(), phase_zone_),
- loop_side_effects_(graph->blocks()->length(), phase_zone_),
- visited_on_paths_(phase_zone_, graph->blocks()->length()) {
+ zone_(graph->isolate()),
+ block_side_effects_(graph->blocks()->length(), zone()),
+ loop_side_effects_(graph->blocks()->length(), zone()),
+ visited_on_paths_(zone(), graph->blocks()->length()) {
ASSERT(!AllowHandleAllocation::IsAllowed());
block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
- phase_zone_);
+ zone());
loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
- phase_zone_);
+ zone());
}
bool HGlobalValueNumberer::Analyze() {
// GvnBasicBlockState instances.
void HGlobalValueNumberer::AnalyzeGraph() {
HBasicBlock* entry_block = graph_->entry_block();
- HValueMap* entry_map = new(phase_zone()) HValueMap(phase_zone());
+ HValueMap* entry_map = new(zone()) HValueMap(zone());
GvnBasicBlockState* current =
- GvnBasicBlockState::CreateEntry(phase_zone(), entry_block, entry_map);
+ GvnBasicBlockState::CreateEntry(zone(), entry_block, entry_map);
while (current != NULL) {
HBasicBlock* block = current->block();
if (instr->HasSideEffects()) removed_side_effects_ = true;
instr->DeleteAndReplaceWith(other);
} else {
- map->Add(instr, phase_zone());
+ map->Add(instr, zone());
}
}
if (instr->IsLinked() &&
HBasicBlock* dominator_block;
GvnBasicBlockState* next =
- current->next_in_dominator_tree_traversal(phase_zone(),
+ current->next_in_dominator_tree_traversal(zone(),
&dominator_block);
if (next != NULL) {
HGraph* graph() { return graph_; }
CompilationInfo* info() { return info_; }
- Zone* phase_zone() const { return info_->phase_zone(); }
+ Zone* zone() { return &zone_; }
HGraph* graph_;
CompilationInfo* info_;
bool removed_side_effects_;
- Zone* phase_zone_;
- ZoneScope phase_zone_scope_;
+ Zone zone_;
// A map of block IDs to their side effects.
ZoneList<GVNFlagSet> block_side_effects_;
descriptor_lookup_cache_(NULL),
handle_scope_implementer_(NULL),
unicode_cache_(NULL),
- runtime_zone_(this),
in_use_list_(0),
free_list_(0),
preallocated_storage_preallocated_(false),
Isolate::~Isolate() {
TRACE_ISOLATE(destructor);
- // Has to be called while counters_ are still alive.
- runtime_zone_.DeleteKeptSegment();
-
delete[] assembler_spare_buffer_;
assembler_spare_buffer_ = NULL;
global_handles_ = new GlobalHandles(this);
bootstrapper_ = new Bootstrapper(this);
handle_scope_implementer_ = new HandleScopeImplementer(this);
- stub_cache_ = new StubCache(this, runtime_zone());
+ stub_cache_ = new StubCache(this);
regexp_stack_ = new RegExpStack();
regexp_stack_->isolate_ = this;
date_cache_ = new DateCache();
ASSERT(handle_scope_implementer_);
return handle_scope_implementer_;
}
- Zone* runtime_zone() { return &runtime_zone_; }
UnicodeCache* unicode_cache() {
return unicode_cache_;
v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
HandleScopeImplementer* handle_scope_implementer_;
UnicodeCache* unicode_cache_;
- Zone runtime_zone_;
PreallocatedStorage in_use_list_;
PreallocatedStorage free_list_;
bool preallocated_storage_preallocated_;
template <bool seq_ascii>
class JsonParser BASE_EMBEDDED {
public:
- static Handle<Object> Parse(Handle<String> source, Zone* zone) {
- return JsonParser().ParseJson(source, zone);
+ static Handle<Object> Parse(Handle<String> source) {
+ return JsonParser(source).ParseJson();
}
static const int kEndOfString = -1;
private:
+ explicit JsonParser(Handle<String> source)
+ : source_(source),
+ source_length_(source->length()),
+ isolate_(source->map()->GetHeap()->isolate()),
+ factory_(isolate_->factory()),
+ zone_(isolate_),
+ object_constructor_(isolate_->native_context()->object_function(),
+ isolate_),
+ position_(-1) {
+ FlattenString(source_);
+ pretenure_ = (source_length_ >= kPretenureTreshold) ? TENURED : NOT_TENURED;
+
+ // Optimized fast case where we only have ASCII characters.
+ if (seq_ascii) {
+ seq_source_ = Handle<SeqOneByteString>::cast(source_);
+ }
+ }
+
// Parse a string containing a single JSON value.
- Handle<Object> ParseJson(Handle<String> source, Zone* zone);
+ Handle<Object> ParseJson();
inline void Advance() {
position_++;
inline Isolate* isolate() { return isolate_; }
inline Factory* factory() { return factory_; }
inline Handle<JSFunction> object_constructor() { return object_constructor_; }
- inline Zone* zone() const { return zone_; }
static const int kInitialSpecialStringLength = 1024;
static const int kPretenureTreshold = 100 * 1024;
private:
+ Zone* zone() { return &zone_; }
+
Handle<String> source_;
int source_length_;
Handle<SeqOneByteString> seq_source_;
PretenureFlag pretenure_;
Isolate* isolate_;
Factory* factory_;
+ Zone zone_;
Handle<JSFunction> object_constructor_;
uc32 c0_;
int position_;
- Zone* zone_;
};
template <bool seq_ascii>
-Handle<Object> JsonParser<seq_ascii>::ParseJson(Handle<String> source,
- Zone* zone) {
- isolate_ = source->map()->GetHeap()->isolate();
- factory_ = isolate_->factory();
- object_constructor_ = Handle<JSFunction>(
- isolate()->native_context()->object_function(), isolate());
- zone_ = zone;
- FlattenString(source);
- source_ = source;
- source_length_ = source_->length();
- pretenure_ = (source_length_ >= kPretenureTreshold) ? TENURED : NOT_TENURED;
-
- // Optimized fast case where we only have ASCII characters.
- if (seq_ascii) {
- seq_source_ = Handle<SeqOneByteString>::cast(source_);
- }
-
- // Set initial position right before the string.
- position_ = -1;
+Handle<Object> JsonParser<seq_ascii>::ParseJson() {
// Advance to the first character (possibly EOS)
AdvanceSkipWhitespace();
Handle<Object> result = ParseJsonValue();
break;
}
- MessageLocation location(factory->NewScript(source),
+ MessageLocation location(factory->NewScript(source_),
position_,
position_ + 1);
Handle<Object> result = factory->NewSyntaxError(message, array);
Handle<JSObject> json_object =
factory()->NewJSObject(object_constructor(), pretenure_);
Handle<Map> map(json_object->map());
- ZoneScope zone_scope(zone());
ZoneList<Handle<Object> > properties(8, zone());
ASSERT_EQ(c0_, '{');
template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() {
HandleScope scope(isolate());
- ZoneScope zone_scope(zone());
ZoneList<Handle<Object> > elements(4, zone());
ASSERT_EQ(c0_, '[');
Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
Handle<String> pattern,
- Handle<String> flag_str,
- Zone* zone) {
- ZoneScope zone_scope(zone);
+ Handle<String> flag_str) {
Isolate* isolate = re->GetIsolate();
+ Zone zone(isolate);
JSRegExp::Flags flags = RegExpFlagsFromString(flag_str);
CompilationCache* compilation_cache = isolate->compilation_cache();
Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags);
RegExpCompileData parse_result;
FlatStringReader reader(isolate, pattern);
if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(),
- &parse_result, zone)) {
+ &parse_result, &zone)) {
// Throw an exception if we fail to parse the pattern.
ThrowRegExpException(re,
pattern,
bool is_ascii) {
// Compile the RegExp.
Isolate* isolate = re->GetIsolate();
- ZoneScope zone_scope(isolate->runtime_zone());
+ Zone zone(isolate);
PostponeInterruptsScope postpone(isolate);
// If we had a compilation error the last time this is saved at the
// saved code index.
if (!pattern->IsFlat()) FlattenString(pattern);
RegExpCompileData compile_data;
FlatStringReader reader(isolate, pattern);
- Zone* zone = isolate->runtime_zone();
if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(),
&compile_data,
- zone)) {
+ &zone)) {
// Throw an exception if we fail to parse the pattern.
// THIS SHOULD NOT HAPPEN. We already pre-parsed it successfully once.
ThrowRegExpException(re,
pattern,
sample_subject,
is_ascii,
- zone);
+ &zone);
if (result.error_message != NULL) {
// Unable to compile regexp.
Handle<String> error_message =
// Returns false if compilation fails.
static Handle<Object> Compile(Handle<JSRegExp> re,
Handle<String> pattern,
- Handle<String> flags,
- Zone* zone);
+ Handle<String> flags);
// See ECMA-262 section 15.10.6.2.
// This function calls the garbage collector if necessary.
// Drops all call frame matched by target and all frames above them.
template<typename TARGET>
static const char* DropActivationsInActiveThreadImpl(
- TARGET& target, bool do_drop, Zone* zone) {
+ TARGET& target, bool do_drop) {
Isolate* isolate = Isolate::Current();
Debug* debug = isolate->debug();
- ZoneScope scope(zone);
- Vector<StackFrame*> frames = CreateStackMap(isolate, zone);
+ Zone zone(isolate);
+ Vector<StackFrame*> frames = CreateStackMap(isolate, &zone);
int top_frame_index = -1;
// Fills result array with statuses of functions. Modifies the stack
// removing all listed function if possible and if do_drop is true.
static const char* DropActivationsInActiveThread(
- Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop,
- Zone* zone) {
+ Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop) {
MultipleFunctionTarget target(shared_info_array, result);
const char* message =
- DropActivationsInActiveThreadImpl(target, do_drop, zone);
+ DropActivationsInActiveThreadImpl(target, do_drop);
if (message) {
return message;
}
Handle<JSArray> LiveEdit::CheckAndDropActivations(
- Handle<JSArray> shared_info_array, bool do_drop, Zone* zone) {
+ Handle<JSArray> shared_info_array, bool do_drop) {
Isolate* isolate = shared_info_array->GetIsolate();
int len = GetArrayLength(shared_info_array);
// Try to drop activations from the current stack.
const char* error_message =
- DropActivationsInActiveThread(shared_info_array, result, do_drop, zone);
+ DropActivationsInActiveThread(shared_info_array, result, do_drop);
if (error_message != NULL) {
// Add error message as an array extra element.
Vector<const char> vector_message(error_message, StrLength(error_message));
// Finds a drops required frame and all frames above.
// Returns error message or NULL.
-const char* LiveEdit::RestartFrame(JavaScriptFrame* frame, Zone* zone) {
+const char* LiveEdit::RestartFrame(JavaScriptFrame* frame) {
SingleFrameTarget target(frame);
- const char* result = DropActivationsInActiveThreadImpl(target, true, zone);
+ const char* result = DropActivationsInActiveThreadImpl(target, true);
if (result != NULL) {
return result;
}
// has restart the lowest found frames and drops all other frames above
// if possible and if do_drop is true.
static Handle<JSArray> CheckAndDropActivations(
- Handle<JSArray> shared_info_array, bool do_drop, Zone* zone);
+ Handle<JSArray> shared_info_array, bool do_drop);
// Restarts the call frame and completely drops all frames above it.
// Return error message or NULL.
- static const char* RestartFrame(JavaScriptFrame* frame, Zone* zone);
+ static const char* RestartFrame(JavaScriptFrame* frame);
// A copy of this is in liveedit-debugger.js.
enum FunctionPatchabilityStatus {
CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
CONVERT_ARG_HANDLE_CHECKED(String, flags, 2);
Handle<Object> result =
- RegExpImpl::Compile(re, pattern, flags, isolate->runtime_zone());
+ RegExpImpl::Compile(re, pattern, flags);
if (result.is_null()) return Failure::Exception();
return *result;
}
ASSERT(subject->IsFlat());
ASSERT(replacement->IsFlat());
- Zone* zone = isolate->runtime_zone();
- ZoneScope zone_space(zone);
- ZoneList<int> indices(8, zone);
+ Zone zone(isolate);
+ ZoneList<int> indices(8, &zone);
ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
String* pattern =
String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex));
int replacement_len = replacement->length();
FindStringIndicesDispatch(
- isolate, *subject, pattern, &indices, 0xffffffff, zone);
+ isolate, *subject, pattern, &indices, 0xffffffff, &zone);
int matches = indices.length();
if (matches == 0) return *subject;
int subject_length = subject->length();
// CompiledReplacement uses zone allocation.
- Zone* zone = isolate->runtime_zone();
- ZoneScope zonescope(zone);
- CompiledReplacement compiled_replacement(zone);
+ Zone zone(isolate);
+ CompiledReplacement compiled_replacement(&zone);
bool simple_replace = compiled_replacement.Compile(replacement,
capture_count,
subject_length);
int capture_count = regexp->CaptureCount();
- Zone* zone = isolate->runtime_zone();
- ZoneScope zone_space(zone);
- ZoneList<int> offsets(8, zone);
+ Zone zone(isolate);
+ ZoneList<int> offsets(8, &zone);
while (true) {
int32_t* match = global_cache.FetchNext();
if (match == NULL) break;
- offsets.Add(match[0], zone); // start
- offsets.Add(match[1], zone); // end
+ offsets.Add(match[0], &zone); // start
+ offsets.Add(match[1], &zone); // end
}
if (global_cache.HasException()) return Failure::Exception();
static const int kMaxInitialListCapacity = 16;
- Zone* zone = isolate->runtime_zone();
- ZoneScope scope(zone);
+ Zone zone(isolate);
// Find (up to limit) indices of separator and end-of-string in subject
int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
- ZoneList<int> indices(initial_capacity, zone);
+ ZoneList<int> indices(initial_capacity, &zone);
if (!pattern->IsFlat()) FlattenString(pattern);
- FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit, zone);
+ FindStringIndicesDispatch(isolate, *subject, *pattern,
+ &indices, limit, &zone);
if (static_cast<uint32_t>(indices.length()) < limit) {
- indices.Add(subject_length, zone);
+ indices.Add(subject_length, &zone);
}
// The list indices now contains the end of each part to create.
ASSERT_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
- Zone* zone = isolate->runtime_zone();
source = Handle<String>(source->TryFlattenGetString());
// Optimized fast case where we only have ASCII characters.
Handle<Object> result;
if (source->IsSeqOneByteString()) {
- result = JsonParser<true>::Parse(source, zone);
+ result = JsonParser<true>::Parse(source);
} else {
- result = JsonParser<false>::Parse(source, zone);
+ result = JsonParser<false>::Parse(source);
}
if (result.is_null()) {
// Syntax error or stack overflow in scanner.
CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1);
- return *LiveEdit::CheckAndDropActivations(shared_array, do_drop,
- isolate->runtime_zone());
+ return *LiveEdit::CheckAndDropActivations(shared_array, do_drop);
}
// Compares 2 strings line-by-line, then token-wise and returns diff in form
}
if (it.done()) return heap->undefined_value();
- const char* error_message =
- LiveEdit::RestartFrame(it.frame(), isolate->runtime_zone());
+ const char* error_message = LiveEdit::RestartFrame(it.frame());
if (error_message) {
return *(isolate->factory()->InternalizeUtf8String(error_message));
}
// StubCache implementation.
-StubCache::StubCache(Isolate* isolate, Zone* zone)
+StubCache::StubCache(Isolate* isolate)
: isolate_(isolate) {
ASSERT(isolate == Isolate::Current());
}
Factory* factory() { return isolate()->factory(); }
private:
- StubCache(Isolate* isolate, Zone* zone);
+ explicit StubCache(Isolate* isolate);
Handle<Code> ComputeCallInitialize(int argc,
RelocInfo::Mode mode,
inline void* Zone::New(int size) {
- ASSERT(scope_nesting_ > 0);
// Round up the requested size to fit the alignment.
size = RoundUp(size, kAlignment);
}
-ZoneScope::ZoneScope(Zone* zone)
- : zone_(zone) {
- zone_->scope_nesting_++;
-}
-
-
-bool ZoneScope::ShouldDeleteOnExit() {
- return zone_->scope_nesting_ == 1;
-}
-
-
} } // namespace v8::internal
#endif // V8_ZONE_INL_H_
segment_bytes_allocated_(0),
position_(0),
limit_(0),
- scope_nesting_(0),
segment_head_(NULL),
isolate_(isolate) {
}
-ZoneScope::~ZoneScope() {
- if (ShouldDeleteOnExit()) zone_->DeleteAll();
- zone_->scope_nesting_--;
+Zone::~Zone() {
+#ifdef DEBUG
+ // Constant byte value used for zapping dead memory in debug mode.
+ static const unsigned char kZapDeadByte = 0xcd;
+#endif
+
+ // Traverse the chained list of segments, zapping
+ // (in debug mode) and freeing every segment
+ Segment* current = segment_head_;
+ while (current != NULL) {
+ Segment* next = current->next();
+ int size = current->size();
+#ifdef DEBUG
+ // Zap the entire current segment (including the header).
+ memset(current, kZapDeadByte, size);
+#endif
+ DeleteSegment(current, size);
+ current = next;
+ }
+
+ // We must clear the position and limit to force
+ // a new segment to be allocated on demand.
+ position_ = limit_ = 0;
+
+ // Update the head segment.
+ segment_head_ = NULL;
}
}
-void Zone::DeleteAll() {
-#ifdef DEBUG
- // Constant byte value used for zapping dead memory in debug mode.
- static const unsigned char kZapDeadByte = 0xcd;
-#endif
-
- // Find a segment with a suitable size to keep around.
- Segment* keep = segment_head_;
- while (keep != NULL && keep->size() > kMaximumKeptSegmentSize) {
- keep = keep->next();
- }
-
- // Traverse the chained list of segments, zapping (in debug mode)
- // and freeing every segment except the one we wish to keep.
- Segment* current = segment_head_;
- while (current != NULL) {
- Segment* next = current->next();
- if (current == keep) {
- // Unlink the segment we wish to keep from the list.
- current->clear_next();
- } else {
- int size = current->size();
-#ifdef DEBUG
- // Zap the entire current segment (including the header).
- memset(current, kZapDeadByte, size);
-#endif
- DeleteSegment(current, size);
- }
- current = next;
- }
-
- // If we have found a segment we want to keep, we must recompute the
- // variables 'position' and 'limit' to prepare for future allocate
- // attempts. Otherwise, we must clear the position and limit to
- // force a new segment to be allocated on demand.
- if (keep != NULL) {
- Address start = keep->start();
- position_ = RoundUp(start, kAlignment);
- limit_ = keep->end();
-#ifdef DEBUG
- // Zap the contents of the kept segment (but not the header).
- memset(start, kZapDeadByte, keep->capacity());
-#endif
- } else {
- position_ = limit_ = 0;
- }
-
- // Update the head segment to be the kept segment (if any).
- segment_head_ = keep;
-}
-
-
-void Zone::DeleteKeptSegment() {
- if (segment_head_ != NULL) {
- DeleteSegment(segment_head_, segment_head_->size());
- segment_head_ = NULL;
- }
-}
-
-
Address Zone::NewExpand(int size) {
// Make sure the requested size is already properly aligned and that
// there isn't enough room in the Zone to satisfy the request.
class Zone {
public:
explicit Zone(Isolate* isolate);
- ~Zone() { DeleteKeptSegment(); }
+ ~Zone();
// Allocate 'size' bytes of memory in the Zone; expands the Zone by
// allocating new segments of memory on demand using malloc().
inline void* New(int size);
template <typename T>
inline T* NewArray(int length);
- // Deletes all objects and free all memory allocated in the Zone. Keeps one
- // small (size <= kMaximumKeptSegmentSize) segment around if it finds one.
- void DeleteAll();
-
- // Deletes the last small segment kept around by DeleteAll().
- void DeleteKeptSegment();
-
// Returns true if more memory has been allocated in zones than
// the limit allows.
inline bool excess_allocation();
private:
friend class Isolate;
- friend class ZoneScope;
// All pointers returned from New() have this alignment. In addition, if the
// object being allocated has a size that is divisible by 8 then its alignment
// Never allocate segments larger than this size in bytes.
static const int kMaximumSegmentSize = 1 * MB;
- // Never keep segments larger than this size in bytes around.
- static const int kMaximumKeptSegmentSize = 64 * KB;
-
// Report zone excess when allocation exceeds this limit.
int zone_excess_limit_;
Address position_;
Address limit_;
- int scope_nesting_;
-
Segment* segment_head_;
Isolate* isolate_;
};
};
-// ZoneScopes keep track of the current parsing and compilation
-// nesting and cleans up generated ASTs in the Zone when exiting the
-// outer-most scope.
-class ZoneScope BASE_EMBEDDED {
- public:
- INLINE(ZoneScope(Zone* zone));
-
- virtual ~ZoneScope();
-
- Zone* zone() const { return zone_; }
-
- inline bool ShouldDeleteOnExit();
-
- inline static int nesting();
-
- private:
- Zone* zone_;
-};
-
-
// A zone splay tree. The config type parameter encapsulates the
// different configurations of a concrete splay tree (see splay-tree.h).
// The tree itself and all its elements are allocated in the Zone.
CHECK_EQ(0, list->length());
Isolate* isolate = Isolate::Current();
- Zone* zone = isolate->runtime_zone();
- ZoneScope zone_scope(zone);
- AstNodeFactory<AstNullVisitor> factory(isolate, zone);
+ Zone zone(isolate);
+ AstNodeFactory<AstNullVisitor> factory(isolate, &zone);
AstNode* node = factory.NewEmptyStatement();
list->Add(node);
CHECK_EQ(1, list->length());
TEST(BitVector) {
v8::internal::V8::Initialize(NULL);
- Zone* zone = Isolate::Current()->runtime_zone();
- ZoneScope zone_scope(zone);
+ Zone zone(Isolate::Current());
{
- BitVector v(15, zone);
+ BitVector v(15, &zone);
v.Add(1);
CHECK(v.Contains(1));
v.Remove(0);
CHECK(!v.Contains(0));
v.Add(0);
v.Add(1);
- BitVector w(15, zone);
+ BitVector w(15, &zone);
w.Add(1);
v.Intersect(w);
CHECK(!v.Contains(0));
}
{
- BitVector v(64, zone);
+ BitVector v(64, &zone);
v.Add(27);
v.Add(30);
v.Add(31);
}
{
- BitVector v(15, zone);
+ BitVector v(15, &zone);
v.Add(0);
- BitVector w(15, zone);
+ BitVector w(15, &zone);
w.Add(1);
v.Union(w);
CHECK(v.Contains(0));
}
{
- BitVector v(15, zone);
+ BitVector v(15, &zone);
v.Add(0);
- BitVector w(15, zone);
+ BitVector w(15, &zone);
w = v;
CHECK(w.Contains(0));
w.Add(1);
- BitVector u(w, zone);
+ BitVector u(w, &zone);
CHECK(u.Contains(0));
CHECK(u.Contains(1));
v.Union(w);
}
{
- BitVector v(35, zone);
+ BitVector v(35, &zone);
v.Add(0);
- BitVector w(35, zone);
+ BitVector w(35, &zone);
w.Add(33);
v.Union(w);
CHECK(v.Contains(0));
}
{
- BitVector v(35, zone);
+ BitVector v(35, &zone);
v.Add(32);
v.Add(33);
- BitVector w(35, zone);
+ BitVector w(35, &zone);
w.Add(33);
v.Intersect(w);
CHECK(!v.Contains(32));
CHECK(v.Contains(33));
- BitVector r(35, zone);
+ BitVector r(35, &zone);
r.CopyFrom(v);
CHECK(!r.Contains(32));
CHECK(r.Contains(33));
class ListDiffOutputWriter : public Comparator::Output {
public:
- explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer)
- : next_chunk_pointer_(next_chunk_pointer) {
+ explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer,
+ Zone* zone)
+ : next_chunk_pointer_(next_chunk_pointer), zone_(zone) {
(*next_chunk_pointer_) = NULL;
}
void AddChunk(int pos1, int pos2, int len1, int len2) {
- current_chunk_ = new(Isolate::Current()->runtime_zone()) DiffChunkStruct(
- pos1, pos2, len1, len2);
+ current_chunk_ = new(zone_) DiffChunkStruct(pos1, pos2, len1, len2);
(*next_chunk_pointer_) = current_chunk_;
next_chunk_pointer_ = ¤t_chunk_->next;
}
private:
DiffChunkStruct** next_chunk_pointer_;
DiffChunkStruct* current_chunk_;
+ Zone* zone_;
};
int expected_diff_parameter = -1) {
StringCompareInput input(s1, s2);
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
DiffChunkStruct* first_chunk;
- ListDiffOutputWriter writer(&first_chunk);
+ ListDiffOutputWriter writer(&first_chunk, &zone);
Comparator::CalculateDifference(&input, &writer);
static bool CheckParse(const char* input) {
V8::Initialize(NULL);
v8::HandleScope scope(v8::Isolate::GetCurrent());
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
FlatStringReader reader(Isolate::Current(), CStrVector(input));
RegExpCompileData result;
return v8::internal::RegExpParser::ParseRegExp(
- &reader, false, &result, Isolate::Current()->runtime_zone());
+ &reader, false, &result, &zone);
}
static SmartArrayPointer<const char> Parse(const char* input) {
V8::Initialize(NULL);
v8::HandleScope scope(v8::Isolate::GetCurrent());
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
FlatStringReader reader(Isolate::Current(), CStrVector(input));
RegExpCompileData result;
CHECK(v8::internal::RegExpParser::ParseRegExp(
- &reader, false, &result, Isolate::Current()->runtime_zone()));
+ &reader, false, &result, &zone));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
- SmartArrayPointer<const char> output =
- result.tree->ToString(Isolate::Current()->runtime_zone());
+ SmartArrayPointer<const char> output = result.tree->ToString(&zone);
return output;
}
static bool CheckSimple(const char* input) {
V8::Initialize(NULL);
v8::HandleScope scope(v8::Isolate::GetCurrent());
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
FlatStringReader reader(Isolate::Current(), CStrVector(input));
RegExpCompileData result;
CHECK(v8::internal::RegExpParser::ParseRegExp(
- &reader, false, &result, Isolate::Current()->runtime_zone()));
+ &reader, false, &result, &zone));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
return result.simple;
static MinMaxPair CheckMinMaxMatch(const char* input) {
V8::Initialize(NULL);
v8::HandleScope scope(v8::Isolate::GetCurrent());
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
FlatStringReader reader(Isolate::Current(), CStrVector(input));
RegExpCompileData result;
CHECK(v8::internal::RegExpParser::ParseRegExp(
- &reader, false, &result, Isolate::Current()->runtime_zone()));
+ &reader, false, &result, &zone));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
int min_match = result.tree->min_match();
const char* expected) {
V8::Initialize(NULL);
v8::HandleScope scope(v8::Isolate::GetCurrent());
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
FlatStringReader reader(Isolate::Current(), CStrVector(input));
RegExpCompileData result;
CHECK(!v8::internal::RegExpParser::ParseRegExp(
- &reader, false, &result, Isolate::Current()->runtime_zone()));
+ &reader, false, &result, &zone));
CHECK(result.tree == NULL);
CHECK(!result.error.is_null());
SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS);
static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) {
- ZoneScope scope(Isolate::Current()->runtime_zone());
- Zone* zone = Isolate::Current()->runtime_zone();
+ Zone zone(Isolate::Current());
ZoneList<CharacterRange>* ranges =
- new(zone) ZoneList<CharacterRange>(2, zone);
- CharacterRange::AddClassEscape(c, ranges, zone);
+ new(&zone) ZoneList<CharacterRange>(2, &zone);
+ CharacterRange::AddClassEscape(c, ranges, &zone);
for (unsigned i = 0; i < (1 << 16); i++) {
bool in_class = false;
for (int j = 0; !in_class && j < ranges->length(); j++) {
}
-static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) {
+static RegExpNode* Compile(const char* input,
+ bool multiline,
+ bool is_ascii,
+ Zone* zone) {
V8::Initialize(NULL);
Isolate* isolate = Isolate::Current();
FlatStringReader reader(isolate, CStrVector(input));
RegExpCompileData compile_data;
if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
- &compile_data,
- isolate->runtime_zone()))
+ &compile_data, zone))
return NULL;
Handle<String> pattern = isolate->factory()->
NewStringFromUtf8(CStrVector(input));
pattern,
sample_subject,
is_ascii,
- isolate->runtime_zone());
+ zone);
return compile_data.node;
}
bool is_ascii,
bool dot_output = false) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- RegExpNode* node = Compile(input, multiline, is_ascii);
+ Zone zone(Isolate::Current());
+ RegExpNode* node = Compile(input, multiline, is_ascii, &zone);
USE(node);
#ifdef DEBUG
if (dot_output) {
TEST(SplayTreeSimple) {
v8::internal::V8::Initialize(NULL);
static const unsigned kLimit = 1000;
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- ZoneSplayTree<TestConfig> tree(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
+ ZoneSplayTree<TestConfig> tree(&zone);
bool seen[kLimit];
for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
#define CHECK_MAPS_EQUAL() do { \
}
}
// Enter test data into dispatch table.
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- DispatchTable table(Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
+ DispatchTable table(&zone);
for (int i = 0; i < kRangeCount; i++) {
uc16* range = ranges[i];
for (int j = 0; j < 2 * kRangeSize; j += 2)
- table.AddRange(CharacterRange(range[j], range[j + 1]), i,
- Isolate::Current()->runtime_zone());
+ table.AddRange(CharacterRange(range[j], range[j + 1]), i, &zone);
}
// Check that the table looks as we would expect
for (int p = 0; p < kLimit; p++) {
public:
ContextInitializer()
: scope_(v8::Isolate::GetCurrent()),
- env_(v8::Context::New(v8::Isolate::GetCurrent())),
- zone_(Isolate::Current()->runtime_zone()) {
+ env_(v8::Context::New(v8::Isolate::GetCurrent())) {
env_->Enter();
}
~ContextInitializer() {
private:
v8::HandleScope scope_;
v8::Handle<v8::Context> env_;
- v8::internal::ZoneScope zone_;
};
TEST(MacroAssemblerNativeSuccess) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
m.Succeed();
TEST(MacroAssemblerNativeSimple) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
Label fail, backtrack;
m.PushBacktrack(&fail);
TEST(MacroAssemblerNativeSimpleUC16) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
Label fail, backtrack;
m.PushBacktrack(&fail);
TEST(MacroAssemblerNativeBacktrack) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
Label fail;
Label backtrack;
TEST(MacroAssemblerNativeBackReferenceASCII) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
m.WriteCurrentPositionToRegister(0, 0);
m.AdvanceCurrentPosition(2);
TEST(MacroAssemblerNativeBackReferenceUC16) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4, &zone);
m.WriteCurrentPositionToRegister(0, 0);
m.AdvanceCurrentPosition(2);
TEST(MacroAssemblernativeAtStart) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
Label not_at_start, newline, fail;
m.CheckNotAtStart(¬_at_start);
TEST(MacroAssemblerNativeBackRefNoCase) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone);
Label fail, succ;
TEST(MacroAssemblerNativeRegisters) {
v8::V8::Initialize();
ContextInitializer initializer;
- Factory* factory = Isolate::Current()->factory();
+ Isolate* isolate = Isolate::Current();
+ Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone);
uc16 foo_chars[3] = {'f', 'o', 'o'};
Vector<const uc16> foo(foo_chars, 3);
ContextInitializer initializer;
Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone);
Label loop;
m.Bind(&loop);
ContextInitializer initializer;
Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
+ Zone zone(isolate);
- ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2,
- Isolate::Current()->runtime_zone());
+ ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone);
// At least 2048, to ensure the allocated space for registers
// span one full page.
TEST(MacroAssembler) {
V8::Initialize(NULL);
byte codes[1024];
- RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024),
- Isolate::Current()->runtime_zone());
+ Zone zone(Isolate::Current());
+ RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone);
// ^f(o)o.
Label start, fail, backtrack;
static const int kLimit = 1000;
static const int kRangeCount = 16;
for (int t = 0; t < 10; t++) {
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- Zone* zone = Isolate::Current()->runtime_zone();
+ Zone zone(Isolate::Current());
ZoneList<CharacterRange>* ranges =
- new(zone)
- ZoneList<CharacterRange>(kRangeCount, zone);
+ new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone);
for (int i = 0; i < kRangeCount; i++) {
int from = PseudoRandom(t + 87, i + 25) % kLimit;
int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20));
if (to > kLimit) to = kLimit;
- ranges->Add(CharacterRange(from, to), zone);
+ ranges->Add(CharacterRange(from, to), &zone);
}
- DispatchTable table(zone);
- DispatchTableConstructor cons(&table, false,
- Isolate::Current()->runtime_zone());
+ DispatchTable table(&zone);
+ DispatchTableConstructor cons(&table, false, &zone);
cons.set_choice_index(0);
cons.AddInverse(ranges);
for (int i = 0; i < kLimit; i++) {
CHECK_EQ(is_on, set->Get(0) == false);
}
}
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- Zone* zone = Isolate::Current()->runtime_zone();
+ Zone zone(Isolate::Current());
ZoneList<CharacterRange>* ranges =
- new(zone) ZoneList<CharacterRange>(1, zone);
- ranges->Add(CharacterRange(0xFFF0, 0xFFFE), zone);
- DispatchTable table(zone);
- DispatchTableConstructor cons(&table, false,
- Isolate::Current()->runtime_zone());
+ new(&zone) ZoneList<CharacterRange>(1, &zone);
+ ranges->Add(CharacterRange(0xFFF0, 0xFFFE), &zone);
+ DispatchTable table(&zone);
+ DispatchTableConstructor cons(&table, false, &zone);
cons.set_choice_index(0);
cons.AddInverse(ranges);
CHECK(!table.Get(0xFFFE)->Get(0));
static void TestRangeCaseIndependence(CharacterRange input,
Vector<CharacterRange> expected) {
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- Zone* zone = Isolate::Current()->runtime_zone();
+ Zone zone(Isolate::Current());
int count = expected.length();
ZoneList<CharacterRange>* list =
- new(zone) ZoneList<CharacterRange>(count, zone);
- input.AddCaseEquivalents(list, false, zone);
+ new(&zone) ZoneList<CharacterRange>(count, &zone);
+ input.AddCaseEquivalents(list, false, &zone);
CHECK_EQ(count, list->length());
for (int i = 0; i < list->length(); i++) {
CHECK_EQ(expected[i].from(), list->at(i).from());
TEST(CharClassDifference) {
v8::internal::V8::Initialize(NULL);
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- Zone* zone = Isolate::Current()->runtime_zone();
+ Zone zone(Isolate::Current());
ZoneList<CharacterRange>* base =
- new(zone) ZoneList<CharacterRange>(1, zone);
- base->Add(CharacterRange::Everything(), zone);
+ new(&zone) ZoneList<CharacterRange>(1, &zone);
+ base->Add(CharacterRange::Everything(), &zone);
Vector<const int> overlay = CharacterRange::GetWordBounds();
ZoneList<CharacterRange>* included = NULL;
ZoneList<CharacterRange>* excluded = NULL;
- CharacterRange::Split(base, overlay, &included, &excluded,
- Isolate::Current()->runtime_zone());
+ CharacterRange::Split(base, overlay, &included, &excluded, &zone);
for (int i = 0; i < (1 << 16); i++) {
bool in_base = InClass(i, base);
if (in_base) {
TEST(CanonicalizeCharacterSets) {
v8::internal::V8::Initialize(NULL);
- ZoneScope scope(Isolate::Current()->runtime_zone());
- Zone* zone = Isolate::Current()->runtime_zone();
+ Zone zone(Isolate::Current());
ZoneList<CharacterRange>* list =
- new(zone) ZoneList<CharacterRange>(4, zone);
+ new(&zone) ZoneList<CharacterRange>(4, &zone);
CharacterSet set(list);
- list->Add(CharacterRange(10, 20), zone);
- list->Add(CharacterRange(30, 40), zone);
- list->Add(CharacterRange(50, 60), zone);
+ list->Add(CharacterRange(10, 20), &zone);
+ list->Add(CharacterRange(30, 40), &zone);
+ list->Add(CharacterRange(50, 60), &zone);
set.Canonicalize();
ASSERT_EQ(3, list->length());
ASSERT_EQ(10, list->at(0).from());
ASSERT_EQ(60, list->at(2).to());
list->Rewind(0);
- list->Add(CharacterRange(10, 20), zone);
- list->Add(CharacterRange(50, 60), zone);
- list->Add(CharacterRange(30, 40), zone);
+ list->Add(CharacterRange(10, 20), &zone);
+ list->Add(CharacterRange(50, 60), &zone);
+ list->Add(CharacterRange(30, 40), &zone);
set.Canonicalize();
ASSERT_EQ(3, list->length());
ASSERT_EQ(10, list->at(0).from());
ASSERT_EQ(60, list->at(2).to());
list->Rewind(0);
- list->Add(CharacterRange(30, 40), zone);
- list->Add(CharacterRange(10, 20), zone);
- list->Add(CharacterRange(25, 25), zone);
- list->Add(CharacterRange(100, 100), zone);
- list->Add(CharacterRange(1, 1), zone);
+ list->Add(CharacterRange(30, 40), &zone);
+ list->Add(CharacterRange(10, 20), &zone);
+ list->Add(CharacterRange(25, 25), &zone);
+ list->Add(CharacterRange(100, 100), &zone);
+ list->Add(CharacterRange(1, 1), &zone);
set.Canonicalize();
ASSERT_EQ(5, list->length());
ASSERT_EQ(1, list->at(0).from());
ASSERT_EQ(100, list->at(4).to());
list->Rewind(0);
- list->Add(CharacterRange(10, 19), zone);
- list->Add(CharacterRange(21, 30), zone);
- list->Add(CharacterRange(20, 20), zone);
+ list->Add(CharacterRange(10, 19), &zone);
+ list->Add(CharacterRange(21, 30), &zone);
+ list->Add(CharacterRange(20, 20), &zone);
set.Canonicalize();
ASSERT_EQ(1, list->length());
ASSERT_EQ(10, list->at(0).from());
TEST(CharacterRangeMerge) {
v8::internal::V8::Initialize(NULL);
- ZoneScope zone_scope(Isolate::Current()->runtime_zone());
- ZoneList<CharacterRange> l1(4, Isolate::Current()->runtime_zone());
- ZoneList<CharacterRange> l2(4, Isolate::Current()->runtime_zone());
- Zone* zone = Isolate::Current()->runtime_zone();
+ Zone zone(Isolate::Current());
+ ZoneList<CharacterRange> l1(4, &zone);
+ ZoneList<CharacterRange> l2(4, &zone);
// Create all combinations of intersections of ranges, both singletons and
// longer.
// Y - outside after
for (int i = 0; i < 5; i++) {
- l1.Add(CharacterRange::Singleton(offset + 2), zone);
- l2.Add(CharacterRange::Singleton(offset + i), zone);
+ l1.Add(CharacterRange::Singleton(offset + 2), &zone);
+ l2.Add(CharacterRange::Singleton(offset + i), &zone);
offset += 6;
}
// Y - disjoint after
for (int i = 0; i < 7; i++) {
- l1.Add(CharacterRange::Range(offset + 2, offset + 4), zone);
- l2.Add(CharacterRange::Singleton(offset + i), zone);
+ l1.Add(CharacterRange::Range(offset + 2, offset + 4), &zone);
+ l2.Add(CharacterRange::Singleton(offset + i), &zone);
offset += 8;
}
// YYYYYYYYYYYY - containing entirely.
for (int i = 0; i < 9; i++) {
- l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone); // Length 8.
- l2.Add(CharacterRange::Range(offset + 2 * i, offset + 2 * i + 3), zone);
+ l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone); // Length 8.
+ l2.Add(CharacterRange::Range(offset + 2 * i, offset + 2 * i + 3), &zone);
offset += 22;
}
- l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone);
- l2.Add(CharacterRange::Range(offset + 6, offset + 15), zone);
+ l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
+ l2.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
offset += 22;
- l1.Add(CharacterRange::Range(offset + 6, offset + 15), zone);
- l2.Add(CharacterRange::Range(offset + 4, offset + 17), zone);
+ l1.Add(CharacterRange::Range(offset + 6, offset + 15), &zone);
+ l2.Add(CharacterRange::Range(offset + 4, offset + 17), &zone);
offset += 22;
// Different kinds of multi-range overlap:
// XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX
// YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y YYYY Y
- l1.Add(CharacterRange::Range(offset, offset + 21), zone);
- l1.Add(CharacterRange::Range(offset + 31, offset + 52), zone);
+ l1.Add(CharacterRange::Range(offset, offset + 21), &zone);
+ l1.Add(CharacterRange::Range(offset + 31, offset + 52), &zone);
for (int i = 0; i < 6; i++) {
- l2.Add(CharacterRange::Range(offset + 2, offset + 5), zone);
- l2.Add(CharacterRange::Singleton(offset + 8), zone);
+ l2.Add(CharacterRange::Range(offset + 2, offset + 5), &zone);
+ l2.Add(CharacterRange::Singleton(offset + 8), &zone);
offset += 9;
}
ASSERT(CharacterRange::IsCanonical(&l1));
ASSERT(CharacterRange::IsCanonical(&l2));
- ZoneList<CharacterRange> first_only(4, Isolate::Current()->runtime_zone());
- ZoneList<CharacterRange> second_only(4, Isolate::Current()->runtime_zone());
- ZoneList<CharacterRange> both(4, Isolate::Current()->runtime_zone());
+ ZoneList<CharacterRange> first_only(4, &zone);
+ ZoneList<CharacterRange> second_only(4, &zone);
+ ZoneList<CharacterRange> both(4, &zone);
}
static void InitializeBuildingBlocks(Handle<String>* building_blocks,
int bb_length,
bool long_blocks,
- RandomNumberGenerator* rng) {
+ RandomNumberGenerator* rng,
+ Zone* zone) {
// A list of pointers that we don't have any interest in cleaning up.
// If they are reachable from a root then leak detection won't complain.
Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
- Zone* zone = isolate->runtime_zone();
for (int i = 0; i < bb_length; i++) {
int len = rng->next(16);
int slice_head_chars = 0;
class ConsStringGenerationData {
public:
static const int kNumberOfBuildingBlocks = 256;
- explicit ConsStringGenerationData(bool long_blocks);
+ ConsStringGenerationData(bool long_blocks, Zone* zone);
void Reset();
inline Handle<String> block(int offset);
inline Handle<String> block(uint32_t offset);
};
-ConsStringGenerationData::ConsStringGenerationData(bool long_blocks) {
+ConsStringGenerationData::ConsStringGenerationData(bool long_blocks,
+ Zone* zone) {
rng_.init();
InitializeBuildingBlocks(
- building_blocks_, kNumberOfBuildingBlocks, long_blocks, &rng_);
+ building_blocks_, kNumberOfBuildingBlocks, long_blocks, &rng_, zone);
empty_string_ = Isolate::Current()->heap()->empty_string();
Reset();
}
printf("TestTraverse\n");
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
- ZoneScope zone(Isolate::Current()->runtime_zone());
- ConsStringGenerationData data(false);
+ Zone zone(Isolate::Current());
+ ConsStringGenerationData data(false, &zone);
Handle<String> flat = ConstructBalanced(&data);
FlattenString(flat);
Handle<String> left_asymmetric = ConstructLeft(&data, DEEP_DEPTH);
CcTest::InitializeVM();
Isolate* isolate = Isolate::Current();
HandleScope outer_scope(isolate);
- ZoneScope zone(Isolate::Current()->runtime_zone());
- ConsStringGenerationData data(true);
+ Zone zone(isolate);
+ ConsStringGenerationData data(true, &zone);
for (int i = 0; i < test_cases; i++) {
printf("%d\n", i);
HandleScope inner_scope(isolate);
TEST(ExternalShortStringAdd) {
- ZoneScope zonescope(Isolate::Current()->runtime_zone());
+ Isolate* isolate = Isolate::Current();
+ Zone zone(isolate);
CcTest::InitializeVM();
v8::HandleScope handle_scope(CcTest::isolate());
- Zone* zone = Isolate::Current()->runtime_zone();
// Make sure we cover all always-flat lengths and at least one above.
static const int kMaxLength = 20;
// Generate short ascii and non-ascii external strings.
for (int i = 0; i <= kMaxLength; i++) {
- char* ascii = zone->NewArray<char>(i + 1);
+ char* ascii = zone.NewArray<char>(i + 1);
for (int j = 0; j < i; j++) {
ascii[j] = 'a';
}
// Terminating '\0' is left out on purpose. It is not required for external
// string data.
AsciiResource* ascii_resource =
- new(zone) AsciiResource(Vector<const char>(ascii, i));
+ new(&zone) AsciiResource(Vector<const char>(ascii, i));
v8::Local<v8::String> ascii_external_string =
v8::String::NewExternal(ascii_resource);
ascii_external_strings->Set(v8::Integer::New(i), ascii_external_string);
- uc16* non_ascii = zone->NewArray<uc16>(i + 1);
+ uc16* non_ascii = zone.NewArray<uc16>(i + 1);
for (int j = 0; j < i; j++) {
non_ascii[j] = 0x1234;
}
// Terminating '\0' is left out on purpose. It is not required for external
// string data.
- Resource* resource = new(zone) Resource(Vector<const uc16>(non_ascii, i));
+ Resource* resource = new(&zone) Resource(Vector<const uc16>(non_ascii, i));
v8::Local<v8::String> non_ascii_external_string =
v8::String::NewExternal(resource);
non_ascii_external_strings->Set(v8::Integer::New(i),
// values didn't fit in the hash field.
// See http://code.google.com/p/v8/issues/detail?id=728
Isolate* isolate = Isolate::Current();
- ZoneScope zone(isolate->runtime_zone());
+ Zone zone(isolate);
CcTest::InitializeVM();
v8::HandleScope handle_scope(CcTest::isolate());