Get rid of ZoneScope completely.
There's no need to differentiate between an actual Zone and its scope. Instead we bind the lifetime of the Zone memory to the lifetime of the Zone itself, which is way easier to understand than having to dig through the code looking for zone scopes. Depends on https://codereview.chromium.org/17826004/ R=danno@chromium.org BUG= Review URL: https://codereview.chromium.org/17827005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15337 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
8e9b934e7e
commit
9e0f0a73dc
@ -546,7 +546,6 @@ static bool DebuggerWantsEagerCompilation(CompilationInfo* info,
|
||||
|
||||
static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
|
||||
Isolate* isolate = info->isolate();
|
||||
ZoneScope zone_scope(info->zone());
|
||||
PostponeInterruptsScope postpone(isolate);
|
||||
|
||||
ASSERT(!isolate->native_context().is_null());
|
||||
@ -910,8 +909,6 @@ static bool InstallCodeFromOptimizedCodeMap(CompilationInfo* info) {
|
||||
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);
|
||||
|
||||
@ -1228,7 +1225,7 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
|
||||
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();
|
||||
|
@ -441,22 +441,18 @@ class CompilationInfoWithZone: public CompilationInfo {
|
||||
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
|
||||
@ -468,7 +464,6 @@ class CompilationInfoWithZone: public CompilationInfo {
|
||||
|
||||
private:
|
||||
Zone zone_;
|
||||
ZoneScope zone_scope_;
|
||||
Zone phase_zone_;
|
||||
};
|
||||
|
||||
@ -643,12 +638,12 @@ class CompilationPhase BASE_EMBEDDED {
|
||||
|
||||
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_;
|
||||
|
||||
|
@ -284,7 +284,7 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
|
||||
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());
|
||||
@ -293,11 +293,11 @@ void Deoptimizer::VisitAllOptimizedFunctionsForContext(
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
@ -420,11 +420,10 @@ void Deoptimizer::DeoptimizeFunction(JSFunction* function) {
|
||||
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()));
|
||||
@ -437,10 +436,9 @@ void Deoptimizer::DeoptimizeAllFunctionsForContext(
|
||||
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()));
|
||||
|
@ -1916,8 +1916,7 @@ static void UnregisterCodeEntry(JITCodeEntry* entry) {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -1930,11 +1929,12 @@ static JITCodeEntry* CreateELFObject(CodeDescription* desc, Zone* zone) {
|
||||
|
||||
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,
|
||||
@ -1942,11 +1942,11 @@ static JITCodeEntry* CreateELFObject(CodeDescription* desc, Zone* zone) {
|
||||
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
|
||||
@ -2083,8 +2083,9 @@ void GDBJITInterface::AddCode(const char* name,
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -37,7 +37,6 @@ EnvironmentSlotLivenessAnalyzer::EnvironmentSlotLivenessAnalyzer(
|
||||
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),
|
||||
@ -147,7 +146,7 @@ void EnvironmentSlotLivenessAnalyzer::UpdateLivenessAtInstruction(
|
||||
}
|
||||
if (collect_markers_) {
|
||||
// Populate |markers_| list during the first pass.
|
||||
markers_->Add(marker, &zone_);
|
||||
markers_->Add(marker, zone());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ class EnvironmentSlotLivenessAnalyzer {
|
||||
// Use a dedicated Zone for this phase, with a ZoneScope to ensure it
|
||||
// gets freed.
|
||||
Zone zone_;
|
||||
ZoneScope zone_scope_;
|
||||
|
||||
int block_count_;
|
||||
|
||||
|
@ -365,16 +365,15 @@ HGlobalValueNumberer::HGlobalValueNumberer(HGraph* graph, CompilationInfo* info)
|
||||
: 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() {
|
||||
@ -758,9 +757,9 @@ class GvnBasicBlockState: public ZoneObject {
|
||||
// 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();
|
||||
@ -802,7 +801,7 @@ void HGlobalValueNumberer::AnalyzeGraph() {
|
||||
if (instr->HasSideEffects()) removed_side_effects_ = true;
|
||||
instr->DeleteAndReplaceWith(other);
|
||||
} else {
|
||||
map->Add(instr, phase_zone());
|
||||
map->Add(instr, zone());
|
||||
}
|
||||
}
|
||||
if (instr->IsLinked() &&
|
||||
@ -828,7 +827,7 @@ void HGlobalValueNumberer::AnalyzeGraph() {
|
||||
|
||||
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) {
|
||||
|
@ -100,14 +100,13 @@ class HGlobalValueNumberer BASE_EMBEDDED {
|
||||
|
||||
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_;
|
||||
|
@ -1738,7 +1738,6 @@ Isolate::Isolate()
|
||||
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),
|
||||
@ -1935,9 +1934,6 @@ void Isolate::SetIsolateThreadLocals(Isolate* isolate,
|
||||
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;
|
||||
|
||||
@ -2114,7 +2110,7 @@ bool Isolate::Init(Deserializer* des) {
|
||||
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();
|
||||
|
@ -892,7 +892,6 @@ class Isolate {
|
||||
ASSERT(handle_scope_implementer_);
|
||||
return handle_scope_implementer_;
|
||||
}
|
||||
Zone* runtime_zone() { return &runtime_zone_; }
|
||||
|
||||
UnicodeCache* unicode_cache() {
|
||||
return unicode_cache_;
|
||||
@ -1260,7 +1259,6 @@ class Isolate {
|
||||
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_;
|
||||
|
@ -43,15 +43,33 @@ namespace internal {
|
||||
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_++;
|
||||
@ -179,13 +197,14 @@ class JsonParser BASE_EMBEDDED {
|
||||
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_;
|
||||
@ -193,32 +212,14 @@ class JsonParser BASE_EMBEDDED {
|
||||
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();
|
||||
@ -264,7 +265,7 @@ Handle<Object> JsonParser<seq_ascii>::ParseJson(Handle<String> source,
|
||||
break;
|
||||
}
|
||||
|
||||
MessageLocation location(factory->NewScript(source),
|
||||
MessageLocation location(factory->NewScript(source_),
|
||||
position_,
|
||||
position_ + 1);
|
||||
Handle<Object> result = factory->NewSyntaxError(message, array);
|
||||
@ -323,7 +324,6 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
|
||||
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_, '{');
|
||||
|
||||
@ -469,7 +469,6 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
|
||||
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_, '[');
|
||||
|
||||
|
@ -168,10 +168,9 @@ static bool HasFewDifferentCharacters(Handle<String> pattern) {
|
||||
|
||||
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);
|
||||
@ -188,7 +187,7 @@ Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
|
||||
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,
|
||||
@ -410,7 +409,7 @@ bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
|
||||
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.
|
||||
@ -441,10 +440,9 @@ bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
|
||||
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,
|
||||
@ -461,7 +459,7 @@ bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
|
||||
pattern,
|
||||
sample_subject,
|
||||
is_ascii,
|
||||
zone);
|
||||
&zone);
|
||||
if (result.error_message != NULL) {
|
||||
// Unable to compile regexp.
|
||||
Handle<String> error_message =
|
||||
|
@ -71,8 +71,7 @@ class RegExpImpl {
|
||||
// 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.
|
||||
|
@ -1832,11 +1832,11 @@ class MultipleFunctionTarget {
|
||||
// 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;
|
||||
@ -1928,12 +1928,11 @@ static const char* DropActivationsInActiveThreadImpl(
|
||||
// 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;
|
||||
}
|
||||
@ -1980,7 +1979,7 @@ class InactiveThreadActivationsChecker : public ThreadVisitor {
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@ -2006,7 +2005,7 @@ Handle<JSArray> LiveEdit::CheckAndDropActivations(
|
||||
|
||||
// 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));
|
||||
@ -2047,10 +2046,10 @@ class SingleFrameTarget {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ class LiveEdit : AllStatic {
|
||||
// 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 {
|
||||
|
@ -1700,7 +1700,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) {
|
||||
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;
|
||||
}
|
||||
@ -3600,9 +3600,8 @@ MUST_USE_RESULT static MaybeObject* StringReplaceGlobalAtomRegExpWithString(
|
||||
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));
|
||||
@ -3611,7 +3610,7 @@ MUST_USE_RESULT static MaybeObject* StringReplaceGlobalAtomRegExpWithString(
|
||||
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;
|
||||
@ -3687,9 +3686,8 @@ MUST_USE_RESULT static MaybeObject* StringReplaceGlobalRegExpWithString(
|
||||
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);
|
||||
@ -4222,15 +4220,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
|
||||
|
||||
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();
|
||||
@ -6315,18 +6312,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
|
||||
|
||||
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.
|
||||
@ -9318,14 +9315,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
|
||||
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.
|
||||
@ -13120,8 +13116,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) {
|
||||
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
|
||||
@ -13169,8 +13164,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditRestartFrame) {
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace internal {
|
||||
// StubCache implementation.
|
||||
|
||||
|
||||
StubCache::StubCache(Isolate* isolate, Zone* zone)
|
||||
StubCache::StubCache(Isolate* isolate)
|
||||
: isolate_(isolate) {
|
||||
ASSERT(isolate == Isolate::Current());
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ class StubCache {
|
||||
Factory* factory() { return isolate()->factory(); }
|
||||
|
||||
private:
|
||||
StubCache(Isolate* isolate, Zone* zone);
|
||||
explicit StubCache(Isolate* isolate);
|
||||
|
||||
Handle<Code> ComputeCallInitialize(int argc,
|
||||
RelocInfo::Mode mode,
|
||||
|
@ -40,7 +40,6 @@ namespace internal {
|
||||
|
||||
|
||||
inline void* Zone::New(int size) {
|
||||
ASSERT(scope_nesting_ > 0);
|
||||
// Round up the requested size to fit the alignment.
|
||||
size = RoundUp(size, kAlignment);
|
||||
|
||||
@ -110,17 +109,6 @@ void* ZoneList<T>::operator new(size_t size, Zone* zone) {
|
||||
}
|
||||
|
||||
|
||||
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_
|
||||
|
90
src/zone.cc
90
src/zone.cc
@ -73,15 +73,37 @@ Zone::Zone(Isolate* isolate)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -105,66 +127,6 @@ void Zone::DeleteSegment(Segment* segment, int size) {
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
|
35
src/zone.h
35
src/zone.h
@ -58,7 +58,7 @@ class Isolate;
|
||||
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);
|
||||
@ -66,13 +66,6 @@ class Zone {
|
||||
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();
|
||||
@ -85,7 +78,6 @@ class Zone {
|
||||
|
||||
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
|
||||
@ -98,9 +90,6 @@ class Zone {
|
||||
// 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_;
|
||||
|
||||
@ -131,8 +120,6 @@ class Zone {
|
||||
Address position_;
|
||||
Address limit_;
|
||||
|
||||
int scope_nesting_;
|
||||
|
||||
Segment* segment_head_;
|
||||
Isolate* isolate_;
|
||||
};
|
||||
@ -225,26 +212,6 @@ class ZoneList: public List<T, ZoneAllocationPolicy> {
|
||||
};
|
||||
|
||||
|
||||
// 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.
|
||||
|
@ -40,9 +40,8 @@ TEST(List) {
|
||||
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());
|
||||
|
@ -36,17 +36,16 @@ using namespace v8::internal;
|
||||
|
||||
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));
|
||||
@ -54,7 +53,7 @@ TEST(BitVector) {
|
||||
}
|
||||
|
||||
{
|
||||
BitVector v(64, zone);
|
||||
BitVector v(64, &zone);
|
||||
v.Add(27);
|
||||
v.Add(30);
|
||||
v.Add(31);
|
||||
@ -72,9 +71,9 @@ TEST(BitVector) {
|
||||
}
|
||||
|
||||
{
|
||||
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));
|
||||
@ -82,13 +81,13 @@ TEST(BitVector) {
|
||||
}
|
||||
|
||||
{
|
||||
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);
|
||||
@ -97,9 +96,9 @@ TEST(BitVector) {
|
||||
}
|
||||
|
||||
{
|
||||
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));
|
||||
@ -107,15 +106,15 @@ TEST(BitVector) {
|
||||
}
|
||||
|
||||
{
|
||||
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));
|
||||
|
@ -76,19 +76,20 @@ class DiffChunkStruct : public ZoneObject {
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
|
||||
@ -96,10 +97,10 @@ void CompareStringsOneWay(const char* s1, const char* s2,
|
||||
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);
|
||||
|
||||
|
@ -72,37 +72,36 @@ using namespace v8::internal;
|
||||
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;
|
||||
@ -116,11 +115,11 @@ struct MinMaxPair {
|
||||
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();
|
||||
@ -389,11 +388,11 @@ static void ExpectError(const char* input,
|
||||
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);
|
||||
@ -473,11 +472,10 @@ static bool NotWord(uc16 c) {
|
||||
|
||||
|
||||
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++) {
|
||||
@ -501,14 +499,16 @@ TEST(CharacterClassEscapes) {
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
@ -521,7 +521,7 @@ static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) {
|
||||
pattern,
|
||||
sample_subject,
|
||||
is_ascii,
|
||||
isolate->runtime_zone());
|
||||
zone);
|
||||
return compile_data.node;
|
||||
}
|
||||
|
||||
@ -531,8 +531,8 @@ static void Execute(const char* input,
|
||||
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) {
|
||||
@ -571,8 +571,8 @@ static unsigned PseudoRandom(int i, int j) {
|
||||
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 { \
|
||||
@ -639,13 +639,12 @@ TEST(DispatchTableConstruction) {
|
||||
}
|
||||
}
|
||||
// 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++) {
|
||||
@ -708,8 +707,7 @@ class ContextInitializer {
|
||||
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() {
|
||||
@ -718,7 +716,6 @@ class ContextInitializer {
|
||||
private:
|
||||
v8::HandleScope scope_;
|
||||
v8::Handle<v8::Context> env_;
|
||||
v8::internal::ZoneScope zone_;
|
||||
};
|
||||
|
||||
|
||||
@ -743,10 +740,11 @@ static ArchRegExpMacroAssembler::Result Execute(Code* code,
|
||||
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();
|
||||
|
||||
@ -779,10 +777,11 @@ TEST(MacroAssemblerNativeSuccess) {
|
||||
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);
|
||||
@ -844,10 +843,11 @@ TEST(MacroAssemblerNativeSimple) {
|
||||
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);
|
||||
@ -914,10 +914,11 @@ TEST(MacroAssemblerNativeSimpleUC16) {
|
||||
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;
|
||||
@ -953,10 +954,11 @@ TEST(MacroAssemblerNativeBacktrack) {
|
||||
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);
|
||||
@ -1001,10 +1003,11 @@ TEST(MacroAssemblerNativeBackReferenceASCII) {
|
||||
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);
|
||||
@ -1052,10 +1055,11 @@ TEST(MacroAssemblerNativeBackReferenceUC16) {
|
||||
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);
|
||||
@ -1110,10 +1114,11 @@ TEST(MacroAssemblernativeAtStart) {
|
||||
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;
|
||||
|
||||
@ -1168,10 +1173,11 @@ TEST(MacroAssemblerNativeBackRefNoCase) {
|
||||
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);
|
||||
@ -1272,9 +1278,9 @@ TEST(MacroAssemblerStackOverflow) {
|
||||
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);
|
||||
@ -1311,9 +1317,9 @@ TEST(MacroAssemblerNativeLotsOfRegisters) {
|
||||
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.
|
||||
@ -1360,8 +1366,8 @@ TEST(MacroAssemblerNativeLotsOfRegisters) {
|
||||
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;
|
||||
|
||||
@ -1428,20 +1434,17 @@ TEST(AddInverseToTable) {
|
||||
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++) {
|
||||
@ -1452,14 +1455,12 @@ TEST(AddInverseToTable) {
|
||||
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));
|
||||
@ -1567,12 +1568,11 @@ TEST(UncanonicalizeEquivalence) {
|
||||
|
||||
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());
|
||||
@ -1633,16 +1633,14 @@ static bool InClass(uc16 c, ZoneList<CharacterRange>* ranges) {
|
||||
|
||||
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) {
|
||||
@ -1663,15 +1661,14 @@ TEST(CharClassDifference) {
|
||||
|
||||
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());
|
||||
@ -1682,9 +1679,9 @@ TEST(CanonicalizeCharacterSets) {
|
||||
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());
|
||||
@ -1695,11 +1692,11 @@ TEST(CanonicalizeCharacterSets) {
|
||||
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());
|
||||
@ -1714,9 +1711,9 @@ TEST(CanonicalizeCharacterSets) {
|
||||
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());
|
||||
@ -1726,10 +1723,9 @@ TEST(CanonicalizeCharacterSets) {
|
||||
|
||||
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.
|
||||
|
||||
@ -1744,8 +1740,8 @@ TEST(CharacterRangeMerge) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -1760,8 +1756,8 @@ TEST(CharacterRangeMerge) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -1781,35 +1777,35 @@ TEST(CharacterRangeMerge) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,12 +133,12 @@ class AsciiResource: public v8::String::ExternalAsciiStringResource,
|
||||
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;
|
||||
@ -263,7 +263,7 @@ void ConsStringStats::VerifyEqual(const ConsStringStats& that) const {
|
||||
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);
|
||||
@ -285,10 +285,11 @@ class ConsStringGenerationData {
|
||||
};
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
@ -570,8 +571,8 @@ TEST(Traverse) {
|
||||
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);
|
||||
@ -660,8 +661,8 @@ void TestStringCharacterStream(BuildString build, int test_cases) {
|
||||
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);
|
||||
@ -929,11 +930,11 @@ TEST(Utf8Conversion) {
|
||||
|
||||
|
||||
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;
|
||||
@ -947,25 +948,25 @@ TEST(ExternalShortStringAdd) {
|
||||
|
||||
// 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),
|
||||
@ -1021,7 +1022,7 @@ TEST(CachedHashOverflow) {
|
||||
// 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());
|
||||
|
Loading…
Reference in New Issue
Block a user