Remove TLS access for current Zone.

By passing around a Zone object explicitly we no longer need to do a
TLS access at the sites that allocate memory from the current Zone.

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10534006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11761 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sanjoy@chromium.org 2012-06-11 12:42:31 +00:00
parent e957b2d51b
commit 6125718f37
84 changed files with 1501 additions and 1225 deletions

View File

@ -291,7 +291,7 @@ static const int kMinimalBufferSize = 4*KB;
Assembler::Assembler(Isolate* arg_isolate, void* buffer, int buffer_size)
: AssemblerBase(arg_isolate),
: AssemblerBase(arg_isolate, arg_isolate->zone()),
positions_recorder_(this),
emit_debug_code_(FLAG_debug_code) {
if (buffer == NULL) {

View File

@ -808,10 +808,11 @@ void FullCodeGenerator::VisitVariableDeclaration(
bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET;
switch (variable->location()) {
case Variable::UNALLOCATED:
globals_->Add(variable->name());
globals_->Add(variable->name(), zone());
globals_->Add(variable->binding_needs_init()
? isolate()->factory()->the_hole_value()
: isolate()->factory()->undefined_value());
: isolate()->factory()->undefined_value(),
zone());
break;
case Variable::PARAMETER:
@ -867,12 +868,12 @@ void FullCodeGenerator::VisitFunctionDeclaration(
Variable* variable = proxy->var();
switch (variable->location()) {
case Variable::UNALLOCATED: {
globals_->Add(variable->name());
globals_->Add(variable->name(), zone());
Handle<SharedFunctionInfo> function =
Compiler::BuildFunctionInfo(declaration->fun(), script());
// Check for stack-overflow exception.
if (function.is_null()) return SetStackOverflow();
globals_->Add(function);
globals_->Add(function, zone());
break;
}
@ -926,8 +927,8 @@ void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
switch (variable->location()) {
case Variable::UNALLOCATED: {
Comment cmnt(masm_, "[ ModuleDeclaration");
globals_->Add(variable->name());
globals_->Add(instance);
globals_->Add(variable->name(), zone());
globals_->Add(instance, zone());
Visit(declaration->module());
break;
}
@ -1603,7 +1604,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
// Mark all computed expressions that are bound to a key that
// is shadowed by a later occurrence of the same key. For the
// marked expressions, no store code is emitted.
expr->CalculateEmitStore();
expr->CalculateEmitStore(zone());
AccessorTable accessor_table(isolate()->zone());
for (int i = 0; i < expr->properties()->length(); i++) {

View File

@ -411,9 +411,9 @@ LChunk::LChunk(CompilationInfo* info, HGraph* graph)
: spill_slot_count_(0),
info_(info),
graph_(graph),
instructions_(32),
pointer_maps_(8),
inlined_closures_(1) {
instructions_(32, graph->zone()),
pointer_maps_(8, graph->zone()),
inlined_closures_(1, graph->zone()) {
}
@ -427,9 +427,9 @@ int LChunk::GetNextSpillIndex(bool is_double) {
LOperand* LChunk::GetNextSpillSlot(bool is_double) {
int index = GetNextSpillIndex(is_double);
if (is_double) {
return LDoubleStackSlot::Create(index);
return LDoubleStackSlot::Create(index, zone());
} else {
return LStackSlot::Create(index);
return LStackSlot::Create(index, zone());
}
}
@ -474,23 +474,23 @@ void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block);
int index = -1;
if (instr->IsControl()) {
instructions_.Add(gap);
instructions_.Add(gap, zone());
index = instructions_.length();
instructions_.Add(instr);
instructions_.Add(instr, zone());
} else {
index = instructions_.length();
instructions_.Add(instr);
instructions_.Add(gap);
instructions_.Add(instr, zone());
instructions_.Add(gap, zone());
}
if (instr->HasPointerMap()) {
pointer_maps_.Add(instr->pointer_map());
pointer_maps_.Add(instr->pointer_map(), zone());
instr->pointer_map()->set_lithium_position(index);
}
}
LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) {
return LConstantOperand::Create(constant->id());
return LConstantOperand::Create(constant->id(), zone());
}
@ -529,7 +529,8 @@ int LChunk::NearestGapPos(int index) const {
void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to);
GetGapAt(index)->GetOrCreateParallelMove(
LGap::START, zone())->AddMove(from, to, zone());
}
@ -762,7 +763,7 @@ LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
ASSERT(!instr->HasPointerMap());
instr->set_pointer_map(new(zone()) LPointerMap(position_));
instr->set_pointer_map(new(zone()) LPointerMap(position_, zone()));
return instr;
}
@ -1345,7 +1346,8 @@ HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) {
HConstant* constant_val = HConstant::cast(divisor);
int32_t int32_val = constant_val->Integer32Value();
if (LChunkBuilder::HasMagicNumberForDivisor(int32_val)) {
return constant_val->CopyToRepresentation(Representation::Integer32());
return constant_val->CopyToRepresentation(Representation::Integer32(),
divisor->block()->zone());
}
}
return NULL;
@ -1361,7 +1363,7 @@ LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
HConstant::cast(right)->HasInteger32Value() &&
HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value()));
return AssignEnvironment(DefineAsRegister(
new LMathFloorOfDiv(dividend, divisor, remainder)));
new(zone()) LMathFloorOfDiv(dividend, divisor, remainder)));
}
@ -1658,7 +1660,8 @@ LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
LOperand* object = UseFixed(instr->value(), r0);
LDateField* result = new LDateField(object, FixedTemp(r1), instr->index());
LDateField* result =
new(zone()) LDateField(object, FixedTemp(r1), instr->index());
return MarkAsCall(DefineFixed(result, r0), instr);
}
@ -2170,7 +2173,8 @@ LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) {
LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) {
LAllocateObject* result = new LAllocateObject(TempRegister(), TempRegister());
LAllocateObject* result =
new(zone()) LAllocateObject(TempRegister(), TempRegister());
return AssignPointerMap(DefineAsRegister(result));
}

View File

@ -333,8 +333,10 @@ class LGap: public LTemplateInstruction<0, 0, 0> {
LAST_INNER_POSITION = AFTER
};
LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
if (parallel_moves_[pos] == NULL) {
parallel_moves_[pos] = new(zone) LParallelMove(zone);
}
return parallel_moves_[pos];
}
@ -2267,9 +2269,11 @@ class LChunk: public ZoneObject {
}
void AddInlinedClosure(Handle<JSFunction> closure) {
inlined_closures_.Add(closure);
inlined_closures_.Add(closure, zone());
}
Zone* zone() const { return graph_->zone(); }
private:
int spill_slot_count_;
CompilationInfo* info_;

View File

@ -639,7 +639,7 @@ void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment,
environment->Register(deoptimization_index,
translation.index(),
(mode == Safepoint::kLazyDeopt) ? pc_offset : -1);
deoptimizations_.Add(environment);
deoptimizations_.Add(environment, zone());
}
}
@ -671,7 +671,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) {
// jump entry if this is the case.
if (deopt_jump_table_.is_empty() ||
(deopt_jump_table_.last().address != entry)) {
deopt_jump_table_.Add(JumpTableEntry(entry));
deopt_jump_table_.Add(JumpTableEntry(entry), zone());
}
__ b(cc, &deopt_jump_table_.last().label);
}
@ -716,7 +716,7 @@ int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
for (int i = 0; i < deoptimization_literals_.length(); ++i) {
if (deoptimization_literals_[i].is_identical_to(literal)) return i;
}
deoptimization_literals_.Add(literal);
deoptimization_literals_.Add(literal, zone());
return result;
}
@ -764,12 +764,12 @@ void LCodeGen::RecordSafepoint(
if (pointer->IsStackSlot()) {
safepoint.DefinePointerSlot(pointer->index(), zone());
} else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
safepoint.DefinePointerRegister(ToRegister(pointer));
safepoint.DefinePointerRegister(ToRegister(pointer), zone());
}
}
if (kind & Safepoint::kWithRegisters) {
// Register cp always contains a pointer to the context.
safepoint.DefinePointerRegister(cp);
safepoint.DefinePointerRegister(cp, zone());
}
}
@ -781,7 +781,7 @@ void LCodeGen::RecordSafepoint(LPointerMap* pointers,
void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) {
LPointerMap empty_pointers(RelocInfo::kNoPosition);
LPointerMap empty_pointers(RelocInfo::kNoPosition, zone());
RecordSafepoint(&empty_pointers, deopt_mode);
}
@ -1191,7 +1191,7 @@ void LCodeGen::DoDivI(LDivI* instr) {
// Call the stub. The numbers in r0 and r1 have
// to be tagged to Smis. If that is not possible, deoptimize.
DeferredDivI* deferred = new DeferredDivI(this, instr);
DeferredDivI* deferred = new(zone()) DeferredDivI(this, instr);
__ TrySmiTag(left, &deoptimize, scratch);
__ TrySmiTag(right, &deoptimize, scratch);
@ -2297,7 +2297,7 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
};
DeferredInstanceOfKnownGlobal* deferred;
deferred = new DeferredInstanceOfKnownGlobal(this, instr);
deferred = new(zone()) DeferredInstanceOfKnownGlobal(this, instr);
Label done, false_result;
Register object = ToRegister(instr->InputAt(0));
@ -3258,7 +3258,7 @@ void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) {
} else {
// Representation is tagged.
DeferredMathAbsTaggedHeapNumber* deferred =
new DeferredMathAbsTaggedHeapNumber(this, instr);
new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr);
Register input = ToRegister(instr->InputAt(0));
// Smi check.
__ JumpIfNotSmi(input, deferred->entry());
@ -3435,7 +3435,7 @@ void LCodeGen::DoRandom(LRandom* instr) {
LRandom* instr_;
};
DeferredDoRandom* deferred = new DeferredDoRandom(this, instr);
DeferredDoRandom* deferred = new(zone()) DeferredDoRandom(this, instr);
// Having marked this instruction as a call we can use any
// registers.
@ -3980,7 +3980,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
};
DeferredStringCharCodeAt* deferred =
new DeferredStringCharCodeAt(this, instr);
new(zone()) DeferredStringCharCodeAt(this, instr);
StringCharLoadGenerator::Generate(masm(),
ToRegister(instr->string()),
@ -4035,7 +4035,7 @@ void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
};
DeferredStringCharFromCode* deferred =
new DeferredStringCharFromCode(this, instr);
new(zone()) DeferredStringCharFromCode(this, instr);
ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
Register char_code = ToRegister(instr->char_code());
@ -4109,7 +4109,7 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
Register src = ToRegister(instr->InputAt(0));
Register dst = ToRegister(instr->result());
DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr);
DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr);
__ SmiTag(dst, src, SetCC);
__ b(vs, deferred->entry());
__ bind(deferred->exit());
@ -4180,7 +4180,7 @@ void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
Register temp1 = ToRegister(instr->TempAt(0));
Register temp2 = ToRegister(instr->TempAt(1));
DeferredNumberTagD* deferred = new DeferredNumberTagD(this, instr);
DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr);
if (FLAG_inline_new) {
__ LoadRoot(scratch, Heap::kHeapNumberMapRootIndex);
__ AllocateHeapNumber(reg, temp1, temp2, scratch, deferred->entry());
@ -4382,7 +4382,7 @@ void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
Register input_reg = ToRegister(input);
DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr);
DeferredTaggedToI* deferred = new(zone()) DeferredTaggedToI(this, instr);
// Optimistically untag the input.
// If the input is a HeapObject, SmiUntag will set the carry flag.
@ -4642,7 +4642,8 @@ void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
LAllocateObject* instr_;
};
DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
DeferredAllocateObject* deferred =
new(zone()) DeferredAllocateObject(this, instr);
Register result = ToRegister(instr->result());
Register scratch = ToRegister(instr->TempAt(0));
@ -5246,7 +5247,7 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
ASSERT(instr->hydrogen()->is_backwards_branch());
// Perform stack overflow check if this goto needs it before jumping.
DeferredStackCheck* deferred_stack_check =
new DeferredStackCheck(this, instr);
new(zone()) DeferredStackCheck(this, instr);
__ LoadRoot(ip, Heap::kStackLimitRootIndex);
__ cmp(sp, Operand(ip));
__ b(lo, deferred_stack_check->entry());

View File

@ -51,20 +51,20 @@ class LCodeGen BASE_EMBEDDED {
current_block_(-1),
current_instruction_(-1),
instructions_(chunk->instructions()),
deoptimizations_(4),
deopt_jump_table_(4),
deoptimization_literals_(8),
deoptimizations_(4, zone),
deopt_jump_table_(4, zone),
deoptimization_literals_(8, zone),
inlined_function_count_(0),
scope_(info->scope()),
status_(UNUSED),
translations_(zone),
deferred_(8),
deferred_(8, zone),
osr_pc_offset_(-1),
last_lazy_deopt_pc_(0),
safepoints_(zone),
zone_(zone),
resolver_(this),
expected_safepoint_kind_(Safepoint::kSimple),
zone_(zone) {
expected_safepoint_kind_(Safepoint::kSimple) {
PopulateDeoptimizationLiteralsWithInlinedFunctions();
}
@ -181,7 +181,7 @@ class LCodeGen BASE_EMBEDDED {
void Abort(const char* format, ...);
void Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); }
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); }
// Code generation passes. Returns true if code generation should
// continue.
@ -371,13 +371,13 @@ class LCodeGen BASE_EMBEDDED {
// itself is emitted at the end of the generated code.
SafepointTableBuilder safepoints_;
Zone* zone_;
// Compiler from a set of parallel moves to a sequential list of moves.
LGapResolver resolver_;
Safepoint::Kind expected_safepoint_kind_;
Zone* zone_;
class PushSafepointRegistersScope BASE_EMBEDDED {
public:
PushSafepointRegistersScope(LCodeGen* codegen,

View File

@ -36,7 +36,7 @@ namespace internal {
static const Register kSavedValueRegister = { 9 };
LGapResolver::LGapResolver(LCodeGen* owner)
: cgen_(owner), moves_(32), root_index_(0), in_cycle_(false),
: cgen_(owner), moves_(32, owner->zone()), root_index_(0), in_cycle_(false),
saved_destination_(NULL) { }
@ -79,7 +79,7 @@ void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) {
const ZoneList<LMoveOperands>* moves = parallel_move->move_operands();
for (int i = 0; i < moves->length(); ++i) {
LMoveOperands move = moves->at(i);
if (!move.IsRedundant()) moves_.Add(move);
if (!move.IsRedundant()) moves_.Add(move, cgen_->zone());
}
Verify();
}

View File

@ -119,8 +119,10 @@ namespace internal {
RegExpMacroAssemblerARM::RegExpMacroAssemblerARM(
Mode mode,
int registers_to_save)
: masm_(new MacroAssembler(Isolate::Current(), NULL, kRegExpCodeSize)),
int registers_to_save,
Zone* zone)
: NativeRegExpMacroAssembler(zone),
masm_(new MacroAssembler(Isolate::Current(), NULL, kRegExpCodeSize)),
mode_(mode),
num_registers_(registers_to_save),
num_saved_registers_(registers_to_save),

View File

@ -45,7 +45,7 @@ class RegExpMacroAssemblerARM: public RegExpMacroAssembler {
#else // V8_INTERPRETED_REGEXP
class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler {
public:
RegExpMacroAssemblerARM(Mode mode, int registers_to_save);
RegExpMacroAssemblerARM(Mode mode, int registers_to_save, Zone* zone);
virtual ~RegExpMacroAssemblerARM();
virtual int stack_limit_slack();
virtual void AdvanceCurrentPosition(int by);

View File

@ -106,9 +106,10 @@ const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING";
// -----------------------------------------------------------------------------
// Implementation of AssemblerBase
AssemblerBase::AssemblerBase(Isolate* isolate)
AssemblerBase::AssemblerBase(Isolate* isolate, Zone* zone)
: isolate_(isolate),
jit_cookie_(0) {
jit_cookie_(0),
zone_(zone) {
if (FLAG_mask_constants_with_cookie && isolate != NULL) {
jit_cookie_ = V8::RandomPrivate(isolate);
}

View File

@ -57,7 +57,7 @@ const unsigned kNoASTId = -1;
class AssemblerBase: public Malloced {
public:
explicit AssemblerBase(Isolate* isolate);
AssemblerBase(Isolate* isolate, Zone* zone);
Isolate* isolate() const { return isolate_; }
int jit_cookie() { return jit_cookie_; }
@ -66,9 +66,12 @@ class AssemblerBase: public Malloced {
// cross-snapshotting.
static void QuietNaN(HeapObject* nan) { }
Zone* zone() const { return zone_; }
private:
Isolate* isolate_;
int jit_cookie_;
Zone* zone_;
};

View File

@ -242,8 +242,11 @@ bool IsEqualNumber(void* first, void* second) {
}
void ObjectLiteral::CalculateEmitStore() {
ZoneHashMap table(Literal::Match);
void ObjectLiteral::CalculateEmitStore(Zone* zone) {
ZoneAllocationPolicy allocator(zone);
ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity,
allocator);
for (int i = properties()->length() - 1; i >= 0; i--) {
ObjectLiteral::Property* property = properties()->at(i);
Literal* literal = property->key();
@ -252,23 +255,23 @@ void ObjectLiteral::CalculateEmitStore() {
// If the key of a computed property is in the table, do not emit
// a store for the property later.
if (property->kind() == ObjectLiteral::Property::COMPUTED &&
table.Lookup(literal, hash, false) != NULL) {
table.Lookup(literal, hash, false, allocator) != NULL) {
property->set_emit_store(false);
} else {
// Add key to the table.
table.Lookup(literal, hash, true);
table.Lookup(literal, hash, true, allocator);
}
}
}
void TargetCollector::AddTarget(Label* target) {
void TargetCollector::AddTarget(Label* target, Zone* zone) {
// Add the label to the collector, but discard duplicates.
int length = targets_.length();
for (int i = 0; i < length; i++) {
if (targets_[i] == target) return;
}
targets_.Add(target);
targets_.Add(target, zone);
}
@ -397,7 +400,8 @@ bool FunctionDeclaration::IsInlineable() const {
// ----------------------------------------------------------------------------
// Recording of type feedback
void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle,
Zone* zone) {
// Record type feedback from the oracle in the AST.
is_uninitialized_ = oracle->LoadIsUninitialized(this);
if (is_uninitialized_) return;
@ -421,15 +425,17 @@ void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
} else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) {
is_string_access_ = true;
} else if (is_monomorphic_) {
receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this));
receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this),
zone);
} else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) {
receiver_types_.Reserve(kMaxKeyedPolymorphism);
receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
}
}
void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle,
Zone* zone) {
Property* prop = target()->AsProperty();
ASSERT(prop != NULL);
is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this);
@ -441,22 +447,23 @@ void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
oracle->StoreReceiverTypes(this, name, &receiver_types_);
} else if (is_monomorphic_) {
// Record receiver type for monomorphic keyed stores.
receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this));
receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this), zone);
} else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) {
receiver_types_.Reserve(kMaxKeyedPolymorphism);
receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
}
}
void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle,
Zone* zone) {
is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this);
receiver_types_.Clear();
if (is_monomorphic_) {
// Record receiver type for monomorphic keyed stores.
receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this));
receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this), zone);
} else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) {
receiver_types_.Reserve(kMaxKeyedPolymorphism);
receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
}
}
@ -783,7 +790,7 @@ bool RegExpCapture::IsAnchoredAtEnd() {
// output formats are alike.
class RegExpUnparser: public RegExpVisitor {
public:
RegExpUnparser();
explicit RegExpUnparser(Zone* zone);
void VisitCharacterRange(CharacterRange that);
SmartArrayPointer<const char> ToString() { return stream_.ToCString(); }
#define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data);
@ -793,10 +800,11 @@ class RegExpUnparser: public RegExpVisitor {
StringStream* stream() { return &stream_; }
HeapStringAllocator alloc_;
StringStream stream_;
Zone* zone_;
};
RegExpUnparser::RegExpUnparser() : stream_(&alloc_) {
RegExpUnparser::RegExpUnparser(Zone* zone) : stream_(&alloc_), zone_(zone) {
}
@ -836,9 +844,9 @@ void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that,
if (that->is_negated())
stream()->Add("^");
stream()->Add("[");
for (int i = 0; i < that->ranges()->length(); i++) {
for (int i = 0; i < that->ranges(zone_)->length(); i++) {
if (i > 0) stream()->Add(" ");
VisitCharacterRange(that->ranges()->at(i));
VisitCharacterRange(that->ranges(zone_)->at(i));
}
stream()->Add("]");
return NULL;
@ -940,8 +948,8 @@ void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) {
}
SmartArrayPointer<const char> RegExpTree::ToString() {
RegExpUnparser unparser;
SmartArrayPointer<const char> RegExpTree::ToString(Zone* zone) {
RegExpUnparser unparser(zone);
Accept(&unparser, NULL);
return unparser.ToString();
}

View File

@ -266,17 +266,17 @@ class Statement: public AstNode {
class SmallMapList {
public:
SmallMapList() {}
explicit SmallMapList(int capacity) : list_(capacity) {}
SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {}
void Reserve(int capacity) { list_.Reserve(capacity); }
void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); }
void Clear() { list_.Clear(); }
void Sort() { list_.Sort(); }
bool is_empty() const { return list_.is_empty(); }
int length() const { return list_.length(); }
void Add(Handle<Map> handle) {
list_.Add(handle.location());
void Add(Handle<Map> handle, Zone* zone) {
list_.Add(handle.location(), zone);
}
Handle<Map> at(int i) const {
@ -432,9 +432,10 @@ class Block: public BreakableStatement {
Block(Isolate* isolate,
ZoneStringList* labels,
int capacity,
bool is_initializer_block)
bool is_initializer_block,
Zone* zone)
: BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY),
statements_(capacity),
statements_(capacity, zone),
is_initializer_block_(is_initializer_block),
scope_(NULL) {
}
@ -597,7 +598,7 @@ class Module: public AstNode {
Interface* interface() const { return interface_; }
protected:
Module() : interface_(Interface::NewModule()) {}
explicit Module(Zone* zone) : interface_(Interface::NewModule(zone)) {}
explicit Module(Interface* interface) : interface_(interface) {}
private:
@ -652,8 +653,9 @@ class ModulePath: public Module {
protected:
template<class> friend class AstNodeFactory;
ModulePath(Module* module, Handle<String> name)
: module_(module),
ModulePath(Module* module, Handle<String> name, Zone* zone)
: Module(zone),
module_(module),
name_(name) {
}
@ -672,7 +674,8 @@ class ModuleUrl: public Module {
protected:
template<class> friend class AstNodeFactory;
explicit ModuleUrl(Handle<String> url) : url_(url) {
ModuleUrl(Handle<String> url, Zone* zone)
: Module(zone), url_(url) {
}
private:
@ -1100,12 +1103,12 @@ class IfStatement: public Statement {
// stack in the compiler; this should probably be reworked.
class TargetCollector: public AstNode {
public:
TargetCollector() : targets_(0) { }
explicit TargetCollector(Zone* zone) : targets_(0, zone) { }
// Adds a jump target to the collector. The collector stores a pointer not
// a copy of the target to make binding work, so make sure not to pass in
// references to something on the stack.
void AddTarget(Label* target);
void AddTarget(Label* target, Zone* zone);
// Virtual behaviour. TargetCollectors are never part of the AST.
virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
@ -1363,7 +1366,7 @@ class ObjectLiteral: public MaterializedLiteral {
// Mark all computed expressions that are bound to a key that
// is shadowed by a later occurrence of the same key. For the
// marked expressions, no store code is emitted.
void CalculateEmitStore();
void CalculateEmitStore(Zone* zone);
enum Flags {
kNoFlags = 0,
@ -1528,7 +1531,7 @@ class Property: public Expression {
bool IsFunctionPrototype() const { return is_function_prototype_; }
// Type feedback information.
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
virtual bool IsMonomorphic() { return is_monomorphic_; }
virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
bool IsArrayLength() { return is_array_length_; }
@ -1801,7 +1804,7 @@ class CountOperation: public Expression {
virtual void MarkAsStatement() { is_prefix_ = true; }
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* znoe);
virtual bool IsMonomorphic() { return is_monomorphic_; }
virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
@ -1954,7 +1957,7 @@ class Assignment: public Expression {
void mark_block_end() { block_end_ = true; }
// Type feedback information.
void RecordTypeFeedback(TypeFeedbackOracle* oracle);
void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
virtual bool IsMonomorphic() { return is_monomorphic_; }
virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
@ -2213,8 +2216,8 @@ class RegExpTree: public ZoneObject {
// Returns the interval of registers used for captures within this
// expression.
virtual Interval CaptureRegisters() { return Interval::Empty(); }
virtual void AppendToText(RegExpText* text);
SmartArrayPointer<const char> ToString();
virtual void AppendToText(RegExpText* text, Zone* zone);
SmartArrayPointer<const char> ToString(Zone* zone);
#define MAKE_ASTYPE(Name) \
virtual RegExp##Name* As##Name(); \
virtual bool Is##Name();
@ -2299,7 +2302,7 @@ class CharacterSet BASE_EMBEDDED {
explicit CharacterSet(ZoneList<CharacterRange>* ranges)
: ranges_(ranges),
standard_set_type_(0) {}
ZoneList<CharacterRange>* ranges();
ZoneList<CharacterRange>* ranges(Zone* zone);
uc16 standard_set_type() { return standard_set_type_; }
void set_standard_set_type(uc16 special_set_type) {
standard_set_type_ = special_set_type;
@ -2330,11 +2333,11 @@ class RegExpCharacterClass: public RegExpTree {
virtual bool IsTextElement() { return true; }
virtual int min_match() { return 1; }
virtual int max_match() { return 1; }
virtual void AppendToText(RegExpText* text);
virtual void AppendToText(RegExpText* text, Zone* zone);
CharacterSet character_set() { return set_; }
// TODO(lrn): Remove need for complex version if is_standard that
// recognizes a mangled standard set and just do { return set_.is_special(); }
bool is_standard();
bool is_standard(Zone* zone);
// Returns a value representing the standard character set if is_standard()
// returns true.
// Currently used values are:
@ -2347,7 +2350,7 @@ class RegExpCharacterClass: public RegExpTree {
// . : non-unicode non-newline
// * : All characters
uc16 standard_type() { return set_.standard_set_type(); }
ZoneList<CharacterRange>* ranges() { return set_.ranges(); }
ZoneList<CharacterRange>* ranges(Zone* zone) { return set_.ranges(zone); }
bool is_negated() { return is_negated_; }
private:
@ -2367,7 +2370,7 @@ class RegExpAtom: public RegExpTree {
virtual bool IsTextElement() { return true; }
virtual int min_match() { return data_.length(); }
virtual int max_match() { return data_.length(); }
virtual void AppendToText(RegExpText* text);
virtual void AppendToText(RegExpText* text, Zone* zone);
Vector<const uc16> data() { return data_; }
int length() { return data_.length(); }
private:
@ -2377,7 +2380,7 @@ class RegExpAtom: public RegExpTree {
class RegExpText: public RegExpTree {
public:
RegExpText() : elements_(2), length_(0) {}
explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {}
virtual void* Accept(RegExpVisitor* visitor, void* data);
virtual RegExpNode* ToNode(RegExpCompiler* compiler,
RegExpNode* on_success);
@ -2386,9 +2389,9 @@ class RegExpText: public RegExpTree {
virtual bool IsTextElement() { return true; }
virtual int min_match() { return length_; }
virtual int max_match() { return length_; }
virtual void AppendToText(RegExpText* text);
void AddElement(TextElement elm) {
elements_.Add(elm);
virtual void AppendToText(RegExpText* text, Zone* zone);
void AddElement(TextElement elm, Zone* zone) {
elements_.Add(elm, zone);
length_ += elm.length();
}
ZoneList<TextElement>* elements() { return &elements_; }
@ -2696,20 +2699,21 @@ class AstNodeFactory BASE_EMBEDDED {
}
ModulePath* NewModulePath(Module* origin, Handle<String> name) {
ModulePath* module = new(zone_) ModulePath(origin, name);
ModulePath* module = new(zone_) ModulePath(origin, name, zone_);
VISIT_AND_RETURN(ModulePath, module)
}
ModuleUrl* NewModuleUrl(Handle<String> url) {
ModuleUrl* module = new(zone_) ModuleUrl(url);
ModuleUrl* module = new(zone_) ModuleUrl(url, zone_);
VISIT_AND_RETURN(ModuleUrl, module)
}
Block* NewBlock(ZoneStringList* labels,
int capacity,
bool is_initializer_block) {
bool is_initializer_block,
Zone* zone) {
Block* block = new(zone_) Block(
isolate_, labels, capacity, is_initializer_block);
isolate_, labels, capacity, is_initializer_block, zone);
VISIT_AND_RETURN(Block, block)
}

View File

@ -294,8 +294,9 @@ static bool MakeCrankshaftCode(CompilationInfo* info) {
}
Handle<Context> global_context(info->closure()->context()->global_context());
TypeFeedbackOracle oracle(code, global_context, info->isolate());
HGraphBuilder builder(info, &oracle);
TypeFeedbackOracle oracle(code, global_context, info->isolate(),
info->isolate()->zone());
HGraphBuilder builder(info, &oracle, info->isolate()->zone());
HPhase phase(HPhase::kTotal);
HGraph* graph = builder.CreateGraph();
if (info->isolate()->has_pending_exception()) {
@ -346,7 +347,8 @@ bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) {
// the compilation info is set if compilation succeeded.
bool succeeded = MakeCode(info);
if (!info->shared_info().is_null()) {
Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope());
Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(),
info->isolate()->zone());
info->shared_info()->set_scope_info(*scope_info);
}
return succeeded;
@ -420,7 +422,7 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
lit->name(),
lit->materialized_literal_count(),
info->code(),
ScopeInfo::Create(info->scope()));
ScopeInfo::Create(info->scope(), info->isolate()->zone()));
ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
Compiler::SetFunctionInfo(result, lit, true, script);
@ -462,7 +464,7 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
script, Debugger::NO_AFTER_COMPILE_FLAGS);
#endif
live_edit_tracker.RecordFunctionInfo(result, lit);
live_edit_tracker.RecordFunctionInfo(result, lit, isolate->zone());
return result;
}
@ -651,7 +653,8 @@ bool Compiler::CompileLazy(CompilationInfo* info) {
// info initialization is important since set_scope_info might
// trigger a GC, causing the ASSERT below to be invalid if the code
// was flushed. By setting the code object last we avoid this.
Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope());
Handle<ScopeInfo> scope_info =
ScopeInfo::Create(info->scope(), info->isolate()->zone());
shared->set_scope_info(*scope_info);
shared->set_code(*code);
if (!function.is_null()) {
@ -728,7 +731,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
} else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) ||
(!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) {
ASSERT(!info.code().is_null());
scope_info = ScopeInfo::Create(info.scope());
scope_info = ScopeInfo::Create(info.scope(), info.isolate()->zone());
} else {
return Handle<SharedFunctionInfo>::null();
}
@ -747,7 +750,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
// the resulting function.
SetExpectedNofPropertiesFromEstimate(result,
literal->expected_property_count());
live_edit_tracker.RecordFunctionInfo(result, literal);
live_edit_tracker.RecordFunctionInfo(result, literal, info.isolate()->zone());
return result;
}

View File

@ -595,7 +595,7 @@ class Translation BASE_EMBEDDED {
void StoreArgumentsObject();
void MarkDuplicate();
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
static int NumberOfOperandsFor(Opcode opcode);

View File

@ -1394,11 +1394,11 @@ class field##_Wrapper : public ZoneObject { \
STACK_FRAME_TYPE_LIST(DEFINE_WRAPPER)
#undef DEFINE_WRAPPER
static StackFrame* AllocateFrameCopy(StackFrame* frame) {
static StackFrame* AllocateFrameCopy(StackFrame* frame, Zone* zone) {
#define FRAME_TYPE_CASE(type, field) \
case StackFrame::type: { \
field##_Wrapper* wrapper = \
new field##_Wrapper(*(reinterpret_cast<field*>(frame))); \
new(zone) field##_Wrapper(*(reinterpret_cast<field*>(frame))); \
return &wrapper->frame_; \
}
@ -1410,11 +1410,11 @@ static StackFrame* AllocateFrameCopy(StackFrame* frame) {
return NULL;
}
Vector<StackFrame*> CreateStackMap() {
ZoneList<StackFrame*> list(10);
Vector<StackFrame*> CreateStackMap(Zone* zone) {
ZoneList<StackFrame*> list(10, zone);
for (StackFrameIterator it; !it.done(); it.Advance()) {
StackFrame* frame = AllocateFrameCopy(it.frame());
list.Add(frame);
StackFrame* frame = AllocateFrameCopy(it.frame(), zone);
list.Add(frame, zone);
}
return list.ToVector();
}

View File

@ -888,7 +888,7 @@ class StackFrameLocator BASE_EMBEDDED {
// Reads all frames on the current stack and copies them into the current
// zone memory.
Vector<StackFrame*> CreateStackMap();
Vector<StackFrame*> CreateStackMap(Zone* zone);
} } // namespace v8::internal

View File

@ -303,7 +303,7 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
masm.positions_recorder()->StartGDBJITLineInfoRecording();
#endif
FullCodeGenerator cgen(&masm, info);
FullCodeGenerator cgen(&masm, info, isolate->zone());
cgen.Generate();
if (cgen.HasStackOverflow()) {
ASSERT(!isolate->has_pending_exception());
@ -440,14 +440,14 @@ void FullCodeGenerator::PrepareForBailoutForId(unsigned id, State state) {
}
}
#endif // DEBUG
bailout_entries_.Add(entry);
bailout_entries_.Add(entry, zone());
}
void FullCodeGenerator::RecordTypeFeedbackCell(
unsigned id, Handle<JSGlobalPropertyCell> cell) {
TypeFeedbackCellEntry entry = { id, cell };
type_feedback_cells_.Add(entry);
type_feedback_cells_.Add(entry, zone());
}
@ -456,7 +456,7 @@ void FullCodeGenerator::RecordStackCheck(unsigned ast_id) {
// state.
ASSERT(masm_->pc_offset() > 0);
BailoutEntry entry = { ast_id, static_cast<unsigned>(masm_->pc_offset()) };
stack_checks_.Add(entry);
stack_checks_.Add(entry, zone());
}
@ -570,7 +570,7 @@ void FullCodeGenerator::DoTest(const TestContext* context) {
void FullCodeGenerator::VisitDeclarations(
ZoneList<Declaration*>* declarations) {
ZoneList<Handle<Object> >* saved_globals = globals_;
ZoneList<Handle<Object> > inner_globals(10);
ZoneList<Handle<Object> > inner_globals(10, zone());
globals_ = &inner_globals;
AstVisitor::VisitDeclarations(declarations);

View File

@ -77,7 +77,8 @@ class FullCodeGenerator: public AstVisitor {
TOS_REG
};
FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info)
FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info,
Zone* zone)
: masm_(masm),
info_(info),
scope_(info->scope()),
@ -86,11 +87,12 @@ class FullCodeGenerator: public AstVisitor {
globals_(NULL),
context_(NULL),
bailout_entries_(info->HasDeoptimizationSupport()
? info->function()->ast_node_count() : 0),
stack_checks_(2), // There's always at least one.
? info->function()->ast_node_count() : 0, zone),
stack_checks_(2, zone), // There's always at least one.
type_feedback_cells_(info->HasDeoptimizationSupport()
? info->function()->ast_node_count() : 0),
ic_total_count_(0) { }
? info->function()->ast_node_count() : 0, zone),
ic_total_count_(0),
zone_(zone) { }
static bool MakeCode(CompilationInfo* info);
@ -108,6 +110,8 @@ class FullCodeGenerator: public AstVisitor {
return NULL;
}
Zone* zone() const { return zone_; }
private:
class Breakable;
class Iteration;
@ -786,6 +790,7 @@ class FullCodeGenerator: public AstVisitor {
int ic_total_count_;
Handle<FixedArray> handler_table_;
Handle<JSGlobalPropertyCell> profiling_counter_;
Zone* zone_;
friend class NestedStatement;
@ -800,11 +805,12 @@ class AccessorTable: public TemplateHashMap<Literal,
public:
explicit AccessorTable(Zone* zone) :
TemplateHashMap<Literal, ObjectLiteral::Accessors,
ZoneAllocationPolicy>(Literal::Match),
ZoneAllocationPolicy>(Literal::Match,
ZoneAllocationPolicy(zone)),
zone_(zone) { }
Iterator lookup(Literal* literal) {
Iterator it = find(literal, true);
Iterator it = find(literal, true, ZoneAllocationPolicy(zone_));
if (it->second == NULL) it->second = new(zone_) ObjectLiteral::Accessors();
return it;
}

View File

@ -34,11 +34,12 @@
namespace v8 {
namespace internal {
FuncNameInferrer::FuncNameInferrer(Isolate* isolate)
FuncNameInferrer::FuncNameInferrer(Isolate* isolate, Zone* zone)
: isolate_(isolate),
entries_stack_(10),
names_stack_(5),
funcs_to_infer_(4) {
entries_stack_(10, zone),
names_stack_(5, zone),
funcs_to_infer_(4, zone),
zone_(zone) {
}
@ -48,21 +49,21 @@ void FuncNameInferrer::PushEnclosingName(Handle<String> name) {
// and starts with a capital letter.
if (name->length() > 0 && Runtime::IsUpperCaseChar(
isolate()->runtime_state(), name->Get(0))) {
names_stack_.Add(Name(name, kEnclosingConstructorName));
names_stack_.Add(Name(name, kEnclosingConstructorName), zone());
}
}
void FuncNameInferrer::PushLiteralName(Handle<String> name) {
if (IsOpen() && !isolate()->heap()->prototype_symbol()->Equals(*name)) {
names_stack_.Add(Name(name, kLiteralName));
names_stack_.Add(Name(name, kLiteralName), zone());
}
}
void FuncNameInferrer::PushVariableName(Handle<String> name) {
if (IsOpen() && !isolate()->heap()->result_symbol()->Equals(*name)) {
names_stack_.Add(Name(name, kVariableName));
names_stack_.Add(Name(name, kVariableName), zone());
}
}

View File

@ -45,7 +45,7 @@ class Isolate;
// a name.
class FuncNameInferrer : public ZoneObject {
public:
explicit FuncNameInferrer(Isolate* isolate);
FuncNameInferrer(Isolate* isolate, Zone* zone);
// Returns whether we have entered name collection state.
bool IsOpen() const { return !entries_stack_.is_empty(); }
@ -55,7 +55,7 @@ class FuncNameInferrer : public ZoneObject {
// Enters name collection state.
void Enter() {
entries_stack_.Add(names_stack_.length());
entries_stack_.Add(names_stack_.length(), zone());
}
// Pushes an encountered name onto names stack when in collection state.
@ -66,7 +66,7 @@ class FuncNameInferrer : public ZoneObject {
// Adds a function to infer name for.
void AddFunction(FunctionLiteral* func_to_infer) {
if (IsOpen()) {
funcs_to_infer_.Add(func_to_infer);
funcs_to_infer_.Add(func_to_infer, zone());
}
}
@ -105,6 +105,7 @@ class FuncNameInferrer : public ZoneObject {
};
Isolate* isolate() { return isolate_; }
Zone* zone() const { return zone_; }
// Constructs a full name in dotted notation from gathered names.
Handle<String> MakeNameFromStack();
@ -119,6 +120,7 @@ class FuncNameInferrer : public ZoneObject {
ZoneList<int> entries_stack_;
ZoneList<Name> names_stack_;
ZoneList<FunctionLiteral*> funcs_to_infer_;
Zone* zone_;
DISALLOW_COPY_AND_ASSIGN(FuncNameInferrer);
};

View File

@ -297,7 +297,7 @@ void TemplateHashMapImpl<AllocationPolicy>::Resize(AllocationPolicy allocator) {
// Rehash all current entries.
for (Entry* p = map; n > 0; p++) {
if (p->key != NULL) {
Lookup(p->key, p->hash, true)->value = p->value;
Lookup(p->key, p->hash, true, allocator)->value = p->value;
n--;
}
}
@ -349,8 +349,9 @@ class TemplateHashMap: private TemplateHashMapImpl<AllocationPolicy> {
Iterator begin() const { return Iterator(this, this->Start()); }
Iterator end() const { return Iterator(this, NULL); }
Iterator find(Key* key, bool insert = false) {
return Iterator(this, this->Lookup(key, key->Hash(), insert));
Iterator find(Key* key, bool insert = false,
AllocationPolicy allocator = AllocationPolicy()) {
return Iterator(this, this->Lookup(key, key->Hash(), insert, allocator));
}
};

View File

@ -336,7 +336,8 @@ HUseListNode* HValue::RemoveUse(HValue* value, int index) {
// Do not reuse use list nodes in debug mode, zap them.
if (current != NULL) {
HUseListNode* temp =
new HUseListNode(current->value(), current->index(), NULL);
new(block()->zone())
HUseListNode(current->value(), current->index(), NULL);
current->Zap();
current = temp;
}
@ -495,8 +496,8 @@ void HValue::RegisterUse(int index, HValue* new_value) {
if (new_value != NULL) {
if (removed == NULL) {
new_value->use_list_ =
new HUseListNode(this, index, new_value->use_list_);
new_value->use_list_ = new(new_value->block()->zone()) HUseListNode(
this, index, new_value->use_list_);
} else {
removed->set_tail(new_value->use_list_);
new_value->use_list_ = removed;
@ -964,7 +965,7 @@ HValue* HUnaryMathOperation::Canonicalize() {
!HInstruction::cast(new_right)->IsLinked()) {
HInstruction::cast(new_right)->InsertBefore(this);
}
HMathFloorOfDiv* instr = new HMathFloorOfDiv(context(),
HMathFloorOfDiv* instr = new(block()->zone()) HMathFloorOfDiv(context(),
new_left,
new_right);
// Replace this HMathFloor instruction by the new HMathFloorOfDiv.
@ -1251,7 +1252,7 @@ void HPhi::PrintTo(StringStream* stream) {
void HPhi::AddInput(HValue* value) {
inputs_.Add(NULL);
inputs_.Add(NULL, value->block()->zone());
SetOperandAt(OperandCount() - 1, value);
// Mark phis that may have 'arguments' directly or indirectly as an operand.
if (!CheckFlag(kIsArguments) && value->CheckFlag(kIsArguments)) {
@ -1397,18 +1398,18 @@ HConstant::HConstant(Handle<Object> handle, Representation r)
}
HConstant* HConstant::CopyToRepresentation(Representation r) const {
HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
if (r.IsInteger32() && !has_int32_value_) return NULL;
if (r.IsDouble() && !has_double_value_) return NULL;
return new HConstant(handle_, r);
return new(zone) HConstant(handle_, r);
}
HConstant* HConstant::CopyToTruncatedInt32() const {
HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const {
if (!has_double_value_) return NULL;
int32_t truncated = NumberToInt32(*handle_);
return new HConstant(FACTORY->NewNumberFromInt(truncated),
Representation::Integer32());
return new(zone) HConstant(FACTORY->NewNumberFromInt(truncated),
Representation::Integer32());
}
@ -1620,8 +1621,9 @@ void HLoadNamedField::PrintDataTo(StringStream* stream) {
HLoadNamedFieldPolymorphic::HLoadNamedFieldPolymorphic(HValue* context,
HValue* object,
SmallMapList* types,
Handle<String> name)
: types_(Min(types->length(), kMaxLoadPolymorphism)),
Handle<String> name,
Zone* zone)
: types_(Min(types->length(), kMaxLoadPolymorphism), zone),
name_(name),
need_generic_(false) {
SetOperandAt(0, context);
@ -1644,11 +1646,11 @@ HLoadNamedFieldPolymorphic::HLoadNamedFieldPolymorphic(HValue* context,
} else {
SetGVNFlag(kDependsOnBackingStoreFields);
}
types_.Add(types->at(i));
types_.Add(types->at(i), zone);
break;
}
case CONSTANT_FUNCTION:
types_.Add(types->at(i));
types_.Add(types->at(i), zone);
break;
case MAP_TRANSITION:
// We should just ignore these since they are not relevant to a load
@ -1765,10 +1767,10 @@ HValue* HLoadKeyedGeneric::Canonicalize() {
index_cache,
key_load->key(),
OMIT_HOLE_CHECK);
HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex(
object(), index);
map_check->InsertBefore(this);
index->InsertBefore(this);
HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex(
object(), index);
load->InsertBefore(this);
return load;
}

View File

@ -992,7 +992,8 @@ class HSoftDeoptimize: public HTemplateInstruction<0> {
class HDeoptimize: public HControlInstruction {
public:
explicit HDeoptimize(int environment_length) : values_(environment_length) { }
HDeoptimize(int environment_length, Zone* zone)
: values_(environment_length, zone) { }
virtual Representation RequiredInputRepresentation(int index) {
return Representation::None();
@ -1011,8 +1012,8 @@ class HDeoptimize: public HControlInstruction {
UNREACHABLE();
}
void AddEnvironmentValue(HValue* value) {
values_.Add(NULL);
void AddEnvironmentValue(HValue* value, Zone* zone) {
values_.Add(NULL, zone);
SetOperandAt(values_.length() - 1, value);
}
@ -1280,11 +1281,12 @@ class HClampToUint8: public HUnaryOperation {
class HSimulate: public HInstruction {
public:
HSimulate(int ast_id, int pop_count)
HSimulate(int ast_id, int pop_count, Zone* zone)
: ast_id_(ast_id),
pop_count_(pop_count),
values_(2),
assigned_indexes_(2) {}
values_(2, zone),
assigned_indexes_(2, zone),
zone_(zone) {}
virtual ~HSimulate() {}
virtual void PrintDataTo(StringStream* stream);
@ -1332,9 +1334,9 @@ class HSimulate: public HInstruction {
private:
static const int kNoIndex = -1;
void AddValue(int index, HValue* value) {
assigned_indexes_.Add(index);
assigned_indexes_.Add(index, zone_);
// Resize the list of pushed values.
values_.Add(NULL);
values_.Add(NULL, zone_);
// Set the operand through the base method in HValue to make sure that the
// use lists are correctly updated.
SetOperandAt(values_.length() - 1, value);
@ -1343,6 +1345,7 @@ class HSimulate: public HInstruction {
int pop_count_;
ZoneList<HValue*> values_;
ZoneList<int> assigned_indexes_;
Zone* zone_;
};
@ -2060,7 +2063,8 @@ class HLoadExternalArrayPointer: public HUnaryOperation {
class HCheckMaps: public HTemplateInstruction<2> {
public:
HCheckMaps(HValue* value, Handle<Map> map, HValue* typecheck = NULL) {
HCheckMaps(HValue* value, Handle<Map> map, Zone* zone,
HValue* typecheck = NULL) {
SetOperandAt(0, value);
// If callers don't depend on a typecheck, they can pass in NULL. In that
// case we use a copy of the |value| argument as a dummy value.
@ -2069,9 +2073,9 @@ class HCheckMaps: public HTemplateInstruction<2> {
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnMaps);
SetGVNFlag(kDependsOnElementsKind);
map_set()->Add(map);
map_set()->Add(map, zone);
}
HCheckMaps(HValue* value, SmallMapList* maps) {
HCheckMaps(HValue* value, SmallMapList* maps, Zone* zone) {
SetOperandAt(0, value);
SetOperandAt(1, value);
set_representation(Representation::Tagged());
@ -2079,13 +2083,14 @@ class HCheckMaps: public HTemplateInstruction<2> {
SetGVNFlag(kDependsOnMaps);
SetGVNFlag(kDependsOnElementsKind);
for (int i = 0; i < maps->length(); i++) {
map_set()->Add(maps->at(i));
map_set()->Add(maps->at(i), zone);
}
map_set()->Sort();
}
static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map) {
HCheckMaps* check_map = new HCheckMaps(object, map);
static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map,
Zone* zone) {
HCheckMaps* check_map = new(zone) HCheckMaps(object, map, zone);
SmallMapList* map_set = check_map->map_set();
// Since transitioned elements maps of the initial map don't fail the map
@ -2099,7 +2104,7 @@ class HCheckMaps: public HTemplateInstruction<2> {
Map* transitioned_map =
map->LookupElementsTransitionMap(kind);
if (transitioned_map) {
map_set->Add(Handle<Map>(transitioned_map));
map_set->Add(Handle<Map>(transitioned_map), zone);
}
};
map_set->Sort();
@ -2168,17 +2173,17 @@ class HCheckFunction: public HUnaryOperation {
class HCheckInstanceType: public HUnaryOperation {
public:
static HCheckInstanceType* NewIsSpecObject(HValue* value) {
return new HCheckInstanceType(value, IS_SPEC_OBJECT);
static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT);
}
static HCheckInstanceType* NewIsJSArray(HValue* value) {
return new HCheckInstanceType(value, IS_JS_ARRAY);
static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_JS_ARRAY);
}
static HCheckInstanceType* NewIsString(HValue* value) {
return new HCheckInstanceType(value, IS_STRING);
static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_STRING);
}
static HCheckInstanceType* NewIsSymbol(HValue* value) {
return new HCheckInstanceType(value, IS_SYMBOL);
static HCheckInstanceType* NewIsSymbol(HValue* value, Zone* zone) {
return new(zone) HCheckInstanceType(value, IS_SYMBOL);
}
virtual void PrintDataTo(StringStream* stream);
@ -2327,8 +2332,8 @@ class HCheckSmi: public HUnaryOperation {
class HPhi: public HValue {
public:
explicit HPhi(int merged_index)
: inputs_(2),
HPhi(int merged_index, Zone* zone)
: inputs_(2, zone),
merged_index_(merged_index),
phi_id_(-1),
is_live_(false),
@ -2487,8 +2492,8 @@ class HConstant: public HTemplateInstruction<0> {
virtual void PrintDataTo(StringStream* stream);
virtual HType CalculateInferredType();
bool IsInteger() const { return handle_->IsSmi(); }
HConstant* CopyToRepresentation(Representation r) const;
HConstant* CopyToTruncatedInt32() const;
HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
HConstant* CopyToTruncatedInt32(Zone* zone) const;
bool HasInteger32Value() const { return has_int32_value_; }
int32_t Integer32Value() const {
ASSERT(HasInteger32Value());
@ -3887,7 +3892,8 @@ class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> {
HLoadNamedFieldPolymorphic(HValue* context,
HValue* object,
SmallMapList* types,
Handle<String> name);
Handle<String> name,
Zone* zone);
HValue* context() { return OperandAt(0); }
HValue* object() { return OperandAt(1); }

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,7 @@ class HBasicBlock: public ZoneObject {
return &deleted_phis_;
}
void RecordDeletedPhi(int merge_index) {
deleted_phis_.Add(merge_index);
deleted_phis_.Add(merge_index, zone());
}
HBasicBlock* dominator() const { return dominator_; }
HEnvironment* last_environment() const { return last_environment_; }
@ -158,7 +158,7 @@ class HBasicBlock: public ZoneObject {
dominates_loop_successors_ = true;
}
inline Zone* zone();
inline Zone* zone() const;
#ifdef DEBUG
void Verify();
@ -212,12 +212,12 @@ class HPredecessorIterator BASE_EMBEDDED {
class HLoopInformation: public ZoneObject {
public:
explicit HLoopInformation(HBasicBlock* loop_header)
: back_edges_(4),
HLoopInformation(HBasicBlock* loop_header, Zone* zone)
: back_edges_(4, zone),
loop_header_(loop_header),
blocks_(8),
blocks_(8, zone),
stack_check_(NULL) {
blocks_.Add(loop_header);
blocks_.Add(loop_header, zone);
}
virtual ~HLoopInformation() {}
@ -244,10 +244,10 @@ class HLoopInformation: public ZoneObject {
class BoundsCheckTable;
class HGraph: public ZoneObject {
public:
explicit HGraph(CompilationInfo* info);
HGraph(CompilationInfo* info, Zone* zone);
Isolate* isolate() { return isolate_; }
Zone* zone() { return isolate_->zone(); }
Zone* zone() const { return zone_; }
const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
@ -304,7 +304,7 @@ class HGraph: public ZoneObject {
int GetMaximumValueID() const { return values_.length(); }
int GetNextBlockID() { return next_block_id_++; }
int GetNextValueID(HValue* value) {
values_.Add(value);
values_.Add(value, zone());
return values_.length() - 1;
}
HValue* LookupValue(int id) const {
@ -380,11 +380,13 @@ class HGraph: public ZoneObject {
SetOncePointer<HBasicBlock> osr_loop_entry_;
SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_;
Zone* zone_;
DISALLOW_COPY_AND_ASSIGN(HGraph);
};
Zone* HBasicBlock::zone() { return graph_->zone(); }
Zone* HBasicBlock::zone() const { return graph_->zone(); }
// Type of stack frame an environment might refer to.
@ -395,7 +397,8 @@ class HEnvironment: public ZoneObject {
public:
HEnvironment(HEnvironment* outer,
Scope* scope,
Handle<JSFunction> closure);
Handle<JSFunction> closure,
Zone* zone);
HEnvironment* DiscardInlined(bool drop_extra) {
HEnvironment* outer = outer_;
@ -462,7 +465,7 @@ class HEnvironment: public ZoneObject {
void Push(HValue* value) {
ASSERT(value != NULL);
++push_count_;
values_.Add(value);
values_.Add(value, zone());
}
HValue* Pop() {
@ -519,13 +522,16 @@ class HEnvironment: public ZoneObject {
void PrintTo(StringStream* stream);
void PrintToStd();
Zone* zone() const { return zone_; }
private:
explicit HEnvironment(const HEnvironment* other);
HEnvironment(const HEnvironment* other, Zone* zone);
HEnvironment(HEnvironment* outer,
Handle<JSFunction> closure,
FrameType frame_type,
int arguments);
int arguments,
Zone* zone);
// Create an artificial stub environment (e.g. for argument adaptor or
// constructor stub).
@ -563,6 +569,7 @@ class HEnvironment: public ZoneObject {
int pop_count_;
int push_count_;
int ast_id_;
Zone* zone_;
};
@ -607,7 +614,7 @@ class AstContext {
HGraphBuilder* owner() const { return owner_; }
inline Zone* zone();
inline Zone* zone() const;
// We want to be able to assert, in a context-specific way, that the stack
// height makes sense when the context is filled.
@ -821,7 +828,7 @@ class HGraphBuilder: public AstVisitor {
BreakAndContinueScope* next_;
};
HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle);
HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle, Zone* zone);
HGraph* CreateGraph();
@ -1144,7 +1151,7 @@ class HGraphBuilder: public AstVisitor {
Handle<Map> receiver_map,
bool smi_and_map_check);
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
// The translation state of the currently-being-translated function.
FunctionState* function_state_;
@ -1176,12 +1183,12 @@ class HGraphBuilder: public AstVisitor {
};
Zone* AstContext::zone() { return owner_->zone(); }
Zone* AstContext::zone() const { return owner_->zone(); }
class HValueMap: public ZoneObject {
public:
HValueMap()
explicit HValueMap(Zone* zone)
: array_size_(0),
lists_size_(0),
count_(0),
@ -1189,15 +1196,15 @@ class HValueMap: public ZoneObject {
array_(NULL),
lists_(NULL),
free_list_head_(kNil) {
ResizeLists(kInitialSize);
Resize(kInitialSize);
ResizeLists(kInitialSize, zone);
Resize(kInitialSize, zone);
}
void Kill(GVNFlagSet flags);
void Add(HValue* value) {
void Add(HValue* value, Zone* zone) {
present_flags_.Add(value->gvn_flags());
Insert(value);
Insert(value, zone);
}
HValue* Lookup(HValue* value) const;
@ -1221,9 +1228,9 @@ class HValueMap: public ZoneObject {
HValueMap(Zone* zone, const HValueMap* other);
void Resize(int new_size);
void ResizeLists(int new_size);
void Insert(HValue* value);
void Resize(int new_size, Zone* zone);
void ResizeLists(int new_size, Zone* zone);
void Insert(HValue* value, Zone* zone);
uint32_t Bound(uint32_t value) const { return value & (array_size_ - 1); }
int array_size_;
@ -1376,7 +1383,7 @@ class HTracer: public Malloced {
WriteChars(filename, "", 0, false);
}
void TraceLiveRange(LiveRange* range, const char* type);
void TraceLiveRange(LiveRange* range, const char* type, Zone* zone);
void Trace(const char* name, HGraph* graph, LChunk* chunk);
void FlushToFile();

View File

@ -313,7 +313,7 @@ static void InitCoverageLog();
#endif
Assembler::Assembler(Isolate* arg_isolate, void* buffer, int buffer_size)
: AssemblerBase(arg_isolate),
: AssemblerBase(arg_isolate, arg_isolate->zone()),
positions_recorder_(this),
emit_debug_code_(FLAG_debug_code) {
if (buffer == NULL) {

View File

@ -782,10 +782,10 @@ void FullCodeGenerator::VisitVariableDeclaration(
bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET;
switch (variable->location()) {
case Variable::UNALLOCATED:
globals_->Add(variable->name());
globals_->Add(variable->name(), zone());
globals_->Add(variable->binding_needs_init()
? isolate()->factory()->the_hole_value()
: isolate()->factory()->undefined_value());
: isolate()->factory()->undefined_value(), zone());
break;
case Variable::PARAMETER:
@ -840,12 +840,12 @@ void FullCodeGenerator::VisitFunctionDeclaration(
Variable* variable = proxy->var();
switch (variable->location()) {
case Variable::UNALLOCATED: {
globals_->Add(variable->name());
globals_->Add(variable->name(), zone());
Handle<SharedFunctionInfo> function =
Compiler::BuildFunctionInfo(declaration->fun(), script());
// Check for stack-overflow exception.
if (function.is_null()) return SetStackOverflow();
globals_->Add(function);
globals_->Add(function, zone());
break;
}
@ -896,8 +896,8 @@ void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
switch (variable->location()) {
case Variable::UNALLOCATED: {
Comment cmnt(masm_, "[ ModuleDeclaration");
globals_->Add(variable->name());
globals_->Add(instance);
globals_->Add(variable->name(), zone());
globals_->Add(instance, zone());
Visit(declaration->module());
break;
}
@ -1557,7 +1557,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
// Mark all computed expressions that are bound to a key that
// is shadowed by a later occurrence of the same key. For the
// marked expressions, no store code is emitted.
expr->CalculateEmitStore();
expr->CalculateEmitStore(zone());
AccessorTable accessor_table(isolate()->zone());
for (int i = 0; i < expr->properties()->length(); i++) {

View File

@ -544,7 +544,7 @@ void LCodeGen::RegisterEnvironmentForDeoptimization(
environment->Register(deoptimization_index,
translation.index(),
(mode == Safepoint::kLazyDeopt) ? pc_offset : -1);
deoptimizations_.Add(environment);
deoptimizations_.Add(environment, zone());
}
}
@ -639,7 +639,7 @@ int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
for (int i = 0; i < deoptimization_literals_.length(); ++i) {
if (deoptimization_literals_[i].is_identical_to(literal)) return i;
}
deoptimization_literals_.Add(literal);
deoptimization_literals_.Add(literal, zone());
return result;
}
@ -686,7 +686,7 @@ void LCodeGen::RecordSafepoint(
if (pointer->IsStackSlot()) {
safepoint.DefinePointerSlot(pointer->index(), zone());
} else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
safepoint.DefinePointerRegister(ToRegister(pointer));
safepoint.DefinePointerRegister(ToRegister(pointer), zone());
}
}
}
@ -699,7 +699,7 @@ void LCodeGen::RecordSafepoint(LPointerMap* pointers,
void LCodeGen::RecordSafepoint(Safepoint::DeoptMode mode) {
LPointerMap empty_pointers(RelocInfo::kNoPosition);
LPointerMap empty_pointers(RelocInfo::kNoPosition, zone());
RecordSafepoint(&empty_pointers, mode);
}
@ -1985,7 +1985,7 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
};
DeferredInstanceOfKnownGlobal* deferred;
deferred = new DeferredInstanceOfKnownGlobal(this, instr);
deferred = new(zone()) DeferredInstanceOfKnownGlobal(this, instr);
Label done, false_result;
Register object = ToRegister(instr->InputAt(1));
@ -2908,7 +2908,7 @@ void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) {
EmitIntegerMathAbs(instr);
} else { // Tagged case.
DeferredMathAbsTaggedHeapNumber* deferred =
new DeferredMathAbsTaggedHeapNumber(this, instr);
new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr);
Register input_reg = ToRegister(instr->value());
// Smi check.
__ JumpIfNotSmi(input_reg, deferred->entry());
@ -3110,7 +3110,7 @@ void LCodeGen::DoRandom(LRandom* instr) {
LRandom* instr_;
};
DeferredDoRandom* deferred = new DeferredDoRandom(this, instr);
DeferredDoRandom* deferred = new(zone()) DeferredDoRandom(this, instr);
// Having marked this instruction as a call we can use any
// registers.
@ -3626,7 +3626,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
};
DeferredStringCharCodeAt* deferred =
new DeferredStringCharCodeAt(this, instr);
new(zone()) DeferredStringCharCodeAt(this, instr);
StringCharLoadGenerator::Generate(masm(),
factory(),
@ -3682,7 +3682,7 @@ void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
};
DeferredStringCharFromCode* deferred =
new DeferredStringCharFromCode(this, instr);
new(zone()) DeferredStringCharFromCode(this, instr);
ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
Register char_code = ToRegister(instr->char_code());
@ -3757,7 +3757,7 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
ASSERT(input->IsRegister() && input->Equals(instr->result()));
Register reg = ToRegister(input);
DeferredNumberTagI* deferred = new DeferredNumberTagI(this, instr);
DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr);
__ SmiTag(reg);
__ j(overflow, deferred->entry());
__ bind(deferred->exit());
@ -3825,7 +3825,7 @@ void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
Register reg = ToRegister(instr->result());
Register tmp = ToRegister(instr->TempAt(0));
DeferredNumberTagD* deferred = new DeferredNumberTagD(this, instr);
DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr);
if (FLAG_inline_new) {
__ AllocateHeapNumber(reg, tmp, no_reg, deferred->entry());
} else {
@ -4025,7 +4025,7 @@ void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
Register input_reg = ToRegister(input);
DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr);
DeferredTaggedToI* deferred = new(zone()) DeferredTaggedToI(this, instr);
// Smi check.
__ JumpIfNotSmi(input_reg, deferred->entry());
@ -4366,7 +4366,8 @@ void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
LAllocateObject* instr_;
};
DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
DeferredAllocateObject* deferred =
new(zone()) DeferredAllocateObject(this, instr);
Register result = ToRegister(instr->result());
Register scratch = ToRegister(instr->TempAt(0));
@ -4981,7 +4982,7 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
ASSERT(instr->hydrogen()->is_backwards_branch());
// Perform stack overflow check if this goto needs it before jumping.
DeferredStackCheck* deferred_stack_check =
new DeferredStackCheck(this, instr);
new(zone()) DeferredStackCheck(this, instr);
ExternalReference stack_limit =
ExternalReference::address_of_stack_limit(isolate());
__ cmp(esp, Operand::StaticVariable(stack_limit));

View File

@ -54,19 +54,19 @@ class LCodeGen BASE_EMBEDDED {
current_block_(-1),
current_instruction_(-1),
instructions_(chunk->instructions()),
deoptimizations_(4),
deoptimization_literals_(8),
deoptimizations_(4, zone),
deoptimization_literals_(8, zone),
inlined_function_count_(0),
scope_(info->scope()),
status_(UNUSED),
translations_(zone),
deferred_(8),
deferred_(8, zone),
osr_pc_offset_(-1),
last_lazy_deopt_pc_(0),
safepoints_(zone),
zone_(zone),
resolver_(this),
expected_safepoint_kind_(Safepoint::kSimple),
zone_(zone) {
expected_safepoint_kind_(Safepoint::kSimple) {
PopulateDeoptimizationLiteralsWithInlinedFunctions();
}
@ -169,7 +169,7 @@ class LCodeGen BASE_EMBEDDED {
void Abort(const char* format, ...);
void Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); }
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); }
// Code generation passes. Returns true if code generation should
// continue.
@ -349,13 +349,13 @@ class LCodeGen BASE_EMBEDDED {
// itself is emitted at the end of the generated code.
SafepointTableBuilder safepoints_;
Zone* zone_;
// Compiler from a set of parallel moves to a sequential list of moves.
LGapResolver resolver_;
Safepoint::Kind expected_safepoint_kind_;
Zone* zone_;
class PushSafepointRegistersScope BASE_EMBEDDED {
public:
explicit PushSafepointRegistersScope(LCodeGen* codegen)

View File

@ -37,7 +37,7 @@ namespace internal {
LGapResolver::LGapResolver(LCodeGen* owner)
: cgen_(owner),
moves_(32),
moves_(32, owner->zone()),
source_uses_(),
destination_uses_(),
spilled_register_(-1) {}
@ -157,7 +157,7 @@ void LGapResolver::AddMove(LMoveOperands move) {
LOperand* destination = move.destination();
if (destination->IsRegister()) ++destination_uses_[destination->index()];
moves_.Add(move);
moves_.Add(move, cgen_->zone());
}

View File

@ -376,9 +376,9 @@ int LChunk::GetNextSpillIndex(bool is_double) {
LOperand* LChunk::GetNextSpillSlot(bool is_double) {
int index = GetNextSpillIndex(is_double);
if (is_double) {
return LDoubleStackSlot::Create(index);
return LDoubleStackSlot::Create(index, zone());
} else {
return LStackSlot::Create(index);
return LStackSlot::Create(index, zone());
}
}
@ -474,23 +474,23 @@ void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block);
int index = -1;
if (instr->IsControl()) {
instructions_.Add(gap);
instructions_.Add(gap, zone());
index = instructions_.length();
instructions_.Add(instr);
instructions_.Add(instr, zone());
} else {
index = instructions_.length();
instructions_.Add(instr);
instructions_.Add(gap);
instructions_.Add(instr, zone());
instructions_.Add(gap, zone());
}
if (instr->HasPointerMap()) {
pointer_maps_.Add(instr->pointer_map());
pointer_maps_.Add(instr->pointer_map(), zone());
instr->pointer_map()->set_lithium_position(index);
}
}
LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) {
return LConstantOperand::Create(constant->id());
return LConstantOperand::Create(constant->id(), zone());
}
@ -529,7 +529,8 @@ int LChunk::NearestGapPos(int index) const {
void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to);
GetGapAt(index)->GetOrCreateParallelMove(
LGap::START, zone())->AddMove(from, to, zone());
}
@ -764,7 +765,7 @@ LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
ASSERT(!instr->HasPointerMap());
instr->set_pointer_map(new(zone()) LPointerMap(position_));
instr->set_pointer_map(new(zone()) LPointerMap(position_, zone()));
return instr;
}
@ -1545,7 +1546,7 @@ LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
ASSERT(instr->value()->representation().IsTagged());
LOperand* temp = TempRegister();
return new LIsStringAndBranch(UseRegister(instr->value()), temp);
return new(zone()) LIsStringAndBranch(UseRegister(instr->value()), temp);
}
@ -1571,7 +1572,7 @@ LInstruction* LChunkBuilder::DoStringCompareAndBranch(
LOperand* left = UseFixed(instr->left(), edx);
LOperand* right = UseFixed(instr->right(), eax);
LStringCompareAndBranch* result = new
LStringCompareAndBranch* result = new(zone())
LStringCompareAndBranch(context, left, right);
return MarkAsCall(result, instr);

View File

@ -327,8 +327,10 @@ class LGap: public LTemplateInstruction<0, 0, 0> {
LAST_INNER_POSITION = AFTER
};
LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
if (parallel_moves_[pos] == NULL) {
parallel_moves_[pos] = new(zone) LParallelMove(zone);
}
return parallel_moves_[pos];
}
@ -2307,9 +2309,9 @@ class LChunk: public ZoneObject {
: spill_slot_count_(0),
info_(info),
graph_(graph),
instructions_(32),
pointer_maps_(8),
inlined_closures_(1) { }
instructions_(32, graph->zone()),
pointer_maps_(8, graph->zone()),
inlined_closures_(1, graph->zone()) { }
void AddInstruction(LInstruction* instruction, HBasicBlock* block);
LConstantOperand* DefineConstantOperand(HConstant* constant);
@ -2354,9 +2356,11 @@ class LChunk: public ZoneObject {
}
void AddInlinedClosure(Handle<JSFunction> closure) {
inlined_closures_.Add(closure);
inlined_closures_.Add(closure, zone());
}
Zone* zone() const { return graph_->zone(); }
private:
int spill_slot_count_;
CompilationInfo* info_;
@ -2403,7 +2407,7 @@ class LChunkBuilder BASE_EMBEDDED {
LChunk* chunk() const { return chunk_; }
CompilationInfo* info() const { return info_; }
HGraph* graph() const { return graph_; }
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
bool is_unused() const { return status_ == UNUSED; }
bool is_building() const { return status_ == BUILDING; }

View File

@ -101,8 +101,10 @@ namespace internal {
RegExpMacroAssemblerIA32::RegExpMacroAssemblerIA32(
Mode mode,
int registers_to_save)
: masm_(new MacroAssembler(Isolate::Current(), NULL, kRegExpCodeSize)),
int registers_to_save,
Zone* zone)
: NativeRegExpMacroAssembler(zone),
masm_(new MacroAssembler(Isolate::Current(), NULL, kRegExpCodeSize)),
mode_(mode),
num_registers_(registers_to_save),
num_saved_registers_(registers_to_save),

View File

@ -44,7 +44,7 @@ class RegExpMacroAssemblerIA32: public RegExpMacroAssembler {
#else // V8_INTERPRETED_REGEXP
class RegExpMacroAssemblerIA32: public NativeRegExpMacroAssembler {
public:
RegExpMacroAssemblerIA32(Mode mode, int registers_to_save);
RegExpMacroAssemblerIA32(Mode mode, int registers_to_save, Zone* zone);
virtual ~RegExpMacroAssemblerIA32();
virtual int stack_limit_slack();
virtual void AdvanceCurrentPosition(int by);

View File

@ -41,11 +41,13 @@ static bool Match(void* key1, void* key2) {
}
Interface* Interface::Lookup(Handle<String> name) {
Interface* Interface::Lookup(Handle<String> name, Zone* zone) {
ASSERT(IsModule());
ZoneHashMap* map = Chase()->exports_;
if (map == NULL) return NULL;
ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false);
ZoneAllocationPolicy allocator(zone);
ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false,
allocator);
if (p == NULL) return NULL;
ASSERT(*static_cast<String**>(p->key) == *name);
ASSERT(p->value != NULL);
@ -69,7 +71,7 @@ int Nesting::current_ = 0;
void Interface::DoAdd(
void* name, uint32_t hash, Interface* interface, bool* ok) {
void* name, uint32_t hash, Interface* interface, Zone* zone, bool* ok) {
MakeModule(ok);
if (!*ok) return;
@ -85,9 +87,13 @@ void Interface::DoAdd(
#endif
ZoneHashMap** map = &Chase()->exports_;
if (*map == NULL) *map = new ZoneHashMap(Match, 8);
ZoneAllocationPolicy allocator(zone);
ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen());
if (*map == NULL)
*map = new ZoneHashMap(Match, ZoneHashMap::kDefaultHashMapCapacity,
allocator);
ZoneHashMap::Entry* p = (*map)->Lookup(name, hash, !IsFrozen(), allocator);
if (p == NULL) {
// This didn't have name but was frozen already, that's an error.
*ok = false;
@ -97,7 +103,7 @@ void Interface::DoAdd(
#ifdef DEBUG
Nesting nested;
#endif
static_cast<Interface*>(p->value)->Unify(interface, ok);
static_cast<Interface*>(p->value)->Unify(interface, zone, ok);
}
#ifdef DEBUG
@ -110,9 +116,9 @@ void Interface::DoAdd(
}
void Interface::Unify(Interface* that, bool* ok) {
if (this->forward_) return this->Chase()->Unify(that, ok);
if (that->forward_) return this->Unify(that->Chase(), ok);
void Interface::Unify(Interface* that, Zone* zone, bool* ok) {
if (this->forward_) return this->Chase()->Unify(that, zone, ok);
if (that->forward_) return this->Unify(that->Chase(), zone, ok);
ASSERT(this->forward_ == NULL);
ASSERT(that->forward_ == NULL);
@ -134,9 +140,9 @@ void Interface::Unify(Interface* that, bool* ok) {
// Merge the smaller interface into the larger, for performance.
if (this->exports_ != NULL && (that->exports_ == NULL ||
this->exports_->occupancy() >= that->exports_->occupancy())) {
this->DoUnify(that, ok);
this->DoUnify(that, ok, zone);
} else {
that->DoUnify(this, ok);
that->DoUnify(this, ok, zone);
}
#ifdef DEBUG
@ -151,7 +157,7 @@ void Interface::Unify(Interface* that, bool* ok) {
}
void Interface::DoUnify(Interface* that, bool* ok) {
void Interface::DoUnify(Interface* that, bool* ok, Zone* zone) {
ASSERT(this->forward_ == NULL);
ASSERT(that->forward_ == NULL);
ASSERT(!this->IsValue());
@ -166,7 +172,7 @@ void Interface::DoUnify(Interface* that, bool* ok) {
ZoneHashMap* map = that->exports_;
if (map != NULL) {
for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), ok);
this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), zone, ok);
if (!*ok) return;
}
}

View File

@ -53,12 +53,12 @@ class Interface : public ZoneObject {
return &value_interface;
}
static Interface* NewUnknown() {
return new Interface(NONE);
static Interface* NewUnknown(Zone* zone) {
return new(zone) Interface(NONE);
}
static Interface* NewModule() {
return new Interface(MODULE);
static Interface* NewModule(Zone* zone) {
return new(zone) Interface(MODULE);
}
// ---------------------------------------------------------------------------
@ -66,13 +66,13 @@ class Interface : public ZoneObject {
// Add a name to the list of exports. If it already exists, unify with
// interface, otherwise insert unless this is closed.
void Add(Handle<String> name, Interface* interface, bool* ok) {
DoAdd(name.location(), name->Hash(), interface, ok);
void Add(Handle<String> name, Interface* interface, Zone* zone, bool* ok) {
DoAdd(name.location(), name->Hash(), interface, zone, ok);
}
// Unify with another interface. If successful, both interface objects will
// represent the same type, and changes to one are reflected in the other.
void Unify(Interface* that, bool* ok);
void Unify(Interface* that, Zone* zone, bool* ok);
// Determine this interface to be a value interface.
void MakeValue(bool* ok) {
@ -116,7 +116,7 @@ class Interface : public ZoneObject {
Handle<JSModule> Instance() { return Chase()->instance_; }
// Look up an exported name. Returns NULL if not (yet) defined.
Interface* Lookup(Handle<String> name);
Interface* Lookup(Handle<String> name, Zone* zone);
// ---------------------------------------------------------------------------
// Iterators.
@ -187,8 +187,9 @@ class Interface : public ZoneObject {
return result;
}
void DoAdd(void* name, uint32_t hash, Interface* interface, bool* ok);
void DoUnify(Interface* that, bool* ok);
void DoAdd(void* name, uint32_t hash, Interface* interface, Zone* zone,
bool* ok);
void DoUnify(Interface* that, bool* ok, Zone* zone);
};
} } // namespace v8::internal

View File

@ -1778,7 +1778,7 @@ bool Isolate::Init(Deserializer* des) {
global_handles_ = new GlobalHandles(this);
bootstrapper_ = new Bootstrapper();
handle_scope_implementer_ = new HandleScopeImplementer(this);
stub_cache_ = new StubCache(this);
stub_cache_ = new StubCache(this, zone());
regexp_stack_ = new RegExpStack();
regexp_stack_->isolate_ = this;
date_cache_ = new DateCache();

View File

@ -1394,7 +1394,6 @@ class PostponeInterruptsScope BASE_EMBEDDED {
#define HEAP (v8::internal::Isolate::Current()->heap())
#define FACTORY (v8::internal::Isolate::Current()->factory())
#define ISOLATE (v8::internal::Isolate::Current())
#define ZONE (v8::internal::Isolate::Current()->zone())
#define LOGGER (v8::internal::Isolate::Current()->logger())

View File

@ -43,15 +43,15 @@ namespace internal {
template <bool seq_ascii>
class JsonParser BASE_EMBEDDED {
public:
static Handle<Object> Parse(Handle<String> source) {
return JsonParser().ParseJson(source);
static Handle<Object> Parse(Handle<String> source, Zone* zone) {
return JsonParser().ParseJson(source, zone);
}
static const int kEndOfString = -1;
private:
// Parse a string containing a single JSON value.
Handle<Object> ParseJson(Handle<String> source);
Handle<Object> ParseJson(Handle<String> source, Zone* zone);
inline void Advance() {
position_++;
@ -149,6 +149,7 @@ class JsonParser BASE_EMBEDDED {
}
inline Isolate* isolate() { return isolate_; }
inline Zone* zone() const { return zone_; }
static const int kInitialSpecialStringLength = 1024;
@ -161,11 +162,14 @@ class JsonParser BASE_EMBEDDED {
Isolate* isolate_;
uc32 c0_;
int position_;
Zone* zone_;
};
template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJson(Handle<String> source) {
Handle<Object> JsonParser<seq_ascii>::ParseJson(Handle<String> source,
Zone* zone) {
isolate_ = source->map()->GetHeap()->isolate();
zone_ = zone;
FlattenString(source);
source_ = source;
source_length_ = source_->length();
@ -323,7 +327,7 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
template <bool seq_ascii>
Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() {
ZoneScope zone_scope(isolate(), DELETE_ON_EXIT);
ZoneList<Handle<Object> > elements(4);
ZoneList<Handle<Object> > elements(4, zone());
ASSERT_EQ(c0_, '[');
AdvanceSkipWhitespace();
@ -331,7 +335,7 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() {
do {
Handle<Object> element = ParseJsonValue();
if (element.is_null()) return ReportUnexpectedCharacter();
elements.Add(element);
elements.Add(element, zone());
} while (MatchSkipWhiteSpace(','));
if (c0_ != ']') {
return ReportUnexpectedCharacter();

View File

@ -820,24 +820,24 @@ Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> jsregexp,
// the event that code generation is requested for an identical trace.
void RegExpTree::AppendToText(RegExpText* text) {
void RegExpTree::AppendToText(RegExpText* text, Zone* zone) {
UNREACHABLE();
}
void RegExpAtom::AppendToText(RegExpText* text) {
text->AddElement(TextElement::Atom(this));
void RegExpAtom::AppendToText(RegExpText* text, Zone* zone) {
text->AddElement(TextElement::Atom(this), zone);
}
void RegExpCharacterClass::AppendToText(RegExpText* text) {
text->AddElement(TextElement::CharClass(this));
void RegExpCharacterClass::AppendToText(RegExpText* text, Zone* zone) {
text->AddElement(TextElement::CharClass(this), zone);
}
void RegExpText::AppendToText(RegExpText* text) {
void RegExpText::AppendToText(RegExpText* text, Zone* zone) {
for (int i = 0; i < elements()->length(); i++)
text->AddElement(elements()->at(i));
text->AddElement(elements()->at(i), zone);
}
@ -868,8 +868,8 @@ int TextElement::length() {
DispatchTable* ChoiceNode::GetTable(bool ignore_case) {
if (table_ == NULL) {
table_ = new DispatchTable();
DispatchTableConstructor cons(table_, ignore_case);
table_ = new(zone()) DispatchTable(zone());
DispatchTableConstructor cons(table_, ignore_case, zone());
cons.BuildTable(this);
}
return table_;
@ -966,7 +966,7 @@ class RegExpCompiler {
current_expansion_factor_ = value;
}
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
static const int kNoRegister = -1;
@ -1014,7 +1014,7 @@ RegExpCompiler::RegExpCompiler(int capture_count, bool ignore_case, bool ascii,
current_expansion_factor_(1),
frequency_collator_(),
zone_(zone) {
accept_ = new EndNode(EndNode::ACCEPT, zone);
accept_ = new(zone) EndNode(EndNode::ACCEPT, zone);
ASSERT(next_register_ - 1 <= RegExpMacroAssembler::kMaxRegister);
}
@ -1110,7 +1110,8 @@ bool Trace::GetStoredPosition(int reg, int* cp_offset) {
}
int Trace::FindAffectedRegisters(OutSet* affected_registers) {
int Trace::FindAffectedRegisters(OutSet* affected_registers,
Zone* zone) {
int max_register = RegExpCompiler::kNoRegister;
for (DeferredAction* action = actions_;
action != NULL;
@ -1118,10 +1119,10 @@ int Trace::FindAffectedRegisters(OutSet* affected_registers) {
if (action->type() == ActionNode::CLEAR_CAPTURES) {
Interval range = static_cast<DeferredClearCaptures*>(action)->range();
for (int i = range.from(); i <= range.to(); i++)
affected_registers->Set(i);
affected_registers->Set(i, zone);
if (range.to() > max_register) max_register = range.to();
} else {
affected_registers->Set(action->reg());
affected_registers->Set(action->reg(), zone);
if (action->reg() > max_register) max_register = action->reg();
}
}
@ -1150,7 +1151,8 @@ void Trace::PerformDeferredActions(RegExpMacroAssembler* assembler,
int max_register,
OutSet& affected_registers,
OutSet* registers_to_pop,
OutSet* registers_to_clear) {
OutSet* registers_to_clear,
Zone* zone) {
// The "+1" is to avoid a push_limit of zero if stack_limit_slack() is 1.
const int push_limit = (assembler->stack_limit_slack() + 1) / 2;
@ -1256,9 +1258,9 @@ void Trace::PerformDeferredActions(RegExpMacroAssembler* assembler,
}
assembler->PushRegister(reg, stack_check);
registers_to_pop->Set(reg);
registers_to_pop->Set(reg, zone);
} else if (undo_action == CLEAR) {
registers_to_clear->Set(reg);
registers_to_clear->Set(reg, zone);
}
// Perform the chronologically last action (or accumulated increment)
// for the register.
@ -1304,14 +1306,16 @@ void Trace::Flush(RegExpCompiler* compiler, RegExpNode* successor) {
assembler->PushCurrentPosition();
}
int max_register = FindAffectedRegisters(&affected_registers);
int max_register = FindAffectedRegisters(&affected_registers,
compiler->zone());
OutSet registers_to_pop;
OutSet registers_to_clear;
PerformDeferredActions(assembler,
max_register,
affected_registers,
&registers_to_pop,
&registers_to_clear);
&registers_to_clear,
compiler->zone());
if (cp_offset_ != 0) {
assembler->AdvanceCurrentPosition(cp_offset_);
}
@ -1388,17 +1392,18 @@ void EndNode::Emit(RegExpCompiler* compiler, Trace* trace) {
}
void GuardedAlternative::AddGuard(Guard* guard) {
void GuardedAlternative::AddGuard(Guard* guard, Zone* zone) {
if (guards_ == NULL)
guards_ = new ZoneList<Guard*>(1);
guards_->Add(guard);
guards_ = new(zone) ZoneList<Guard*>(1, zone);
guards_->Add(guard, zone);
}
ActionNode* ActionNode::SetRegister(int reg,
int val,
RegExpNode* on_success) {
ActionNode* result = new ActionNode(SET_REGISTER, on_success);
ActionNode* result =
new(on_success->zone()) ActionNode(SET_REGISTER, on_success);
result->data_.u_store_register.reg = reg;
result->data_.u_store_register.value = val;
return result;
@ -1406,7 +1411,8 @@ ActionNode* ActionNode::SetRegister(int reg,
ActionNode* ActionNode::IncrementRegister(int reg, RegExpNode* on_success) {
ActionNode* result = new ActionNode(INCREMENT_REGISTER, on_success);
ActionNode* result =
new(on_success->zone()) ActionNode(INCREMENT_REGISTER, on_success);
result->data_.u_increment_register.reg = reg;
return result;
}
@ -1415,7 +1421,8 @@ ActionNode* ActionNode::IncrementRegister(int reg, RegExpNode* on_success) {
ActionNode* ActionNode::StorePosition(int reg,
bool is_capture,
RegExpNode* on_success) {
ActionNode* result = new ActionNode(STORE_POSITION, on_success);
ActionNode* result =
new(on_success->zone()) ActionNode(STORE_POSITION, on_success);
result->data_.u_position_register.reg = reg;
result->data_.u_position_register.is_capture = is_capture;
return result;
@ -1424,7 +1431,8 @@ ActionNode* ActionNode::StorePosition(int reg,
ActionNode* ActionNode::ClearCaptures(Interval range,
RegExpNode* on_success) {
ActionNode* result = new ActionNode(CLEAR_CAPTURES, on_success);
ActionNode* result =
new(on_success->zone()) ActionNode(CLEAR_CAPTURES, on_success);
result->data_.u_clear_captures.range_from = range.from();
result->data_.u_clear_captures.range_to = range.to();
return result;
@ -1434,7 +1442,8 @@ ActionNode* ActionNode::ClearCaptures(Interval range,
ActionNode* ActionNode::BeginSubmatch(int stack_reg,
int position_reg,
RegExpNode* on_success) {
ActionNode* result = new ActionNode(BEGIN_SUBMATCH, on_success);
ActionNode* result =
new(on_success->zone()) ActionNode(BEGIN_SUBMATCH, on_success);
result->data_.u_submatch.stack_pointer_register = stack_reg;
result->data_.u_submatch.current_position_register = position_reg;
return result;
@ -1446,7 +1455,8 @@ ActionNode* ActionNode::PositiveSubmatchSuccess(int stack_reg,
int clear_register_count,
int clear_register_from,
RegExpNode* on_success) {
ActionNode* result = new ActionNode(POSITIVE_SUBMATCH_SUCCESS, on_success);
ActionNode* result =
new(on_success->zone()) ActionNode(POSITIVE_SUBMATCH_SUCCESS, on_success);
result->data_.u_submatch.stack_pointer_register = stack_reg;
result->data_.u_submatch.current_position_register = position_reg;
result->data_.u_submatch.clear_register_count = clear_register_count;
@ -1459,7 +1469,8 @@ ActionNode* ActionNode::EmptyMatchCheck(int start_register,
int repetition_register,
int repetition_limit,
RegExpNode* on_success) {
ActionNode* result = new ActionNode(EMPTY_MATCH_CHECK, on_success);
ActionNode* result =
new(on_success->zone()) ActionNode(EMPTY_MATCH_CHECK, on_success);
result->data_.u_empty_match_check.start_register = start_register;
result->data_.u_empty_match_check.repetition_register = repetition_register;
result->data_.u_empty_match_check.repetition_limit = repetition_limit;
@ -2039,8 +2050,9 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler,
Label* on_failure,
int cp_offset,
bool check_offset,
bool preloaded) {
ZoneList<CharacterRange>* ranges = cc->ranges();
bool preloaded,
Zone* zone) {
ZoneList<CharacterRange>* ranges = cc->ranges(zone);
if (!CharacterRange::IsCanonical(ranges)) {
CharacterRange::Canonicalize(ranges);
}
@ -2099,7 +2111,7 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler,
macro_assembler->LoadCurrentCharacter(cp_offset, on_failure, check_offset);
}
if (cc->is_standard() &&
if (cc->is_standard(zone) &&
macro_assembler->CheckSpecialCharacterClass(cc->standard_type(),
on_failure)) {
return;
@ -2112,7 +2124,8 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler,
// entry at zero which goes to the failure label, but if there
// was already one there we fall through for success on that entry.
// Subsequent entries have alternating meaning (success/failure).
ZoneList<int>* range_boundaries = new ZoneList<int>(last_valid_range);
ZoneList<int>* range_boundaries =
new(zone) ZoneList<int>(last_valid_range, zone);
bool zeroth_entry_is_failure = !cc->is_negated();
@ -2122,9 +2135,9 @@ static void EmitCharClass(RegExpMacroAssembler* macro_assembler,
ASSERT_EQ(i, 0);
zeroth_entry_is_failure = !zeroth_entry_is_failure;
} else {
range_boundaries->Add(range.from());
range_boundaries->Add(range.from(), zone);
}
range_boundaries->Add(range.to() + 1);
range_boundaries->Add(range.to() + 1, zone);
}
int end_index = range_boundaries->length() - 1;
if (range_boundaries->at(end_index) > max_char) {
@ -2522,7 +2535,7 @@ void TextNode::GetQuickCheckDetails(QuickCheckDetails* details,
QuickCheckDetails::Position* pos =
details->positions(characters_filled_in);
RegExpCharacterClass* tree = elm.data.u_char_class;
ZoneList<CharacterRange>* ranges = tree->ranges();
ZoneList<CharacterRange>* ranges = tree->ranges(zone());
if (tree->is_negated()) {
// A quick check uses multi-character mask and compare. There is no
// useful way to incorporate a negative char class into this scheme
@ -2707,7 +2720,7 @@ RegExpNode* TextNode::FilterASCII(int depth) {
} else {
ASSERT(elm.type == TextElement::CHAR_CLASS);
RegExpCharacterClass* cc = elm.data.u_char_class;
ZoneList<CharacterRange>* ranges = cc->ranges();
ZoneList<CharacterRange>* ranges = cc->ranges(zone());
if (!CharacterRange::IsCanonical(ranges)) {
CharacterRange::Canonicalize(ranges);
}
@ -2784,13 +2797,13 @@ RegExpNode* ChoiceNode::FilterASCII(int depth) {
// Only some of the nodes survived the filtering. We need to rebuild the
// alternatives list.
ZoneList<GuardedAlternative>* new_alternatives =
new ZoneList<GuardedAlternative>(surviving);
new(zone()) ZoneList<GuardedAlternative>(surviving, zone());
for (int i = 0; i < choice_count; i++) {
RegExpNode* replacement =
alternatives_->at(i).node()->FilterASCII(depth - 1);
if (replacement != NULL) {
alternatives_->at(i).set_node(replacement);
new_alternatives->Add(alternatives_->at(i));
new_alternatives->Add(alternatives_->at(i), zone());
}
}
alternatives_ = new_alternatives;
@ -2947,7 +2960,7 @@ void AssertionNode::EmitBoundaryCheck(RegExpCompiler* compiler, Trace* trace) {
EatsAtLeast(kMaxLookaheadForBoyerMoore, 0, not_at_start));
if (eats_at_least >= 1) {
BoyerMooreLookahead* bm =
new BoyerMooreLookahead(eats_at_least, compiler, zone());
new(zone()) BoyerMooreLookahead(eats_at_least, compiler, zone());
FillInBMInfo(0, 0, kFillInBMBudget, bm, not_at_start);
if (bm->at(0)->is_non_word()) next_is_word_character = Trace::FALSE;
if (bm->at(0)->is_word()) next_is_word_character = Trace::TRUE;
@ -3174,7 +3187,8 @@ void TextNode::TextEmitPass(RegExpCompiler* compiler,
backtrack,
cp_offset,
*checked_up_to < cp_offset,
preloaded);
preloaded,
zone());
UpdateBoundsCheck(cp_offset, checked_up_to);
}
}
@ -3295,11 +3309,11 @@ void TextNode::MakeCaseIndependent(bool is_ascii) {
RegExpCharacterClass* cc = elm.data.u_char_class;
// None of the standard character classes is different in the case
// independent case and it slows us down if we don't know that.
if (cc->is_standard()) continue;
ZoneList<CharacterRange>* ranges = cc->ranges();
if (cc->is_standard(zone())) continue;
ZoneList<CharacterRange>* ranges = cc->ranges(zone());
int range_count = ranges->length();
for (int j = 0; j < range_count; j++) {
ranges->at(j).AddCaseEquivalents(ranges, is_ascii);
ranges->at(j).AddCaseEquivalents(ranges, is_ascii, zone());
}
}
}
@ -3322,7 +3336,7 @@ RegExpNode* TextNode::GetSuccessorOfOmnivorousTextNode(
TextElement elm = elms_->at(0);
if (elm.type != TextElement::CHAR_CLASS) return NULL;
RegExpCharacterClass* node = elm.data.u_char_class;
ZoneList<CharacterRange>* ranges = node->ranges();
ZoneList<CharacterRange>* ranges = node->ranges(zone());
if (!CharacterRange::IsCanonical(ranges)) {
CharacterRange::Canonicalize(ranges);
}
@ -3444,13 +3458,13 @@ class AlternativeGeneration: public Malloced {
// size then it is on the stack, otherwise the excess is on the heap.
class AlternativeGenerationList {
public:
explicit AlternativeGenerationList(int count)
: alt_gens_(count) {
AlternativeGenerationList(int count, Zone* zone)
: alt_gens_(count, zone) {
for (int i = 0; i < count && i < kAFew; i++) {
alt_gens_.Add(a_few_alt_gens_ + i);
alt_gens_.Add(a_few_alt_gens_ + i, zone);
}
for (int i = kAFew; i < count; i++) {
alt_gens_.Add(new AlternativeGeneration());
alt_gens_.Add(new AlternativeGeneration(), zone);
}
}
~AlternativeGenerationList() {
@ -3536,9 +3550,9 @@ BoyerMooreLookahead::BoyerMooreLookahead(
} else {
max_char_ = String::kMaxUtf16CodeUnit;
}
bitmaps_ = new ZoneList<BoyerMoorePositionInfo*>(length);
bitmaps_ = new(zone) ZoneList<BoyerMoorePositionInfo*>(length, zone);
for (int i = 0; i < length; i++) {
bitmaps_->Add(new BoyerMoorePositionInfo(zone));
bitmaps_->Add(new(zone) BoyerMoorePositionInfo(zone), zone);
}
}
@ -3884,7 +3898,9 @@ void ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) {
EatsAtLeast(kMaxLookaheadForBoyerMoore, 0, not_at_start));
if (eats_at_least >= 1) {
BoyerMooreLookahead* bm =
new BoyerMooreLookahead(eats_at_least, compiler, zone());
new(zone()) BoyerMooreLookahead(eats_at_least,
compiler,
zone());
GuardedAlternative alt0 = alternatives_->at(0);
alt0.node()->FillInBMInfo(0, 0, kFillInBMBudget, bm, not_at_start);
skip_was_emitted = bm->EmitSkipInstructions(macro_assembler);
@ -3906,7 +3922,7 @@ void ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) {
(current_trace->characters_preloaded() == preload_characters);
bool preload_has_checked_bounds = preload_is_current;
AlternativeGenerationList alt_gens(choice_count);
AlternativeGenerationList alt_gens(choice_count, zone());
// For now we just call all choices one after the other. The idea ultimately
// is to use the Dispatch table to try only the relevant ones.
@ -4386,6 +4402,7 @@ void DotPrinter::VisitChoice(ChoiceNode* that) {
void DotPrinter::VisitText(TextNode* that) {
Zone* zone = that->zone();
stream()->Add(" n%p [label=\"", that);
for (int i = 0; i < that->elements()->length(); i++) {
if (i > 0) stream()->Add(" ");
@ -4400,8 +4417,8 @@ void DotPrinter::VisitText(TextNode* that) {
stream()->Add("[");
if (node->is_negated())
stream()->Add("^");
for (int j = 0; j < node->ranges()->length(); j++) {
CharacterRange range = node->ranges()->at(j);
for (int j = 0; j < node->ranges(zone)->length(); j++) {
CharacterRange range = node->ranges(zone)->at(j);
stream()->Add("%k-%k", range.from(), range.to());
}
stream()->Add("]");
@ -4559,15 +4576,16 @@ void RegExpEngine::DotPrint(const char* label,
RegExpNode* RegExpAtom::ToNode(RegExpCompiler* compiler,
RegExpNode* on_success) {
ZoneList<TextElement>* elms = new ZoneList<TextElement>(1);
elms->Add(TextElement::Atom(this));
return new TextNode(elms, on_success);
ZoneList<TextElement>* elms =
new(compiler->zone()) ZoneList<TextElement>(1, compiler->zone());
elms->Add(TextElement::Atom(this), compiler->zone());
return new(compiler->zone()) TextNode(elms, on_success);
}
RegExpNode* RegExpText::ToNode(RegExpCompiler* compiler,
RegExpNode* on_success) {
return new TextNode(elements(), on_success);
return new(compiler->zone()) TextNode(elements(), on_success);
}
@ -4621,7 +4639,7 @@ static bool CompareRanges(ZoneList<CharacterRange>* ranges,
}
bool RegExpCharacterClass::is_standard() {
bool RegExpCharacterClass::is_standard(Zone* zone) {
// TODO(lrn): Remove need for this function, by not throwing away information
// along the way.
if (is_negated_) {
@ -4630,31 +4648,31 @@ bool RegExpCharacterClass::is_standard() {
if (set_.is_standard()) {
return true;
}
if (CompareRanges(set_.ranges(), kSpaceRanges, kSpaceRangeCount)) {
if (CompareRanges(set_.ranges(zone), kSpaceRanges, kSpaceRangeCount)) {
set_.set_standard_set_type('s');
return true;
}
if (CompareInverseRanges(set_.ranges(), kSpaceRanges, kSpaceRangeCount)) {
if (CompareInverseRanges(set_.ranges(zone), kSpaceRanges, kSpaceRangeCount)) {
set_.set_standard_set_type('S');
return true;
}
if (CompareInverseRanges(set_.ranges(),
if (CompareInverseRanges(set_.ranges(zone),
kLineTerminatorRanges,
kLineTerminatorRangeCount)) {
set_.set_standard_set_type('.');
return true;
}
if (CompareRanges(set_.ranges(),
if (CompareRanges(set_.ranges(zone),
kLineTerminatorRanges,
kLineTerminatorRangeCount)) {
set_.set_standard_set_type('n');
return true;
}
if (CompareRanges(set_.ranges(), kWordRanges, kWordRangeCount)) {
if (CompareRanges(set_.ranges(zone), kWordRanges, kWordRangeCount)) {
set_.set_standard_set_type('w');
return true;
}
if (CompareInverseRanges(set_.ranges(), kWordRanges, kWordRangeCount)) {
if (CompareInverseRanges(set_.ranges(zone), kWordRanges, kWordRangeCount)) {
set_.set_standard_set_type('W');
return true;
}
@ -4664,7 +4682,7 @@ bool RegExpCharacterClass::is_standard() {
RegExpNode* RegExpCharacterClass::ToNode(RegExpCompiler* compiler,
RegExpNode* on_success) {
return new TextNode(this, on_success);
return new(compiler->zone()) TextNode(this, on_success);
}
@ -4672,7 +4690,8 @@ RegExpNode* RegExpDisjunction::ToNode(RegExpCompiler* compiler,
RegExpNode* on_success) {
ZoneList<RegExpTree*>* alternatives = this->alternatives();
int length = alternatives->length();
ChoiceNode* result = new ChoiceNode(length, compiler->zone());
ChoiceNode* result =
new(compiler->zone()) ChoiceNode(length, compiler->zone());
for (int i = 0; i < length; i++) {
GuardedAlternative alternative(alternatives->at(i)->ToNode(compiler,
on_success));
@ -4765,6 +4784,8 @@ RegExpNode* RegExpQuantifier::ToNode(int min,
int body_start_reg = RegExpCompiler::kNoRegister;
Interval capture_registers = body->CaptureRegisters();
bool needs_capture_clearing = !capture_registers.is_empty();
Zone* zone = compiler->zone();
if (body_can_be_empty) {
body_start_reg = compiler->AllocateRegister();
} else if (FLAG_regexp_optimization && !needs_capture_clearing) {
@ -4795,7 +4816,7 @@ RegExpNode* RegExpQuantifier::ToNode(int min,
// Unroll the optional matches up to max.
RegExpNode* answer = on_success;
for (int i = 0; i < max; i++) {
ChoiceNode* alternation = new ChoiceNode(2, compiler->zone());
ChoiceNode* alternation = new(zone) ChoiceNode(2, zone);
if (is_greedy) {
alternation->AddAlternative(
GuardedAlternative(body->ToNode(compiler, answer)));
@ -4818,8 +4839,8 @@ RegExpNode* RegExpQuantifier::ToNode(int min,
int reg_ctr = needs_counter
? compiler->AllocateRegister()
: RegExpCompiler::kNoRegister;
LoopChoiceNode* center = new LoopChoiceNode(body->min_match() == 0,
compiler->zone());
LoopChoiceNode* center = new(zone) LoopChoiceNode(body->min_match() == 0,
zone);
if (not_at_start) center->set_not_at_start();
RegExpNode* loop_return = needs_counter
? static_cast<RegExpNode*>(ActionNode::IncrementRegister(reg_ctr, center))
@ -4844,13 +4865,14 @@ RegExpNode* RegExpQuantifier::ToNode(int min,
}
GuardedAlternative body_alt(body_node);
if (has_max) {
Guard* body_guard = new Guard(reg_ctr, Guard::LT, max);
body_alt.AddGuard(body_guard);
Guard* body_guard =
new(zone) Guard(reg_ctr, Guard::LT, max);
body_alt.AddGuard(body_guard, zone);
}
GuardedAlternative rest_alt(on_success);
if (has_min) {
Guard* rest_guard = new Guard(reg_ctr, Guard::GEQ, min);
rest_alt.AddGuard(rest_guard);
Guard* rest_guard = new(compiler->zone()) Guard(reg_ctr, Guard::GEQ, min);
rest_alt.AddGuard(rest_guard, zone);
}
if (is_greedy) {
center->AddLoopAlternative(body_alt);
@ -4870,6 +4892,8 @@ RegExpNode* RegExpQuantifier::ToNode(int min,
RegExpNode* RegExpAssertion::ToNode(RegExpCompiler* compiler,
RegExpNode* on_success) {
NodeInfo info;
Zone* zone = compiler->zone();
switch (type()) {
case START_OF_LINE:
return AssertionNode::AfterNewline(on_success);
@ -4888,13 +4912,13 @@ RegExpNode* RegExpAssertion::ToNode(RegExpCompiler* compiler,
int stack_pointer_register = compiler->AllocateRegister();
int position_register = compiler->AllocateRegister();
// The ChoiceNode to distinguish between a newline and end-of-input.
ChoiceNode* result = new ChoiceNode(2, compiler->zone());
ChoiceNode* result = new(zone) ChoiceNode(2, zone);
// Create a newline atom.
ZoneList<CharacterRange>* newline_ranges =
new ZoneList<CharacterRange>(3);
CharacterRange::AddClassEscape('n', newline_ranges);
RegExpCharacterClass* newline_atom = new RegExpCharacterClass('n');
TextNode* newline_matcher = new TextNode(
new(zone) ZoneList<CharacterRange>(3, zone);
CharacterRange::AddClassEscape('n', newline_ranges, zone);
RegExpCharacterClass* newline_atom = new(zone) RegExpCharacterClass('n');
TextNode* newline_matcher = new(zone) TextNode(
newline_atom,
ActionNode::PositiveSubmatchSuccess(stack_pointer_register,
position_register,
@ -4922,9 +4946,10 @@ RegExpNode* RegExpAssertion::ToNode(RegExpCompiler* compiler,
RegExpNode* RegExpBackReference::ToNode(RegExpCompiler* compiler,
RegExpNode* on_success) {
return new BackReferenceNode(RegExpCapture::StartRegister(index()),
RegExpCapture::EndRegister(index()),
on_success);
return new(compiler->zone())
BackReferenceNode(RegExpCapture::StartRegister(index()),
RegExpCapture::EndRegister(index()),
on_success);
}
@ -4969,18 +4994,20 @@ RegExpNode* RegExpLookahead::ToNode(RegExpCompiler* compiler,
// for a negative lookahead. The NegativeLookaheadChoiceNode is a special
// ChoiceNode that knows to ignore the first exit when calculating quick
// checks.
Zone* zone = compiler->zone();
GuardedAlternative body_alt(
body()->ToNode(
compiler,
success = new NegativeSubmatchSuccess(stack_pointer_register,
position_register,
register_count,
register_start,
compiler->zone())));
success = new(zone) NegativeSubmatchSuccess(stack_pointer_register,
position_register,
register_count,
register_start,
zone)));
ChoiceNode* choice_node =
new NegativeLookaheadChoiceNode(body_alt,
GuardedAlternative(on_success),
compiler->zone());
new(zone) NegativeLookaheadChoiceNode(body_alt,
GuardedAlternative(on_success),
zone);
return ActionNode::BeginSubmatch(stack_pointer_register,
position_register,
choice_node);
@ -5019,19 +5046,21 @@ RegExpNode* RegExpAlternative::ToNode(RegExpCompiler* compiler,
static void AddClass(const int* elmv,
int elmc,
ZoneList<CharacterRange>* ranges) {
ZoneList<CharacterRange>* ranges,
Zone* zone) {
elmc--;
ASSERT(elmv[elmc] == 0x10000);
for (int i = 0; i < elmc; i += 2) {
ASSERT(elmv[i] < elmv[i + 1]);
ranges->Add(CharacterRange(elmv[i], elmv[i + 1] - 1));
ranges->Add(CharacterRange(elmv[i], elmv[i + 1] - 1), zone);
}
}
static void AddClassNegated(const int *elmv,
int elmc,
ZoneList<CharacterRange>* ranges) {
ZoneList<CharacterRange>* ranges,
Zone* zone) {
elmc--;
ASSERT(elmv[elmc] == 0x10000);
ASSERT(elmv[0] != 0x0000);
@ -5040,51 +5069,54 @@ static void AddClassNegated(const int *elmv,
for (int i = 0; i < elmc; i += 2) {
ASSERT(last <= elmv[i] - 1);
ASSERT(elmv[i] < elmv[i + 1]);
ranges->Add(CharacterRange(last, elmv[i] - 1));
ranges->Add(CharacterRange(last, elmv[i] - 1), zone);
last = elmv[i + 1];
}
ranges->Add(CharacterRange(last, String::kMaxUtf16CodeUnit));
ranges->Add(CharacterRange(last, String::kMaxUtf16CodeUnit), zone);
}
void CharacterRange::AddClassEscape(uc16 type,
ZoneList<CharacterRange>* ranges) {
ZoneList<CharacterRange>* ranges,
Zone* zone) {
switch (type) {
case 's':
AddClass(kSpaceRanges, kSpaceRangeCount, ranges);
AddClass(kSpaceRanges, kSpaceRangeCount, ranges, zone);
break;
case 'S':
AddClassNegated(kSpaceRanges, kSpaceRangeCount, ranges);
AddClassNegated(kSpaceRanges, kSpaceRangeCount, ranges, zone);
break;
case 'w':
AddClass(kWordRanges, kWordRangeCount, ranges);
AddClass(kWordRanges, kWordRangeCount, ranges, zone);
break;
case 'W':
AddClassNegated(kWordRanges, kWordRangeCount, ranges);
AddClassNegated(kWordRanges, kWordRangeCount, ranges, zone);
break;
case 'd':
AddClass(kDigitRanges, kDigitRangeCount, ranges);
AddClass(kDigitRanges, kDigitRangeCount, ranges, zone);
break;
case 'D':
AddClassNegated(kDigitRanges, kDigitRangeCount, ranges);
AddClassNegated(kDigitRanges, kDigitRangeCount, ranges, zone);
break;
case '.':
AddClassNegated(kLineTerminatorRanges,
kLineTerminatorRangeCount,
ranges);
ranges,
zone);
break;
// This is not a character range as defined by the spec but a
// convenient shorthand for a character class that matches any
// character.
case '*':
ranges->Add(CharacterRange::Everything());
ranges->Add(CharacterRange::Everything(), zone);
break;
// This is the set of characters matched by the $ and ^ symbols
// in multiline mode.
case 'n':
AddClass(kLineTerminatorRanges,
kLineTerminatorRangeCount,
ranges);
ranges,
zone);
break;
default:
UNREACHABLE();
@ -5100,9 +5132,11 @@ Vector<const int> CharacterRange::GetWordBounds() {
class CharacterRangeSplitter {
public:
CharacterRangeSplitter(ZoneList<CharacterRange>** included,
ZoneList<CharacterRange>** excluded)
ZoneList<CharacterRange>** excluded,
Zone* zone)
: included_(included),
excluded_(excluded) { }
excluded_(excluded),
zone_(zone) { }
void Call(uc16 from, DispatchTable::Entry entry);
static const int kInBase = 0;
@ -5111,6 +5145,7 @@ class CharacterRangeSplitter {
private:
ZoneList<CharacterRange>** included_;
ZoneList<CharacterRange>** excluded_;
Zone* zone_;
};
@ -5119,31 +5154,33 @@ void CharacterRangeSplitter::Call(uc16 from, DispatchTable::Entry entry) {
ZoneList<CharacterRange>** target = entry.out_set()->Get(kInOverlay)
? included_
: excluded_;
if (*target == NULL) *target = new ZoneList<CharacterRange>(2);
(*target)->Add(CharacterRange(entry.from(), entry.to()));
if (*target == NULL) *target = new(zone_) ZoneList<CharacterRange>(2, zone_);
(*target)->Add(CharacterRange(entry.from(), entry.to()), zone_);
}
void CharacterRange::Split(ZoneList<CharacterRange>* base,
Vector<const int> overlay,
ZoneList<CharacterRange>** included,
ZoneList<CharacterRange>** excluded) {
ZoneList<CharacterRange>** excluded,
Zone* zone) {
ASSERT_EQ(NULL, *included);
ASSERT_EQ(NULL, *excluded);
DispatchTable table;
DispatchTable table(zone);
for (int i = 0; i < base->length(); i++)
table.AddRange(base->at(i), CharacterRangeSplitter::kInBase);
table.AddRange(base->at(i), CharacterRangeSplitter::kInBase, zone);
for (int i = 0; i < overlay.length(); i += 2) {
table.AddRange(CharacterRange(overlay[i], overlay[i + 1] - 1),
CharacterRangeSplitter::kInOverlay);
CharacterRangeSplitter::kInOverlay, zone);
}
CharacterRangeSplitter callback(included, excluded);
CharacterRangeSplitter callback(included, excluded, zone);
table.ForEach(&callback);
}
void CharacterRange::AddCaseEquivalents(ZoneList<CharacterRange>* ranges,
bool is_ascii) {
bool is_ascii,
Zone* zone) {
Isolate* isolate = Isolate::Current();
uc16 bottom = from();
uc16 top = to();
@ -5158,7 +5195,7 @@ void CharacterRange::AddCaseEquivalents(ZoneList<CharacterRange>* ranges,
for (int i = 0; i < length; i++) {
uc32 chr = chars[i];
if (chr != bottom) {
ranges->Add(CharacterRange::Singleton(chars[i]));
ranges->Add(CharacterRange::Singleton(chars[i]), zone);
}
}
} else {
@ -5198,7 +5235,7 @@ void CharacterRange::AddCaseEquivalents(ZoneList<CharacterRange>* ranges,
uc16 range_from = c - (block_end - pos);
uc16 range_to = c - (block_end - end);
if (!(bottom <= range_from && range_to <= top)) {
ranges->Add(CharacterRange(range_from, range_to));
ranges->Add(CharacterRange(range_from, range_to), zone);
}
}
pos = end + 1;
@ -5221,10 +5258,10 @@ bool CharacterRange::IsCanonical(ZoneList<CharacterRange>* ranges) {
}
ZoneList<CharacterRange>* CharacterSet::ranges() {
ZoneList<CharacterRange>* CharacterSet::ranges(Zone* zone) {
if (ranges_ == NULL) {
ranges_ = new ZoneList<CharacterRange>(2);
CharacterRange::AddClassEscape(standard_set_type_, ranges_);
ranges_ = new(zone) ZoneList<CharacterRange>(2, zone);
CharacterRange::AddClassEscape(standard_set_type_, ranges_, zone);
}
return ranges_;
}
@ -5353,7 +5390,8 @@ void CharacterRange::Canonicalize(ZoneList<CharacterRange>* character_ranges) {
void CharacterRange::Negate(ZoneList<CharacterRange>* ranges,
ZoneList<CharacterRange>* negated_ranges) {
ZoneList<CharacterRange>* negated_ranges,
Zone* zone) {
ASSERT(CharacterRange::IsCanonical(ranges));
ASSERT_EQ(0, negated_ranges->length());
int range_count = ranges->length();
@ -5365,12 +5403,13 @@ void CharacterRange::Negate(ZoneList<CharacterRange>* ranges,
}
while (i < range_count) {
CharacterRange range = ranges->at(i);
negated_ranges->Add(CharacterRange(from + 1, range.from() - 1));
negated_ranges->Add(CharacterRange(from + 1, range.from() - 1), zone);
from = range.to();
i++;
}
if (from < String::kMaxUtf16CodeUnit) {
negated_ranges->Add(CharacterRange(from + 1, String::kMaxUtf16CodeUnit));
negated_ranges->Add(CharacterRange(from + 1, String::kMaxUtf16CodeUnit),
zone);
}
}
@ -5379,33 +5418,33 @@ void CharacterRange::Negate(ZoneList<CharacterRange>* ranges,
// Splay tree
OutSet* OutSet::Extend(unsigned value) {
OutSet* OutSet::Extend(unsigned value, Zone* zone) {
if (Get(value))
return this;
if (successors() != NULL) {
for (int i = 0; i < successors()->length(); i++) {
OutSet* successor = successors()->at(i);
if (successors(zone) != NULL) {
for (int i = 0; i < successors(zone)->length(); i++) {
OutSet* successor = successors(zone)->at(i);
if (successor->Get(value))
return successor;
}
} else {
successors_ = new ZoneList<OutSet*>(2);
successors_ = new(zone) ZoneList<OutSet*>(2, zone);
}
OutSet* result = new OutSet(first_, remaining_);
result->Set(value);
successors()->Add(result);
OutSet* result = new(zone) OutSet(first_, remaining_);
result->Set(value, zone);
successors(zone)->Add(result, zone);
return result;
}
void OutSet::Set(unsigned value) {
void OutSet::Set(unsigned value, Zone *zone) {
if (value < kFirstLimit) {
first_ |= (1 << value);
} else {
if (remaining_ == NULL)
remaining_ = new ZoneList<unsigned>(1);
remaining_ = new(zone) ZoneList<unsigned>(1, zone);
if (remaining_->is_empty() || !remaining_->Contains(value))
remaining_->Add(value);
remaining_->Add(value, zone);
}
}
@ -5424,13 +5463,15 @@ bool OutSet::Get(unsigned value) {
const uc16 DispatchTable::Config::kNoKey = unibrow::Utf8::kBadChar;
void DispatchTable::AddRange(CharacterRange full_range, int value) {
void DispatchTable::AddRange(CharacterRange full_range, int value,
Zone* zone) {
CharacterRange current = full_range;
if (tree()->is_empty()) {
// If this is the first range we just insert into the table.
ZoneSplayTree<Config>::Locator loc;
ASSERT_RESULT(tree()->Insert(current.from(), &loc));
loc.set_value(Entry(current.from(), current.to(), empty()->Extend(value)));
loc.set_value(Entry(current.from(), current.to(),
empty()->Extend(value, zone)));
return;
}
// First see if there is a range to the left of this one that
@ -5473,7 +5514,7 @@ void DispatchTable::AddRange(CharacterRange full_range, int value) {
ASSERT_RESULT(tree()->Insert(current.from(), &ins));
ins.set_value(Entry(current.from(),
entry->from() - 1,
empty()->Extend(value)));
empty()->Extend(value, zone)));
current.set_from(entry->from());
}
ASSERT_EQ(current.from(), entry->from());
@ -5491,7 +5532,7 @@ void DispatchTable::AddRange(CharacterRange full_range, int value) {
// The overlapping range is now completely contained by the range
// we're adding so we can just update it and move the start point
// of the range we're adding just past it.
entry->AddValue(value);
entry->AddValue(value, zone);
// Bail out if the last interval ended at 0xFFFF since otherwise
// adding 1 will wrap around to 0.
if (entry->to() == String::kMaxUtf16CodeUnit)
@ -5504,7 +5545,7 @@ void DispatchTable::AddRange(CharacterRange full_range, int value) {
ASSERT_RESULT(tree()->Insert(current.from(), &ins));
ins.set_value(Entry(current.from(),
current.to(),
empty()->Extend(value)));
empty()->Extend(value, zone)));
break;
}
}
@ -5704,7 +5745,7 @@ void TextNode::FillInBMInfo(int initial_offset,
} else {
ASSERT(text.type == TextElement::CHAR_CLASS);
RegExpCharacterClass* char_class = text.data.u_char_class;
ZoneList<CharacterRange>* ranges = char_class->ranges();
ZoneList<CharacterRange>* ranges = char_class->ranges(zone());
if (char_class->is_negated()) {
bm->SetAll(offset);
} else {
@ -5824,7 +5865,7 @@ void DispatchTableConstructor::VisitText(TextNode* that) {
}
case TextElement::CHAR_CLASS: {
RegExpCharacterClass* tree = elm.data.u_char_class;
ZoneList<CharacterRange>* ranges = tree->ranges();
ZoneList<CharacterRange>* ranges = tree->ranges(that->zone());
if (tree->is_negated()) {
AddInverse(ranges);
} else {
@ -5888,7 +5929,7 @@ RegExpEngine::CompilationResult RegExpEngine::Compile(
RegExpQuantifier::ToNode(0,
RegExpTree::kInfinity,
false,
new RegExpCharacterClass('*'),
new(zone) RegExpCharacterClass('*'),
&compiler,
captured_body,
data->contains_anchor);
@ -5896,10 +5937,10 @@ RegExpEngine::CompilationResult RegExpEngine::Compile(
if (data->contains_anchor) {
// Unroll loop once, to take care of the case that might start
// at the start of input.
ChoiceNode* first_step_node = new ChoiceNode(2, zone);
ChoiceNode* first_step_node = new(zone) ChoiceNode(2, zone);
first_step_node->AddAlternative(GuardedAlternative(captured_body));
first_step_node->AddAlternative(GuardedAlternative(
new TextNode(new RegExpCharacterClass('*'), loop_node)));
new(zone) TextNode(new(zone) RegExpCharacterClass('*'), loop_node)));
node = first_step_node;
} else {
node = loop_node;
@ -5912,7 +5953,7 @@ RegExpEngine::CompilationResult RegExpEngine::Compile(
if (node != NULL) node = node->FilterASCII(RegExpCompiler::kMaxRecursion);
}
if (node == NULL) node = new EndNode(EndNode::BACKTRACK, zone);
if (node == NULL) node = new(zone) EndNode(EndNode::BACKTRACK, zone);
data->node = node;
Analysis analysis(ignore_case, is_ascii);
analysis.EnsureAnalyzed(node);
@ -5930,11 +5971,14 @@ RegExpEngine::CompilationResult RegExpEngine::Compile(
: NativeRegExpMacroAssembler::UC16;
#if V8_TARGET_ARCH_IA32
RegExpMacroAssemblerIA32 macro_assembler(mode, (data->capture_count + 1) * 2);
RegExpMacroAssemblerIA32 macro_assembler(mode, (data->capture_count + 1) * 2,
zone);
#elif V8_TARGET_ARCH_X64
RegExpMacroAssemblerX64 macro_assembler(mode, (data->capture_count + 1) * 2);
RegExpMacroAssemblerX64 macro_assembler(mode, (data->capture_count + 1) * 2,
zone);
#elif V8_TARGET_ARCH_ARM
RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2);
RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2,
zone);
#elif V8_TARGET_ARCH_MIPS
RegExpMacroAssemblerMIPS macro_assembler(mode, (data->capture_count + 1) * 2);
#endif

View File

@ -245,7 +245,8 @@ class CharacterRange {
// For compatibility with the CHECK_OK macro
CharacterRange(void* null) { ASSERT_EQ(NULL, null); } //NOLINT
CharacterRange(uc16 from, uc16 to) : from_(from), to_(to) { }
static void AddClassEscape(uc16 type, ZoneList<CharacterRange>* ranges);
static void AddClassEscape(uc16 type, ZoneList<CharacterRange>* ranges,
Zone* zone);
static Vector<const int> GetWordBounds();
static inline CharacterRange Singleton(uc16 value) {
return CharacterRange(value, value);
@ -265,11 +266,13 @@ class CharacterRange {
bool is_valid() { return from_ <= to_; }
bool IsEverything(uc16 max) { return from_ == 0 && to_ >= max; }
bool IsSingleton() { return (from_ == to_); }
void AddCaseEquivalents(ZoneList<CharacterRange>* ranges, bool is_ascii);
void AddCaseEquivalents(ZoneList<CharacterRange>* ranges, bool is_ascii,
Zone* zone);
static void Split(ZoneList<CharacterRange>* base,
Vector<const int> overlay,
ZoneList<CharacterRange>** included,
ZoneList<CharacterRange>** excluded);
ZoneList<CharacterRange>** excluded,
Zone* zone);
// Whether a range list is in canonical form: Ranges ordered by from value,
// and ranges non-overlapping and non-adjacent.
static bool IsCanonical(ZoneList<CharacterRange>* ranges);
@ -280,7 +283,8 @@ class CharacterRange {
static void Canonicalize(ZoneList<CharacterRange>* ranges);
// Negate the contents of a character range in canonical form.
static void Negate(ZoneList<CharacterRange>* src,
ZoneList<CharacterRange>* dst);
ZoneList<CharacterRange>* dst,
Zone* zone);
static const int kStartMarker = (1 << 24);
static const int kPayloadMask = (1 << 24) - 1;
@ -295,7 +299,7 @@ class CharacterRange {
class OutSet: public ZoneObject {
public:
OutSet() : first_(0), remaining_(NULL), successors_(NULL) { }
OutSet* Extend(unsigned value);
OutSet* Extend(unsigned value, Zone* zone);
bool Get(unsigned value);
static const unsigned kFirstLimit = 32;
@ -303,12 +307,12 @@ class OutSet: public ZoneObject {
// Destructively set a value in this set. In most cases you want
// to use Extend instead to ensure that only one instance exists
// that contains the same values.
void Set(unsigned value);
void Set(unsigned value, Zone* zone);
// The successors are a list of sets that contain the same values
// as this set and the one more value that is not present in this
// set.
ZoneList<OutSet*>* successors() { return successors_; }
ZoneList<OutSet*>* successors(Zone* zone) { return successors_; }
OutSet(uint32_t first, ZoneList<unsigned>* remaining)
: first_(first), remaining_(remaining), successors_(NULL) { }
@ -323,6 +327,8 @@ class OutSet: public ZoneObject {
// Used for mapping character ranges to choices.
class DispatchTable : public ZoneObject {
public:
explicit DispatchTable(Zone* zone) : tree_(zone) { }
class Entry {
public:
Entry() : from_(0), to_(0), out_set_(NULL) { }
@ -331,7 +337,9 @@ class DispatchTable : public ZoneObject {
uc16 from() { return from_; }
uc16 to() { return to_; }
void set_to(uc16 value) { to_ = value; }
void AddValue(int value) { out_set_ = out_set_->Extend(value); }
void AddValue(int value, Zone* zone) {
out_set_ = out_set_->Extend(value, zone);
}
OutSet* out_set() { return out_set_; }
private:
uc16 from_;
@ -355,12 +363,14 @@ class DispatchTable : public ZoneObject {
}
};
void AddRange(CharacterRange range, int value);
void AddRange(CharacterRange range, int value, Zone* zone);
OutSet* Get(uc16 value);
void Dump();
template <typename Callback>
void ForEach(Callback* callback) { return tree()->ForEach(callback); }
void ForEach(Callback* callback) {
return tree()->ForEach(callback);
}
private:
// There can't be a static empty set since it allocates its
@ -635,7 +645,7 @@ class RegExpNode: public ZoneObject {
return bm_info_[not_at_start ? 1 : 0];
}
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
protected:
enum LimitResult { DONE, CONTINUE };
@ -811,7 +821,7 @@ class TextNode: public SeqRegExpNode {
TextNode(RegExpCharacterClass* that,
RegExpNode* on_success)
: SeqRegExpNode(on_success),
elms_(new ZoneList<TextElement>(1, zone())) {
elms_(new(zone()) ZoneList<TextElement>(1, zone())) {
elms_->Add(TextElement::CharClass(that), zone());
}
virtual void Accept(NodeVisitor* visitor);
@ -868,19 +878,19 @@ class AssertionNode: public SeqRegExpNode {
AFTER_NEWLINE
};
static AssertionNode* AtEnd(RegExpNode* on_success) {
return new AssertionNode(AT_END, on_success);
return new(on_success->zone()) AssertionNode(AT_END, on_success);
}
static AssertionNode* AtStart(RegExpNode* on_success) {
return new AssertionNode(AT_START, on_success);
return new(on_success->zone()) AssertionNode(AT_START, on_success);
}
static AssertionNode* AtBoundary(RegExpNode* on_success) {
return new AssertionNode(AT_BOUNDARY, on_success);
return new(on_success->zone()) AssertionNode(AT_BOUNDARY, on_success);
}
static AssertionNode* AtNonBoundary(RegExpNode* on_success) {
return new AssertionNode(AT_NON_BOUNDARY, on_success);
return new(on_success->zone()) AssertionNode(AT_NON_BOUNDARY, on_success);
}
static AssertionNode* AfterNewline(RegExpNode* on_success) {
return new AssertionNode(AFTER_NEWLINE, on_success);
return new(on_success->zone()) AssertionNode(AFTER_NEWLINE, on_success);
}
virtual void Accept(NodeVisitor* visitor);
virtual void Emit(RegExpCompiler* compiler, Trace* trace);
@ -1018,7 +1028,7 @@ class Guard: public ZoneObject {
class GuardedAlternative {
public:
explicit GuardedAlternative(RegExpNode* node) : node_(node), guards_(NULL) { }
void AddGuard(Guard* guard);
void AddGuard(Guard* guard, Zone* zone);
RegExpNode* node() { return node_; }
void set_node(RegExpNode* node) { node_ = node; }
ZoneList<Guard*>* guards() { return guards_; }
@ -1036,7 +1046,8 @@ class ChoiceNode: public RegExpNode {
public:
explicit ChoiceNode(int expected_size, Zone* zone)
: RegExpNode(zone),
alternatives_(new ZoneList<GuardedAlternative>(expected_size, zone)),
alternatives_(new(zone)
ZoneList<GuardedAlternative>(expected_size, zone)),
table_(NULL),
not_at_start_(false),
being_calculated_(false) { }
@ -1220,7 +1231,7 @@ ContainedInLattice AddRange(ContainedInLattice a,
class BoyerMoorePositionInfo : public ZoneObject {
public:
explicit BoyerMoorePositionInfo(Zone* zone)
: map_(new ZoneList<bool>(kMapSize, zone)),
: map_(new(zone) ZoneList<bool>(kMapSize, zone)),
map_count_(0),
w_(kNotYet),
s_(kNotYet),
@ -1458,12 +1469,13 @@ class Trace {
void AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler);
private:
int FindAffectedRegisters(OutSet* affected_registers);
int FindAffectedRegisters(OutSet* affected_registers, Zone* zone);
void PerformDeferredActions(RegExpMacroAssembler* macro,
int max_register,
OutSet& affected_registers,
OutSet* registers_to_pop,
OutSet* registers_to_clear);
int max_register,
OutSet& affected_registers,
OutSet* registers_to_pop,
OutSet* registers_to_clear,
Zone* zone);
void RestoreAffectedRegisters(RegExpMacroAssembler* macro,
int max_register,
OutSet& registers_to_pop,
@ -1496,15 +1508,17 @@ FOR_EACH_NODE_TYPE(DECLARE_VISIT)
// dispatch table of a choice node.
class DispatchTableConstructor: public NodeVisitor {
public:
DispatchTableConstructor(DispatchTable* table, bool ignore_case)
DispatchTableConstructor(DispatchTable* table, bool ignore_case,
Zone* zone)
: table_(table),
choice_index_(-1),
ignore_case_(ignore_case) { }
ignore_case_(ignore_case),
zone_(zone) { }
void BuildTable(ChoiceNode* node);
void AddRange(CharacterRange range) {
table()->AddRange(range, choice_index_);
table()->AddRange(range, choice_index_, zone_);
}
void AddInverse(ZoneList<CharacterRange>* ranges);
@ -1521,6 +1535,7 @@ FOR_EACH_NODE_TYPE(DECLARE_VISIT)
DispatchTable* table_;
int choice_index_;
bool ignore_case_;
Zone* zone_;
};

View File

@ -147,7 +147,11 @@ void List<T, P>::Allocate(int length, P allocator) {
template<typename T, class P>
void List<T, P>::Clear() {
DeleteData(data_);
Initialize(0);
// We don't call Initialize(0) since that requires passing a Zone,
// which we don't really need.
data_ = NULL;
capacity_ = 0;
length_ = 0;
}

View File

@ -230,9 +230,9 @@ LOperand* LiveRange::CreateAssignedOperand(Zone* zone) {
if (HasRegisterAssigned()) {
ASSERT(!IsSpilled());
if (IsDouble()) {
op = LDoubleRegister::Create(assigned_register());
op = LDoubleRegister::Create(assigned_register(), zone);
} else {
op = LRegister::Create(assigned_register());
op = LRegister::Create(assigned_register(), zone);
}
} else if (IsSpilled()) {
ASSERT(!HasRegisterAssigned());
@ -533,14 +533,14 @@ LifetimePosition LiveRange::FirstIntersection(LiveRange* other) {
LAllocator::LAllocator(int num_values, HGraph* graph)
: zone_(graph->zone()),
chunk_(NULL),
live_in_sets_(graph->blocks()->length()),
live_ranges_(num_values * 2),
live_in_sets_(graph->blocks()->length(), zone_),
live_ranges_(num_values * 2, zone_),
fixed_live_ranges_(NULL),
fixed_double_live_ranges_(NULL),
unhandled_live_ranges_(num_values * 2),
active_live_ranges_(8),
inactive_live_ranges_(8),
reusable_slots_(8),
unhandled_live_ranges_(num_values * 2, zone_),
active_live_ranges_(8, zone_),
inactive_live_ranges_(8, zone_),
reusable_slots_(8, zone_),
next_virtual_register_(num_values),
first_artificial_register_(num_values),
mode_(GENERAL_REGISTERS),
@ -553,8 +553,8 @@ LAllocator::LAllocator(int num_values, HGraph* graph)
void LAllocator::InitializeLivenessAnalysis() {
// Initialize the live_in sets for each block to NULL.
int block_count = graph_->blocks()->length();
live_in_sets_.Initialize(block_count);
live_in_sets_.AddBlock(NULL, block_count);
live_in_sets_.Initialize(block_count, zone());
live_in_sets_.AddBlock(NULL, block_count, zone());
}
@ -630,7 +630,7 @@ LOperand* LAllocator::AllocateFixed(LUnallocated* operand,
TraceAlloc("Fixed reg is tagged at %d\n", pos);
LInstruction* instr = InstructionAt(pos);
if (instr->HasPointerMap()) {
instr->pointer_map()->RecordPointer(operand);
instr->pointer_map()->RecordPointer(operand, zone());
}
}
return operand;
@ -665,7 +665,7 @@ LiveRange* LAllocator::FixedDoubleLiveRangeFor(int index) {
LiveRange* LAllocator::LiveRangeFor(int index) {
if (index >= live_ranges_.length()) {
live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1);
live_ranges_.AddBlock(NULL, index - live_ranges_.length() + 1, zone());
}
LiveRange* result = live_ranges_[index];
if (result == NULL) {
@ -746,7 +746,7 @@ void LAllocator::AddConstraintsGapMove(int index,
LOperand* from,
LOperand* to) {
LGap* gap = GapAt(index);
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START);
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START, zone());
if (from->IsUnallocated()) {
const ZoneList<LMoveOperands>* move_operands = move->move_operands();
for (int i = 0; i < move_operands->length(); ++i) {
@ -755,13 +755,13 @@ void LAllocator::AddConstraintsGapMove(int index,
if (cur_to->IsUnallocated()) {
if (LUnallocated::cast(cur_to)->virtual_register() ==
LUnallocated::cast(from)->virtual_register()) {
move->AddMove(cur.source(), to);
move->AddMove(cur.source(), to, zone());
return;
}
}
}
}
move->AddMove(from, to);
move->AddMove(from, to, zone());
}
@ -800,7 +800,7 @@ void LAllocator::MeetConstraintsBetween(LInstruction* first,
LiveRange* range = LiveRangeFor(first_output->virtual_register());
bool assigned = false;
if (first_output->HasFixedPolicy()) {
LUnallocated* output_copy = first_output->CopyUnconstrained();
LUnallocated* output_copy = first_output->CopyUnconstrained(zone());
bool is_tagged = HasTaggedValue(first_output->virtual_register());
AllocateFixed(first_output, gap_index, is_tagged);
@ -821,8 +821,8 @@ void LAllocator::MeetConstraintsBetween(LInstruction* first,
// Thus it should be inserted to a lifetime position corresponding to
// the instruction end.
LGap* gap = GapAt(gap_index);
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::BEFORE);
move->AddMove(first_output, range->GetSpillOperand());
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::BEFORE, zone());
move->AddMove(first_output, range->GetSpillOperand(), zone());
}
}
@ -831,7 +831,7 @@ void LAllocator::MeetConstraintsBetween(LInstruction* first,
for (UseIterator it(second); !it.Done(); it.Advance()) {
LUnallocated* cur_input = LUnallocated::cast(it.Current());
if (cur_input->HasFixedPolicy()) {
LUnallocated* input_copy = cur_input->CopyUnconstrained();
LUnallocated* input_copy = cur_input->CopyUnconstrained(zone());
bool is_tagged = HasTaggedValue(cur_input->virtual_register());
AllocateFixed(cur_input, gap_index + 1, is_tagged);
AddConstraintsGapMove(gap_index, input_copy, cur_input);
@ -840,7 +840,7 @@ void LAllocator::MeetConstraintsBetween(LInstruction* first,
// of the instruction.
ASSERT(!cur_input->IsUsedAtStart());
LUnallocated* input_copy = cur_input->CopyUnconstrained();
LUnallocated* input_copy = cur_input->CopyUnconstrained(zone());
cur_input->set_virtual_register(GetVirtualRegister());
if (!AllocationOk()) return;
@ -864,7 +864,7 @@ void LAllocator::MeetConstraintsBetween(LInstruction* first,
int output_vreg = second_output->virtual_register();
int input_vreg = cur_input->virtual_register();
LUnallocated* input_copy = cur_input->CopyUnconstrained();
LUnallocated* input_copy = cur_input->CopyUnconstrained(zone());
cur_input->set_virtual_register(second_output->virtual_register());
AddConstraintsGapMove(gap_index, input_copy, cur_input);
@ -872,7 +872,7 @@ void LAllocator::MeetConstraintsBetween(LInstruction* first,
int index = gap_index + 1;
LInstruction* instr = InstructionAt(index);
if (instr->HasPointerMap()) {
instr->pointer_map()->RecordPointer(input_copy);
instr->pointer_map()->RecordPointer(input_copy, zone());
}
} else if (!HasTaggedValue(input_vreg) && HasTaggedValue(output_vreg)) {
// The input is assumed to immediately have a tagged representation,
@ -901,7 +901,7 @@ void LAllocator::ProcessInstructions(HBasicBlock* block, BitVector* live) {
if (IsGapAt(index)) {
// We have a gap at this position.
LGap* gap = GapAt(index);
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START);
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START, zone());
const ZoneList<LMoveOperands>* move_operands = move->move_operands();
for (int i = 0; i < move_operands->length(); ++i) {
LMoveOperands* cur = &move_operands->at(i);
@ -1046,17 +1046,17 @@ void LAllocator::ResolvePhis(HBasicBlock* block) {
InstructionAt(cur_block->last_instruction_index());
if (branch->HasPointerMap()) {
if (phi->representation().IsTagged()) {
branch->pointer_map()->RecordPointer(phi_operand);
branch->pointer_map()->RecordPointer(phi_operand, zone());
} else if (!phi->representation().IsDouble()) {
branch->pointer_map()->RecordUntagged(phi_operand);
branch->pointer_map()->RecordUntagged(phi_operand, zone());
}
}
}
LiveRange* live_range = LiveRangeFor(phi->id());
LLabel* label = chunk_->GetLabel(phi->block()->block_id());
label->GetOrCreateParallelMove(LGap::START)->
AddMove(phi_operand, live_range->GetSpillOperand());
label->GetOrCreateParallelMove(LGap::START, zone())->
AddMove(phi_operand, live_range->GetSpillOperand(), zone());
live_range->SetSpillStartIndex(phi->block()->first_instruction_index());
}
}
@ -1151,14 +1151,15 @@ void LAllocator::ResolveControlFlow(LiveRange* range,
LInstruction* branch = InstructionAt(pred->last_instruction_index());
if (branch->HasPointerMap()) {
if (HasTaggedValue(range->id())) {
branch->pointer_map()->RecordPointer(cur_op);
branch->pointer_map()->RecordPointer(cur_op, zone());
} else if (!cur_op->IsDoubleStackSlot() &&
!cur_op->IsDoubleRegister()) {
branch->pointer_map()->RemovePointer(cur_op);
}
}
}
gap->GetOrCreateParallelMove(LGap::START)->AddMove(pred_op, cur_op);
gap->GetOrCreateParallelMove(
LGap::START, zone())->AddMove(pred_op, cur_op, zone());
}
}
}
@ -1169,11 +1170,11 @@ LParallelMove* LAllocator::GetConnectingParallelMove(LifetimePosition pos) {
if (IsGapAt(index)) {
LGap* gap = GapAt(index);
return gap->GetOrCreateParallelMove(
pos.IsInstructionStart() ? LGap::START : LGap::END);
pos.IsInstructionStart() ? LGap::START : LGap::END, zone());
}
int gap_pos = pos.IsInstructionStart() ? (index - 1) : (index + 1);
return GapAt(gap_pos)->GetOrCreateParallelMove(
(gap_pos < index) ? LGap::AFTER : LGap::BEFORE);
(gap_pos < index) ? LGap::AFTER : LGap::BEFORE, zone());
}
@ -1205,7 +1206,7 @@ void LAllocator::ConnectRanges() {
LParallelMove* move = GetConnectingParallelMove(pos);
LOperand* prev_operand = first_range->CreateAssignedOperand(zone_);
LOperand* cur_operand = second_range->CreateAssignedOperand(zone_);
move->AddMove(prev_operand, cur_operand);
move->AddMove(prev_operand, cur_operand, zone());
}
}
}
@ -1270,7 +1271,7 @@ void LAllocator::BuildLiveRanges() {
LOperand* hint = NULL;
LOperand* phi_operand = NULL;
LGap* gap = GetLastGap(phi->block()->predecessors()->at(0));
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START);
LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START, zone());
for (int j = 0; j < move->move_operands()->length(); ++j) {
LOperand* to = move->move_operands()->at(j).destination();
if (to->IsUnallocated() &&
@ -1421,7 +1422,7 @@ void LAllocator::PopulatePointerMaps() {
safe_point >= range->spill_start_index()) {
TraceAlloc("Pointer for range %d (spilled at %d) at safe point %d\n",
range->id(), range->spill_start_index(), safe_point);
map->RecordPointer(range->GetSpillOperand());
map->RecordPointer(range->GetSpillOperand(), zone());
}
if (!cur->IsSpilled()) {
@ -1430,7 +1431,7 @@ void LAllocator::PopulatePointerMaps() {
cur->id(), cur->Start().Value(), safe_point);
LOperand* operand = cur->CreateAssignedOperand(zone_);
ASSERT(!operand->IsStackSlot());
map->RecordPointer(operand);
map->RecordPointer(operand, zone());
}
}
}
@ -1632,13 +1633,13 @@ RegisterKind LAllocator::RequiredRegisterKind(int virtual_register) const {
void LAllocator::AddToActive(LiveRange* range) {
TraceAlloc("Add live range %d to active\n", range->id());
active_live_ranges_.Add(range);
active_live_ranges_.Add(range, zone());
}
void LAllocator::AddToInactive(LiveRange* range) {
TraceAlloc("Add live range %d to inactive\n", range->id());
inactive_live_ranges_.Add(range);
inactive_live_ranges_.Add(range, zone());
}
@ -1649,13 +1650,13 @@ void LAllocator::AddToUnhandledSorted(LiveRange* range) {
LiveRange* cur_range = unhandled_live_ranges_.at(i);
if (range->ShouldBeAllocatedBefore(cur_range)) {
TraceAlloc("Add live range %d to unhandled at %d\n", range->id(), i + 1);
unhandled_live_ranges_.InsertAt(i + 1, range);
unhandled_live_ranges_.InsertAt(i + 1, range, zone());
ASSERT(UnhandledIsSorted());
return;
}
}
TraceAlloc("Add live range %d to unhandled at start\n", range->id());
unhandled_live_ranges_.InsertAt(0, range);
unhandled_live_ranges_.InsertAt(0, range, zone());
ASSERT(UnhandledIsSorted());
}
@ -1664,7 +1665,7 @@ void LAllocator::AddToUnhandledUnsorted(LiveRange* range) {
if (range == NULL || range->IsEmpty()) return;
ASSERT(!range->HasRegisterAssigned() && !range->IsSpilled());
TraceAlloc("Add live range %d to unhandled unsorted at end\n", range->id());
unhandled_live_ranges_.Add(range);
unhandled_live_ranges_.Add(range, zone());
}
@ -1705,7 +1706,7 @@ void LAllocator::FreeSpillSlot(LiveRange* range) {
int index = range->TopLevel()->GetSpillOperand()->index();
if (index >= 0) {
reusable_slots_.Add(range);
reusable_slots_.Add(range, zone());
}
}
@ -1733,7 +1734,7 @@ void LAllocator::ActiveToHandled(LiveRange* range) {
void LAllocator::ActiveToInactive(LiveRange* range) {
ASSERT(active_live_ranges_.Contains(range));
active_live_ranges_.RemoveElement(range);
inactive_live_ranges_.Add(range);
inactive_live_ranges_.Add(range, zone());
TraceAlloc("Moving live range %d from active to inactive\n", range->id());
}
@ -1749,7 +1750,7 @@ void LAllocator::InactiveToHandled(LiveRange* range) {
void LAllocator::InactiveToActive(LiveRange* range) {
ASSERT(inactive_live_ranges_.Contains(range));
inactive_live_ranges_.RemoveElement(range);
active_live_ranges_.Add(range);
active_live_ranges_.Add(range, zone());
TraceAlloc("Moving live range %d from inactive to active\n", range->id());
}

View File

@ -457,6 +457,7 @@ class LAllocator BASE_EMBEDDED {
LChunk* chunk() const { return chunk_; }
HGraph* graph() const { return graph_; }
Zone* zone() const { return zone_; }
int GetVirtualRegister() {
if (next_virtual_register_ > LUnallocated::kMaxVirtualRegisters) {

View File

@ -171,11 +171,11 @@ void LEnvironment::PrintTo(StringStream* stream) {
}
void LPointerMap::RecordPointer(LOperand* op) {
void LPointerMap::RecordPointer(LOperand* op, Zone* zone) {
// Do not record arguments as pointers.
if (op->IsStackSlot() && op->index() < 0) return;
ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot());
pointer_operands_.Add(op);
pointer_operands_.Add(op, zone);
}
@ -192,11 +192,11 @@ void LPointerMap::RemovePointer(LOperand* op) {
}
void LPointerMap::RecordUntagged(LOperand* op) {
void LPointerMap::RecordUntagged(LOperand* op, Zone* zone) {
// Do not record arguments as pointers.
if (op->IsStackSlot() && op->index() < 0) return;
ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot());
untagged_operands_.Add(op);
untagged_operands_.Add(op, zone);
}

View File

@ -187,8 +187,8 @@ class LUnallocated: public LOperand {
value_ = VirtualRegisterField::update(value_, id);
}
LUnallocated* CopyUnconstrained() {
LUnallocated* result = new LUnallocated(ANY);
LUnallocated* CopyUnconstrained(Zone* zone) {
LUnallocated* result = new(zone) LUnallocated(ANY);
result->set_virtual_register(virtual_register());
return result;
}
@ -260,10 +260,10 @@ class LMoveOperands BASE_EMBEDDED {
class LConstantOperand: public LOperand {
public:
static LConstantOperand* Create(int index) {
static LConstantOperand* Create(int index, Zone* zone) {
ASSERT(index >= 0);
if (index < kNumCachedOperands) return &cache[index];
return new LConstantOperand(index);
return new(zone) LConstantOperand(index);
}
static LConstantOperand* cast(LOperand* op) {
@ -296,10 +296,10 @@ class LArgument: public LOperand {
class LStackSlot: public LOperand {
public:
static LStackSlot* Create(int index) {
static LStackSlot* Create(int index, Zone* zone) {
ASSERT(index >= 0);
if (index < kNumCachedOperands) return &cache[index];
return new LStackSlot(index);
return new(zone) LStackSlot(index);
}
static LStackSlot* cast(LOperand* op) {
@ -321,10 +321,10 @@ class LStackSlot: public LOperand {
class LDoubleStackSlot: public LOperand {
public:
static LDoubleStackSlot* Create(int index) {
static LDoubleStackSlot* Create(int index, Zone* zone) {
ASSERT(index >= 0);
if (index < kNumCachedOperands) return &cache[index];
return new LDoubleStackSlot(index);
return new(zone) LDoubleStackSlot(index);
}
static LDoubleStackSlot* cast(LOperand* op) {
@ -346,10 +346,10 @@ class LDoubleStackSlot: public LOperand {
class LRegister: public LOperand {
public:
static LRegister* Create(int index) {
static LRegister* Create(int index, Zone* zone) {
ASSERT(index >= 0);
if (index < kNumCachedOperands) return &cache[index];
return new LRegister(index);
return new(zone) LRegister(index);
}
static LRegister* cast(LOperand* op) {
@ -371,10 +371,10 @@ class LRegister: public LOperand {
class LDoubleRegister: public LOperand {
public:
static LDoubleRegister* Create(int index) {
static LDoubleRegister* Create(int index, Zone* zone) {
ASSERT(index >= 0);
if (index < kNumCachedOperands) return &cache[index];
return new LDoubleRegister(index);
return new(zone) LDoubleRegister(index);
}
static LDoubleRegister* cast(LOperand* op) {
@ -396,10 +396,10 @@ class LDoubleRegister: public LOperand {
class LParallelMove : public ZoneObject {
public:
LParallelMove() : move_operands_(4) { }
explicit LParallelMove(Zone* zone) : move_operands_(4, zone) { }
void AddMove(LOperand* from, LOperand* to) {
move_operands_.Add(LMoveOperands(from, to));
void AddMove(LOperand* from, LOperand* to, Zone* zone) {
move_operands_.Add(LMoveOperands(from, to), zone);
}
bool IsRedundant() const;
@ -417,9 +417,9 @@ class LParallelMove : public ZoneObject {
class LPointerMap: public ZoneObject {
public:
explicit LPointerMap(int position)
: pointer_operands_(8),
untagged_operands_(0),
explicit LPointerMap(int position, Zone* zone)
: pointer_operands_(8, zone),
untagged_operands_(0, zone),
position_(position),
lithium_position_(-1) { }
@ -438,9 +438,9 @@ class LPointerMap: public ZoneObject {
lithium_position_ = pos;
}
void RecordPointer(LOperand* op);
void RecordPointer(LOperand* op, Zone* zone);
void RemovePointer(LOperand* op);
void RecordUntagged(LOperand* op);
void RecordUntagged(LOperand* op, Zone* zone);
void PrintTo(StringStream* stream);
private:
@ -469,7 +469,7 @@ class LEnvironment: public ZoneObject {
ast_id_(ast_id),
parameter_count_(parameter_count),
pc_offset_(-1),
values_(value_count),
values_(value_count, zone),
is_tagged_(value_count, closure->GetHeap()->isolate()->zone()),
spilled_registers_(NULL),
spilled_double_registers_(NULL),
@ -492,7 +492,7 @@ class LEnvironment: public ZoneObject {
LEnvironment* outer() const { return outer_; }
void AddValue(LOperand* operand, Representation representation) {
values_.Add(operand);
values_.Add(operand, zone());
if (representation.IsTagged()) {
is_tagged_.Add(values_.length() - 1);
}
@ -522,7 +522,7 @@ class LEnvironment: public ZoneObject {
void PrintTo(StringStream* stream);
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
private:
Handle<JSFunction> closure_;

View File

@ -825,7 +825,8 @@ class FunctionInfoListener {
// Saves full information about a function: its code, its scope info
// and a SharedFunctionInfo object.
void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope) {
void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope,
Zone* zone) {
if (!shared->IsSharedFunctionInfo()) {
return;
}
@ -836,14 +837,14 @@ class FunctionInfoListener {
Handle<Object>(shared->scope_info()));
info.SetSharedFunctionInfo(shared);
Handle<Object> scope_info_list(SerializeFunctionScope(scope));
Handle<Object> scope_info_list(SerializeFunctionScope(scope, zone));
info.SetOuterScopeInfo(scope_info_list);
}
Handle<JSArray> GetResult() { return result_; }
private:
Object* SerializeFunctionScope(Scope* scope) {
Object* SerializeFunctionScope(Scope* scope, Zone* zone) {
HandleScope handle_scope;
Handle<JSArray> scope_info_list = FACTORY->NewJSArray(10);
@ -857,8 +858,8 @@ class FunctionInfoListener {
return HEAP->undefined_value();
}
do {
ZoneList<Variable*> stack_list(outer_scope->StackLocalCount());
ZoneList<Variable*> context_list(outer_scope->ContextLocalCount());
ZoneList<Variable*> stack_list(outer_scope->StackLocalCount(), zone);
ZoneList<Variable*> context_list(outer_scope->ContextLocalCount(), zone);
outer_scope->CollectStackAndContextLocals(&stack_list, &context_list);
context_list.Sort(&Variable::CompareIndex);
@ -927,28 +928,32 @@ void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) {
// It works in context of ZoneScope.
class ReferenceCollectorVisitor : public ObjectVisitor {
public:
explicit ReferenceCollectorVisitor(Code* original)
: original_(original), rvalues_(10), reloc_infos_(10), code_entries_(10) {
ReferenceCollectorVisitor(Code* original, Zone* zone)
: original_(original),
rvalues_(10, zone),
reloc_infos_(10, zone),
code_entries_(10, zone),
zone_(zone) {
}
virtual void VisitPointers(Object** start, Object** end) {
for (Object** p = start; p < end; p++) {
if (*p == original_) {
rvalues_.Add(p);
rvalues_.Add(p, zone_);
}
}
}
virtual void VisitCodeEntry(Address entry) {
if (Code::GetObjectFromEntryAddress(entry) == original_) {
code_entries_.Add(entry);
code_entries_.Add(entry, zone_);
}
}
virtual void VisitCodeTarget(RelocInfo* rinfo) {
if (RelocInfo::IsCodeTarget(rinfo->rmode()) &&
Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) {
reloc_infos_.Add(*rinfo);
reloc_infos_.Add(*rinfo, zone_);
}
}
@ -977,6 +982,7 @@ class ReferenceCollectorVisitor : public ObjectVisitor {
ZoneList<Object**> rvalues_;
ZoneList<RelocInfo> reloc_infos_;
ZoneList<Address> code_entries_;
Zone* zone_;
};
@ -990,7 +996,7 @@ static void ReplaceCodeObject(Code* original, Code* substitution) {
// A zone scope for ReferenceCollectorVisitor.
ZoneScope scope(Isolate::Current(), DELETE_ON_EXIT);
ReferenceCollectorVisitor visitor(original);
ReferenceCollectorVisitor visitor(original, Isolate::Current()->zone());
// Iterate over all roots. Stack frames may have pointer into original code,
// so temporary replace the pointers with offset numbers
@ -1592,11 +1598,12 @@ static bool IsDropableFrame(StackFrame* frame) {
// 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) {
Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop,
Zone* zone) {
Isolate* isolate = Isolate::Current();
Debug* debug = isolate->debug();
ZoneScope scope(isolate, DELETE_ON_EXIT);
Vector<StackFrame*> frames = CreateStackMap();
Vector<StackFrame*> frames = CreateStackMap(zone);
int array_len = Smi::cast(shared_info_array->length())->value();
@ -1723,7 +1730,7 @@ class InactiveThreadActivationsChecker : public ThreadVisitor {
Handle<JSArray> LiveEdit::CheckAndDropActivations(
Handle<JSArray> shared_info_array, bool do_drop) {
Handle<JSArray> shared_info_array, bool do_drop, Zone* zone) {
int len = Smi::cast(shared_info_array->length())->value();
Handle<JSArray> result = FACTORY->NewJSArray(len);
@ -1748,7 +1755,7 @@ Handle<JSArray> LiveEdit::CheckAndDropActivations(
// Try to drop activations from the current stack.
const char* error_message =
DropActivationsInActiveThread(shared_info_array, result, do_drop);
DropActivationsInActiveThread(shared_info_array, result, do_drop, zone);
if (error_message != NULL) {
// Add error message as an array extra element.
Vector<const char> vector_message(error_message, StrLength(error_message));
@ -1776,9 +1783,11 @@ LiveEditFunctionTracker::~LiveEditFunctionTracker() {
void LiveEditFunctionTracker::RecordFunctionInfo(
Handle<SharedFunctionInfo> info, FunctionLiteral* lit) {
Handle<SharedFunctionInfo> info, FunctionLiteral* lit,
Zone* zone) {
if (isolate_->active_function_info_listener() != NULL) {
isolate_->active_function_info_listener()->FunctionInfo(info, lit->scope());
isolate_->active_function_info_listener()->FunctionInfo(info, lit->scope(),
zone);
}
}

View File

@ -69,7 +69,7 @@ class LiveEditFunctionTracker {
explicit LiveEditFunctionTracker(Isolate* isolate, FunctionLiteral* fun);
~LiveEditFunctionTracker();
void RecordFunctionInfo(Handle<SharedFunctionInfo> info,
FunctionLiteral* lit);
FunctionLiteral* lit, Zone* zone);
void RecordRootFunctionInfo(Handle<Code> code);
static bool IsActive(Isolate* isolate);
@ -121,7 +121,7 @@ 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);
Handle<JSArray> shared_info_array, bool do_drop, Zone* zone);
// A copy of this is in liveedit-debugger.js.
enum FunctionPatchabilityStatus {

View File

@ -41,6 +41,7 @@
#include "mips/constants-mips.h"
#endif
#include "v8checks.h"
#include "zone.h"
//
@ -3471,7 +3472,7 @@ class ScopeInfo : public FixedArray {
// must be a symbol (canonicalized).
int FunctionContextSlotIndex(String* name, VariableMode* mode);
static Handle<ScopeInfo> Create(Scope* scope);
static Handle<ScopeInfo> Create(Scope* scope, Zone* zone);
// Serializes empty scope info.
static ScopeInfo* Empty();

View File

@ -103,7 +103,7 @@ void RegExpBuilder::FlushCharacters() {
if (characters_ != NULL) {
RegExpTree* atom = new(zone()) RegExpAtom(characters_->ToConstVector());
characters_ = NULL;
text_.Add(atom);
text_.Add(atom, zone());
LAST(ADD_ATOM);
}
}
@ -115,12 +115,12 @@ void RegExpBuilder::FlushText() {
if (num_text == 0) {
return;
} else if (num_text == 1) {
terms_.Add(text_.last());
terms_.Add(text_.last(), zone());
} else {
RegExpText* text = new(zone()) RegExpText();
RegExpText* text = new(zone()) RegExpText(zone());
for (int i = 0; i < num_text; i++)
text_.Get(i)->AppendToText(text);
terms_.Add(text);
text_.Get(i)->AppendToText(text, zone());
terms_.Add(text, zone());
}
text_.Clear();
}
@ -129,9 +129,9 @@ void RegExpBuilder::FlushText() {
void RegExpBuilder::AddCharacter(uc16 c) {
pending_empty_ = false;
if (characters_ == NULL) {
characters_ = new(zone()) ZoneList<uc16>(4);
characters_ = new(zone()) ZoneList<uc16>(4, zone());
}
characters_->Add(c);
characters_->Add(c, zone());
LAST(ADD_CHAR);
}
@ -148,10 +148,10 @@ void RegExpBuilder::AddAtom(RegExpTree* term) {
}
if (term->IsTextElement()) {
FlushCharacters();
text_.Add(term);
text_.Add(term, zone());
} else {
FlushText();
terms_.Add(term);
terms_.Add(term, zone());
}
LAST(ADD_ATOM);
}
@ -159,7 +159,7 @@ void RegExpBuilder::AddAtom(RegExpTree* term) {
void RegExpBuilder::AddAssertion(RegExpTree* assert) {
FlushText();
terms_.Add(assert);
terms_.Add(assert, zone());
LAST(ADD_ASSERT);
}
@ -178,9 +178,9 @@ void RegExpBuilder::FlushTerms() {
} else if (num_terms == 1) {
alternative = terms_.last();
} else {
alternative = new(zone()) RegExpAlternative(terms_.GetList());
alternative = new(zone()) RegExpAlternative(terms_.GetList(zone()));
}
alternatives_.Add(alternative);
alternatives_.Add(alternative, zone());
terms_.Clear();
LAST(ADD_NONE);
}
@ -195,7 +195,7 @@ RegExpTree* RegExpBuilder::ToRegExp() {
if (num_alternatives == 1) {
return alternatives_.last();
}
return new(zone()) RegExpDisjunction(alternatives_.GetList());
return new(zone()) RegExpDisjunction(alternatives_.GetList(zone()));
}
@ -214,7 +214,7 @@ void RegExpBuilder::AddQuantifierToAtom(int min,
int num_chars = char_vector.length();
if (num_chars > 1) {
Vector<const uc16> prefix = char_vector.SubVector(0, num_chars - 1);
text_.Add(new(zone()) RegExpAtom(prefix));
text_.Add(new(zone()) RegExpAtom(prefix), zone());
char_vector = char_vector.SubVector(num_chars - 1, num_chars);
}
characters_ = NULL;
@ -233,7 +233,7 @@ void RegExpBuilder::AddQuantifierToAtom(int min,
if (min == 0) {
return;
}
terms_.Add(atom);
terms_.Add(atom, zone());
return;
}
} else {
@ -241,7 +241,7 @@ void RegExpBuilder::AddQuantifierToAtom(int min,
UNREACHABLE();
return;
}
terms_.Add(new(zone()) RegExpQuantifier(min, max, type, atom));
terms_.Add(new(zone()) RegExpQuantifier(min, max, type, atom), zone());
LAST(ADD_TERM);
}
@ -270,7 +270,7 @@ Handle<String> Parser::LookupCachedSymbol(int symbol_id) {
if (symbol_cache_.length() <= symbol_id) {
// Increase length to index + 1.
symbol_cache_.AddBlock(Handle<String>::null(),
symbol_id + 1 - symbol_cache_.length());
symbol_id + 1 - symbol_cache_.length(), zone());
}
Handle<String> result = symbol_cache_.at(symbol_id);
if (result.is_null()) {
@ -408,7 +408,7 @@ unsigned* ScriptDataImpl::ReadAddress(int position) {
Scope* Parser::NewScope(Scope* parent, ScopeType type) {
Scope* result = new(zone()) Scope(parent, type);
Scope* result = new(zone()) Scope(parent, type, zone());
result->Initialize();
return result;
}
@ -538,7 +538,7 @@ Parser::Parser(Handle<Script> script,
ScriptDataImpl* pre_data,
Zone* zone)
: isolate_(script->GetIsolate()),
symbol_cache_(pre_data ? pre_data->symbol_count() : 0),
symbol_cache_(pre_data ? pre_data->symbol_count() : 0, zone),
script_(script),
scanner_(isolate_->unicode_cache()),
reusable_preparser_(NULL),
@ -570,7 +570,7 @@ FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) {
HistogramTimerScope timer(isolate()->counters()->parse());
Handle<String> source(String::cast(script_->source()));
isolate()->counters()->total_parse_size()->Increment(source->length());
fni_ = new(zone()) FuncNameInferrer(isolate());
fni_ = new(zone()) FuncNameInferrer(isolate(), zone());
// Initialize parser state.
source->TryFlatten();
@ -609,7 +609,8 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
if (info->is_eval()) {
Handle<SharedFunctionInfo> shared = info->shared_info();
if (!info->is_global() && (shared.is_null() || shared->is_function())) {
scope = Scope::DeserializeScopeChain(*info->calling_context(), scope);
scope = Scope::DeserializeScopeChain(*info->calling_context(), scope,
zone());
}
if (!scope->is_global_scope() || info->language_mode() != CLASSIC_MODE) {
scope = NewScope(scope, EVAL_SCOPE);
@ -619,7 +620,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
scope->set_end_position(source->length());
FunctionState function_state(this, scope, isolate());
top_scope_->SetLanguageMode(info->language_mode());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16);
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
bool ok = true;
int beg_loc = scanner().location().beg_pos;
ParseSourceElements(body, Token::EOS, info->is_eval(), &ok);
@ -696,7 +697,7 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info,
ASSERT(target_stack_ == NULL);
Handle<String> name(String::cast(shared_info->name()));
fni_ = new(zone()) FuncNameInferrer(isolate());
fni_ = new(zone()) FuncNameInferrer(isolate(), zone());
fni_->PushEnclosingName(name);
mode_ = PARSE_EAGERLY;
@ -709,7 +710,8 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info,
Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE);
info->SetGlobalScope(scope);
if (!info->closure().is_null()) {
scope = Scope::DeserializeScopeChain(info->closure()->context(), scope);
scope = Scope::DeserializeScopeChain(info->closure()->context(), scope,
zone());
}
FunctionState function_state(this, scope, isolate());
ASSERT(scope->language_mode() != STRICT_MODE || !info->is_classic_mode());
@ -944,12 +946,13 @@ class InitializationBlockFinder : public ParserFinder {
// function contains only assignments of this type.
class ThisNamedPropertyAssignmentFinder : public ParserFinder {
public:
explicit ThisNamedPropertyAssignmentFinder(Isolate* isolate)
ThisNamedPropertyAssignmentFinder(Isolate* isolate, Zone* zone)
: isolate_(isolate),
only_simple_this_property_assignments_(true),
names_(0),
assigned_arguments_(0),
assigned_constants_(0) {
names_(0, zone),
assigned_arguments_(0, zone),
assigned_constants_(0, zone),
zone_(zone) {
}
void Update(Scope* scope, Statement* stat) {
@ -1058,9 +1061,9 @@ class ThisNamedPropertyAssignmentFinder : public ParserFinder {
return;
}
}
names_.Add(name);
assigned_arguments_.Add(index);
assigned_constants_.Add(isolate_->factory()->undefined_value());
names_.Add(name, zone());
assigned_arguments_.Add(index, zone());
assigned_constants_.Add(isolate_->factory()->undefined_value(), zone());
}
void AssignmentFromConstant(Handle<String> name, Handle<Object> value) {
@ -1072,9 +1075,9 @@ class ThisNamedPropertyAssignmentFinder : public ParserFinder {
return;
}
}
names_.Add(name);
assigned_arguments_.Add(-1);
assigned_constants_.Add(value);
names_.Add(name, zone());
assigned_arguments_.Add(-1, zone());
assigned_constants_.Add(value, zone());
}
void AssignmentFromSomethingElse() {
@ -1086,17 +1089,20 @@ class ThisNamedPropertyAssignmentFinder : public ParserFinder {
if (names_.capacity() == 0) {
ASSERT(assigned_arguments_.capacity() == 0);
ASSERT(assigned_constants_.capacity() == 0);
names_.Initialize(4);
assigned_arguments_.Initialize(4);
assigned_constants_.Initialize(4);
names_.Initialize(4, zone());
assigned_arguments_.Initialize(4, zone());
assigned_constants_.Initialize(4, zone());
}
}
Zone* zone() const { return zone_; }
Isolate* isolate_;
bool only_simple_this_property_assignments_;
ZoneStringList names_;
ZoneList<int> assigned_arguments_;
ZoneObjectList assigned_constants_;
Zone* zone_;
};
@ -1115,7 +1121,8 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
ASSERT(processor != NULL);
InitializationBlockFinder block_finder(top_scope_, target_stack_);
ThisNamedPropertyAssignmentFinder this_property_assignment_finder(isolate());
ThisNamedPropertyAssignmentFinder this_property_assignment_finder(isolate(),
zone());
bool directive_prologue = true; // Parsing directive prologue.
while (peek() != end_token) {
@ -1173,7 +1180,7 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor,
if (top_scope_->is_function_scope()) {
this_property_assignment_finder.Update(top_scope_, stat);
}
processor->Add(stat);
processor->Add(stat, zone());
}
// Propagate the collected information on this property assignments.
@ -1244,7 +1251,7 @@ Block* Parser::ParseModuleDeclaration(ZoneStringList* names, bool* ok) {
// 'module' Identifier Module
// Create new block with one expected declaration.
Block* block = factory()->NewBlock(NULL, 1, true);
Block* block = factory()->NewBlock(NULL, 1, true, zone());
Handle<String> name = ParseIdentifier(CHECK_OK);
#ifdef DEBUG
@ -1270,7 +1277,7 @@ Block* Parser::ParseModuleDeclaration(ZoneStringList* names, bool* ok) {
// TODO(rossberg): Add initialization statement to block.
if (names) names->Add(name);
if (names) names->Add(name, zone());
return block;
}
@ -1307,7 +1314,7 @@ Module* Parser::ParseModuleLiteral(bool* ok) {
// '{' ModuleElement '}'
// Construct block expecting 16 statements.
Block* body = factory()->NewBlock(NULL, 16, false);
Block* body = factory()->NewBlock(NULL, 16, false, zone());
#ifdef DEBUG
if (FLAG_print_interface_details) PrintF("# Literal ");
#endif
@ -1319,7 +1326,7 @@ Module* Parser::ParseModuleLiteral(bool* ok) {
{
BlockState block_state(this, scope);
TargetCollector collector;
TargetCollector collector(zone());
Target target(&this->target_stack_, &collector);
Target target_body(&this->target_stack_, body);
InitializationBlockFinder block_finder(top_scope_, target_stack_);
@ -1364,7 +1371,7 @@ Module* Parser::ParseModulePath(bool* ok) {
PrintF("# Path .%s ", name->ToAsciiArray());
#endif
Module* member = factory()->NewModulePath(result, name);
result->interface()->Add(name, member->interface(), ok);
result->interface()->Add(name, member->interface(), zone(), ok);
if (!*ok) {
#ifdef DEBUG
if (FLAG_print_interfaces) {
@ -1395,7 +1402,8 @@ Module* Parser::ParseModuleVariable(bool* ok) {
PrintF("# Module variable %s ", name->ToAsciiArray());
#endif
VariableProxy* proxy = top_scope_->NewUnresolved(
factory(), name, scanner().location().beg_pos, Interface::NewModule());
factory(), name, scanner().location().beg_pos,
Interface::NewModule(zone()));
return factory()->NewModuleVariable(proxy);
}
@ -1444,14 +1452,14 @@ Block* Parser::ParseImportDeclaration(bool* ok) {
// TODO(ES6): implement destructuring ImportSpecifiers
Expect(Token::IMPORT, CHECK_OK);
ZoneStringList names(1);
ZoneStringList names(1, zone());
Handle<String> name = ParseIdentifierName(CHECK_OK);
names.Add(name);
names.Add(name, zone());
while (peek() == Token::COMMA) {
Consume(Token::COMMA);
name = ParseIdentifierName(CHECK_OK);
names.Add(name);
names.Add(name, zone());
}
ExpectContextualKeyword("from", CHECK_OK);
@ -1460,14 +1468,14 @@ Block* Parser::ParseImportDeclaration(bool* ok) {
// Generate a separate declaration for each identifier.
// TODO(ES6): once we implement destructuring, make that one declaration.
Block* block = factory()->NewBlock(NULL, 1, true);
Block* block = factory()->NewBlock(NULL, 1, true, zone());
for (int i = 0; i < names.length(); ++i) {
#ifdef DEBUG
if (FLAG_print_interface_details)
PrintF("# Import %s ", names[i]->ToAsciiArray());
#endif
Interface* interface = Interface::NewUnknown();
module->interface()->Add(names[i], interface, ok);
Interface* interface = Interface::NewUnknown(zone());
module->interface()->Add(names[i], interface, zone(), ok);
if (!*ok) {
#ifdef DEBUG
if (FLAG_print_interfaces) {
@ -1502,17 +1510,17 @@ Statement* Parser::ParseExportDeclaration(bool* ok) {
Expect(Token::EXPORT, CHECK_OK);
Statement* result = NULL;
ZoneStringList names(1);
ZoneStringList names(1, zone());
switch (peek()) {
case Token::IDENTIFIER: {
Handle<String> name = ParseIdentifier(CHECK_OK);
// Handle 'module' as a context-sensitive keyword.
if (!name->IsEqualTo(CStrVector("module"))) {
names.Add(name);
names.Add(name, zone());
while (peek() == Token::COMMA) {
Consume(Token::COMMA);
name = ParseIdentifier(CHECK_OK);
names.Add(name);
names.Add(name, zone());
}
ExpectSemicolon(CHECK_OK);
result = factory()->NewEmptyStatement();
@ -1545,8 +1553,10 @@ Statement* Parser::ParseExportDeclaration(bool* ok) {
if (FLAG_print_interface_details)
PrintF("# Export %s ", names[i]->ToAsciiArray());
#endif
Interface* inner = Interface::NewUnknown();
interface->Add(names[i], inner, CHECK_OK);
Interface* inner = Interface::NewUnknown(zone());
interface->Add(names[i], inner, zone(), CHECK_OK);
if (!*ok)
return NULL;
VariableProxy* proxy = NewUnresolved(names[i], LET, inner);
USE(proxy);
// TODO(rossberg): Rethink whether we actually need to store export
@ -1673,7 +1683,7 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) {
// one must take great care not to treat it as a
// fall-through. It is much easier just to wrap the entire
// try-statement in a statement block and put the labels there
Block* result = factory()->NewBlock(labels, 1, false);
Block* result = factory()->NewBlock(labels, 1, false, zone());
Target target(&this->target_stack_, result);
TryStatement* statement = ParseTryStatement(CHECK_OK);
if (statement) {
@ -1872,7 +1882,7 @@ void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) {
if (FLAG_print_interface_details)
PrintF("# Declare %s\n", var->name()->ToAsciiArray());
#endif
proxy->interface()->Unify(var->interface(), &ok);
proxy->interface()->Unify(var->interface(), zone(), &ok);
if (!ok) {
#ifdef DEBUG
if (FLAG_print_interfaces) {
@ -1971,7 +1981,7 @@ Statement* Parser::ParseFunctionDeclaration(ZoneStringList* names, bool* ok) {
Declaration* declaration =
factory()->NewFunctionDeclaration(proxy, mode, fun, top_scope_);
Declare(declaration, true, CHECK_OK);
if (names) names->Add(name);
if (names) names->Add(name, zone());
return factory()->NewEmptyStatement();
}
@ -1986,7 +1996,7 @@ Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
// (ECMA-262, 3rd, 12.2)
//
// Construct block expecting 16 statements.
Block* result = factory()->NewBlock(labels, 16, false);
Block* result = factory()->NewBlock(labels, 16, false, zone());
Target target(&this->target_stack_, result);
Expect(Token::LBRACE, CHECK_OK);
InitializationBlockFinder block_finder(top_scope_, target_stack_);
@ -2009,14 +2019,14 @@ Block* Parser::ParseScopedBlock(ZoneStringList* labels, bool* ok) {
// '{' BlockElement* '}'
// Construct block expecting 16 statements.
Block* body = factory()->NewBlock(labels, 16, false);
Block* body = factory()->NewBlock(labels, 16, false, zone());
Scope* block_scope = NewScope(top_scope_, BLOCK_SCOPE);
// Parse the statements and collect escaping labels.
Expect(Token::LBRACE, CHECK_OK);
block_scope->set_start_position(scanner().location().beg_pos);
{ BlockState block_state(this, block_scope);
TargetCollector collector;
TargetCollector collector(zone());
Target target(&this->target_stack_, &collector);
Target target_body(&this->target_stack_, body);
InitializationBlockFinder block_finder(top_scope_, target_stack_);
@ -2166,7 +2176,7 @@ Block* Parser::ParseVariableDeclarations(
// is inside an initializer block, it is ignored.
//
// Create new block with one expected declaration.
Block* block = factory()->NewBlock(NULL, 1, true);
Block* block = factory()->NewBlock(NULL, 1, true, zone());
int nvars = 0; // the number of variables declared
Handle<String> name;
do {
@ -2210,7 +2220,7 @@ Block* Parser::ParseVariableDeclarations(
*ok = false;
return NULL;
}
if (names) names->Add(name);
if (names) names->Add(name, zone());
// Parse initialization expression if present and/or needed. A
// declaration of the form:
@ -2289,13 +2299,14 @@ Block* Parser::ParseVariableDeclarations(
// properties defined in prototype objects.
if (initialization_scope->is_global_scope()) {
// Compute the arguments for the runtime call.
ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3);
ZoneList<Expression*>* arguments =
new(zone()) ZoneList<Expression*>(3, zone());
// We have at least 1 parameter.
arguments->Add(factory()->NewLiteral(name));
arguments->Add(factory()->NewLiteral(name), zone());
CallRuntime* initialize;
if (is_const) {
arguments->Add(value);
arguments->Add(value, zone());
value = NULL; // zap the value to avoid the unnecessary assignment
// Construct the call to Runtime_InitializeConstGlobal
@ -2310,14 +2321,14 @@ Block* Parser::ParseVariableDeclarations(
// Add strict mode.
// We may want to pass singleton to avoid Literal allocations.
LanguageMode language_mode = initialization_scope->language_mode();
arguments->Add(factory()->NewNumberLiteral(language_mode));
arguments->Add(factory()->NewNumberLiteral(language_mode), zone());
// Be careful not to assign a value to the global variable if
// we're in a with. The initialization value should not
// necessarily be stored in the global object in that case,
// which is why we need to generate a separate assignment node.
if (value != NULL && !inside_with()) {
arguments->Add(value);
arguments->Add(value, zone());
value = NULL; // zap the value to avoid the unnecessary assignment
}
@ -2417,8 +2428,10 @@ Statement* Parser::ParseExpressionOrLabelledStatement(ZoneStringList* labels,
*ok = false;
return NULL;
}
if (labels == NULL) labels = new(zone()) ZoneStringList(4);
labels->Add(label);
if (labels == NULL) {
labels = new(zone()) ZoneStringList(4, zone());
}
labels->Add(label, zone());
// Remove the "ghost" variable that turned out to be a label
// from the top scope. This way, we don't try to resolve it
// during the scope processing.
@ -2630,12 +2643,13 @@ CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) {
}
Expect(Token::COLON, CHECK_OK);
int pos = scanner().location().beg_pos;
ZoneList<Statement*>* statements = new(zone()) ZoneList<Statement*>(5);
ZoneList<Statement*>* statements =
new(zone()) ZoneList<Statement*>(5, zone());
while (peek() != Token::CASE &&
peek() != Token::DEFAULT &&
peek() != Token::RBRACE) {
Statement* stat = ParseStatement(NULL, CHECK_OK);
statements->Add(stat);
statements->Add(stat, zone());
}
return new(zone()) CaseClause(isolate(), label, statements, pos);
@ -2656,11 +2670,11 @@ SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels,
Expect(Token::RPAREN, CHECK_OK);
bool default_seen = false;
ZoneList<CaseClause*>* cases = new(zone()) ZoneList<CaseClause*>(4);
ZoneList<CaseClause*>* cases = new(zone()) ZoneList<CaseClause*>(4, zone());
Expect(Token::LBRACE, CHECK_OK);
while (peek() != Token::RBRACE) {
CaseClause* clause = ParseCaseClause(&default_seen, CHECK_OK);
cases->Add(clause);
cases->Add(clause, zone());
}
Expect(Token::RBRACE, CHECK_OK);
@ -2701,7 +2715,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
Expect(Token::TRY, CHECK_OK);
TargetCollector try_collector;
TargetCollector try_collector(zone());
Block* try_block;
{ Target target(&this->target_stack_, &try_collector);
@ -2719,7 +2733,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
// then we will need to collect escaping targets from the catch
// block. Since we don't know yet if there will be a finally block, we
// always collect the targets.
TargetCollector catch_collector;
TargetCollector catch_collector(zone());
Scope* catch_scope = NULL;
Variable* catch_variable = NULL;
Block* catch_block = NULL;
@ -2773,7 +2787,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
TryCatchStatement* statement = factory()->NewTryCatchStatement(
index, try_block, catch_scope, catch_variable, catch_block);
statement->set_escaping_targets(try_collector.targets());
try_block = factory()->NewBlock(NULL, 1, false);
try_block = factory()->NewBlock(NULL, 1, false, zone());
try_block->AddStatement(statement, zone());
catch_block = NULL; // Clear to indicate it's been handled.
}
@ -2790,7 +2804,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
int index = current_function_state_->NextHandlerIndex();
result = factory()->NewTryFinallyStatement(index, try_block, finally_block);
// Combine the jump targets of the try block and the possible catch block.
try_collector.targets()->AddAll(*catch_collector.targets());
try_collector.targets()->AddAll(*catch_collector.targets(), zone());
}
result->set_escaping_targets(try_collector.targets());
@ -2879,7 +2893,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
Statement* body = ParseStatement(NULL, CHECK_OK);
loop->Initialize(each, enumerable, body);
Block* result = factory()->NewBlock(NULL, 2, false);
Block* result = factory()->NewBlock(NULL, 2, false, zone());
result->AddStatement(variable_statement, zone());
result->AddStatement(loop, zone());
top_scope_ = saved_scope;
@ -2925,7 +2939,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
Expect(Token::RPAREN, CHECK_OK);
Statement* body = ParseStatement(NULL, CHECK_OK);
Block* body_block = factory()->NewBlock(NULL, 3, false);
Block* body_block = factory()->NewBlock(NULL, 3, false, zone());
Assignment* assignment = factory()->NewAssignment(
Token::ASSIGN, each, temp_proxy, RelocInfo::kNoPosition);
Statement* assignment_statement =
@ -3014,7 +3028,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) {
// for (; c; n) b
// }
ASSERT(init != NULL);
Block* result = factory()->NewBlock(NULL, 2, false);
Block* result = factory()->NewBlock(NULL, 2, false, zone());
result->AddStatement(init, zone());
result->AddStatement(loop, zone());
result->set_scope(for_scope);
@ -3459,7 +3473,7 @@ Expression* Parser::ParseNewPrefix(PositionStack* stack, bool* ok) {
if (!stack->is_empty()) {
int last = stack->pop();
result = factory()->NewCallNew(
result, new(zone()) ZoneList<Expression*>(0), last);
result, new(zone()) ZoneList<Expression*>(0, zone()), last);
}
return result;
}
@ -3649,7 +3663,7 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) {
if (FLAG_print_interface_details)
PrintF("# Variable %s ", name->ToAsciiArray());
#endif
Interface* interface = Interface::NewUnknown();
Interface* interface = Interface::NewUnknown(zone());
result = top_scope_->NewUnresolved(
factory(), name, scanner().location().beg_pos, interface);
break;
@ -3749,7 +3763,7 @@ Expression* Parser::ParseArrayLiteral(bool* ok) {
// ArrayLiteral ::
// '[' Expression? (',' Expression?)* ']'
ZoneList<Expression*>* values = new(zone()) ZoneList<Expression*>(4);
ZoneList<Expression*>* values = new(zone()) ZoneList<Expression*>(4, zone());
Expect(Token::LBRACK, CHECK_OK);
while (peek() != Token::RBRACK) {
Expression* elem;
@ -3758,7 +3772,7 @@ Expression* Parser::ParseArrayLiteral(bool* ok) {
} else {
elem = ParseAssignmentExpression(true, CHECK_OK);
}
values->Add(elem);
values->Add(elem, zone());
if (peek() != Token::RBRACK) {
Expect(Token::COMMA, CHECK_OK);
}
@ -4127,7 +4141,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
// )*[','] '}'
ZoneList<ObjectLiteral::Property*>* properties =
new(zone()) ZoneList<ObjectLiteral::Property*>(4);
new(zone()) ZoneList<ObjectLiteral::Property*>(4, zone());
int number_of_boilerplate_properties = 0;
bool has_function = false;
@ -4164,7 +4178,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
}
// Validate the property.
checker.CheckProperty(property, loc, CHECK_OK);
properties->Add(property);
properties->Add(property, zone());
if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK);
if (fni_ != NULL) {
@ -4232,7 +4246,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
if (IsBoilerplateProperty(property)) number_of_boilerplate_properties++;
// Validate the property
checker.CheckProperty(property, loc, CHECK_OK);
properties->Add(property);
properties->Add(property, zone());
// TODO(1240767): Consider allowing trailing comma.
if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK);
@ -4291,12 +4305,12 @@ ZoneList<Expression*>* Parser::ParseArguments(bool* ok) {
// Arguments ::
// '(' (AssignmentExpression)*[','] ')'
ZoneList<Expression*>* result = new(zone()) ZoneList<Expression*>(4);
ZoneList<Expression*>* result = new(zone()) ZoneList<Expression*>(4, zone());
Expect(Token::LPAREN, CHECK_OK);
bool done = (peek() == Token::RPAREN);
while (!done) {
Expression* argument = ParseAssignmentExpression(true, CHECK_OK);
result->Add(argument);
result->Add(argument, zone());
if (result->length() > kMaxNumFunctionParameters) {
ReportMessageAt(scanner().location(), "too_many_arguments",
Vector<const char*>::empty());
@ -4585,7 +4599,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
}
if (!is_lazily_compiled) {
body = new(zone()) ZoneList<Statement*>(8);
body = new(zone()) ZoneList<Statement*>(8, zone());
if (fvar != NULL) {
VariableProxy* fproxy =
top_scope_->NewUnresolved(factory(), function_name);
@ -4594,7 +4608,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
factory()->NewAssignment(fvar_init_op,
fproxy,
factory()->NewThisFunction(),
RelocInfo::kNoPosition)));
RelocInfo::kNoPosition)),
zone());
}
ParseSourceElements(body, Token::RBRACE, false, CHECK_OK);
@ -4993,7 +5008,7 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) {
// the break target to any TargetCollectors passed on the stack.
for (Target* t = target_stack_; t != stop; t = t->previous()) {
TargetCollector* collector = t->node()->AsTargetCollector();
if (collector != NULL) collector->AddTarget(target);
if (collector != NULL) collector->AddTarget(target, zone());
}
}
@ -5040,9 +5055,9 @@ Expression* Parser::NewThrowError(Handle<String> constructor,
Handle<JSArray> array = isolate()->factory()->NewJSArrayWithElements(
elements, FAST_ELEMENTS, TENURED);
ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2);
args->Add(factory()->NewLiteral(type));
args->Add(factory()->NewLiteral(array));
ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2, zone());
args->Add(factory()->NewLiteral(type), zone());
args->Add(factory()->NewLiteral(array), zone());
CallRuntime* call_constructor =
factory()->NewCallRuntime(constructor, NULL, args);
return factory()->NewThrow(call_constructor, scanner().location().beg_pos);
@ -5236,8 +5251,8 @@ RegExpTree* RegExpParser::ParseDisjunction() {
Advance();
// everything except \x0a, \x0d, \u2028 and \u2029
ZoneList<CharacterRange>* ranges =
new(zone()) ZoneList<CharacterRange>(2);
CharacterRange::AddClassEscape('.', ranges);
new(zone()) ZoneList<CharacterRange>(2, zone());
CharacterRange::AddClassEscape('.', ranges, zone());
RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false);
builder->AddAtom(atom);
break;
@ -5263,12 +5278,12 @@ RegExpTree* RegExpParser::ParseDisjunction() {
Advance(2);
} else {
if (captures_ == NULL) {
captures_ = new(zone()) ZoneList<RegExpCapture*>(2);
captures_ = new(zone()) ZoneList<RegExpCapture*>(2, zone());
}
if (captures_started() >= kMaxCaptures) {
ReportError(CStrVector("Too many captures") CHECK_FAILED);
}
captures_->Add(NULL);
captures_->Add(NULL, zone());
}
// Store current state and begin new disjunction parsing.
stored_state = new(zone()) RegExpParserState(stored_state, type,
@ -5306,8 +5321,8 @@ RegExpTree* RegExpParser::ParseDisjunction() {
uc32 c = Next();
Advance(2);
ZoneList<CharacterRange>* ranges =
new(zone()) ZoneList<CharacterRange>(2);
CharacterRange::AddClassEscape(c, ranges);
new(zone()) ZoneList<CharacterRange>(2, zone());
CharacterRange::AddClassEscape(c, ranges, zone());
RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false);
builder->AddAtom(atom);
break;
@ -5782,11 +5797,12 @@ static const uc16 kNoCharClass = 0;
// escape (i.e., 's' means whitespace, from '\s').
static inline void AddRangeOrEscape(ZoneList<CharacterRange>* ranges,
uc16 char_class,
CharacterRange range) {
CharacterRange range,
Zone* zone) {
if (char_class != kNoCharClass) {
CharacterRange::AddClassEscape(char_class, ranges);
CharacterRange::AddClassEscape(char_class, ranges, zone);
} else {
ranges->Add(range);
ranges->Add(range, zone);
}
}
@ -5802,7 +5818,8 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
is_negated = true;
Advance();
}
ZoneList<CharacterRange>* ranges = new(zone()) ZoneList<CharacterRange>(2);
ZoneList<CharacterRange>* ranges =
new(zone()) ZoneList<CharacterRange>(2, zone());
while (has_more() && current() != ']') {
uc16 char_class = kNoCharClass;
CharacterRange first = ParseClassAtom(&char_class CHECK_FAILED);
@ -5813,25 +5830,25 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
// following code report an error.
break;
} else if (current() == ']') {
AddRangeOrEscape(ranges, char_class, first);
ranges->Add(CharacterRange::Singleton('-'));
AddRangeOrEscape(ranges, char_class, first, zone());
ranges->Add(CharacterRange::Singleton('-'), zone());
break;
}
uc16 char_class_2 = kNoCharClass;
CharacterRange next = ParseClassAtom(&char_class_2 CHECK_FAILED);
if (char_class != kNoCharClass || char_class_2 != kNoCharClass) {
// Either end is an escaped character class. Treat the '-' verbatim.
AddRangeOrEscape(ranges, char_class, first);
ranges->Add(CharacterRange::Singleton('-'));
AddRangeOrEscape(ranges, char_class_2, next);
AddRangeOrEscape(ranges, char_class, first, zone());
ranges->Add(CharacterRange::Singleton('-'), zone());
AddRangeOrEscape(ranges, char_class_2, next, zone());
continue;
}
if (first.from() > next.to()) {
return ReportError(CStrVector(kRangeOutOfOrder) CHECK_FAILED);
}
ranges->Add(CharacterRange::Range(first.from(), next.to()));
ranges->Add(CharacterRange::Range(first.from(), next.to()), zone());
} else {
AddRangeOrEscape(ranges, char_class, first);
AddRangeOrEscape(ranges, char_class, first, zone());
}
}
if (!has_more()) {
@ -5839,7 +5856,7 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
}
Advance();
if (ranges->length() == 0) {
ranges->Add(CharacterRange::Everything());
ranges->Add(CharacterRange::Everything(), zone());
is_negated = !is_negated;
}
return new(zone()) RegExpCharacterClass(ranges, is_negated);

View File

@ -200,12 +200,12 @@ class BufferedZoneList {
// Adds element at end of list. This element is buffered and can
// be read using last() or removed using RemoveLast until a new Add or until
// RemoveLast or GetList has been called.
void Add(T* value) {
void Add(T* value, Zone* zone) {
if (last_ != NULL) {
if (list_ == NULL) {
list_ = new ZoneList<T*>(initial_size);
list_ = new(zone) ZoneList<T*>(initial_size, zone);
}
list_->Add(last_);
list_->Add(last_, zone);
}
last_ = value;
}
@ -250,12 +250,12 @@ class BufferedZoneList {
return length + ((last_ == NULL) ? 0 : 1);
}
ZoneList<T*>* GetList() {
ZoneList<T*>* GetList(Zone* zone) {
if (list_ == NULL) {
list_ = new ZoneList<T*>(initial_size);
list_ = new(zone) ZoneList<T*>(initial_size, zone);
}
if (last_ != NULL) {
list_->Add(last_);
list_->Add(last_, zone);
last_ = NULL;
}
return list_;
@ -285,7 +285,7 @@ class RegExpBuilder: public ZoneObject {
void FlushCharacters();
void FlushText();
void FlushTerms();
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
Zone* zone_;
bool pending_empty_;
@ -371,7 +371,7 @@ class RegExpParser {
int disjunction_capture_index,
Zone* zone)
: previous_state_(previous_state),
builder_(new RegExpBuilder(zone)),
builder_(new(zone) RegExpBuilder(zone)),
group_type_(group_type),
disjunction_capture_index_(disjunction_capture_index) {}
// Parser state of containing expression, if any.
@ -398,7 +398,7 @@ class RegExpParser {
};
Isolate* isolate() { return isolate_; }
Zone* zone() { return isolate_->zone(); }
Zone* zone() const { return isolate_->zone(); }
uc32 current() { return current_; }
bool has_more() { return has_more_; }
@ -548,7 +548,7 @@ class Parser {
ZoneScope* zone_scope);
Isolate* isolate() { return isolate_; }
Zone* zone() { return zone_; }
Zone* zone() const { return zone_; }
// Called by ParseProgram after setting up the scanner.
FunctionLiteral* DoParseProgram(CompilationInfo* info,

View File

@ -35,6 +35,7 @@ namespace internal {
RegExpMacroAssemblerTracer::RegExpMacroAssemblerTracer(
RegExpMacroAssembler* assembler) :
RegExpMacroAssembler(assembler->zone()),
assembler_(assembler) {
unsigned int type = assembler->Implementation();
ASSERT(type < 5);

View File

@ -35,9 +35,10 @@
namespace v8 {
namespace internal {
RegExpMacroAssembler::RegExpMacroAssembler()
RegExpMacroAssembler::RegExpMacroAssembler(Zone* zone)
: slow_safe_compiler_(false),
global_mode_(NOT_GLOBAL) {
global_mode_(NOT_GLOBAL),
zone_(zone) {
}
@ -56,8 +57,8 @@ bool RegExpMacroAssembler::CanReadUnaligned() {
#ifndef V8_INTERPRETED_REGEXP // Avoid unused code, e.g., on ARM.
NativeRegExpMacroAssembler::NativeRegExpMacroAssembler()
: RegExpMacroAssembler() {
NativeRegExpMacroAssembler::NativeRegExpMacroAssembler(Zone* zone)
: RegExpMacroAssembler(zone) {
}

View File

@ -63,7 +63,7 @@ class RegExpMacroAssembler {
kCheckStackLimit = true
};
RegExpMacroAssembler();
explicit RegExpMacroAssembler(Zone* zone);
virtual ~RegExpMacroAssembler();
// The maximal number of pushes between stack checks. Users must supply
// kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck)
@ -189,9 +189,12 @@ class RegExpMacroAssembler {
return global_mode_ == GLOBAL;
}
Zone* zone() const { return zone_; }
private:
bool slow_safe_compiler_;
bool global_mode_;
Zone* zone_;
};
@ -213,7 +216,7 @@ class NativeRegExpMacroAssembler: public RegExpMacroAssembler {
// capture positions.
enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 };
NativeRegExpMacroAssembler();
explicit NativeRegExpMacroAssembler(Zone* zone);
virtual ~NativeRegExpMacroAssembler();
virtual bool CanReadUnaligned();

View File

@ -262,7 +262,7 @@ bool Rewriter::Rewrite(CompilationInfo* info) {
Statement* result_statement =
processor.factory()->NewReturnStatement(result_proxy);
result_statement->set_statement_pos(position);
body->Add(result_statement);
body->Add(result_statement, info->isolate()->zone());
}
}

View File

@ -2528,8 +2528,10 @@ class ReplacementStringBuilder {
class CompiledReplacement {
public:
CompiledReplacement()
: parts_(1), replacement_substrings_(0), simple_hint_(false) {}
explicit CompiledReplacement(Zone* zone)
: parts_(1, zone), replacement_substrings_(0, zone),
simple_hint_(false),
zone_(zone) {}
void Compile(Handle<String> replacement,
int capture_count,
@ -2549,6 +2551,8 @@ class CompiledReplacement {
return simple_hint_;
}
Zone* zone() const { return zone_; }
private:
enum PartType {
SUBJECT_PREFIX = 1,
@ -2610,7 +2614,8 @@ class CompiledReplacement {
static bool ParseReplacementPattern(ZoneList<ReplacementPart>* parts,
Vector<Char> characters,
int capture_count,
int subject_length) {
int subject_length,
Zone* zone) {
int length = characters.length();
int last = 0;
for (int i = 0; i < length; i++) {
@ -2625,7 +2630,8 @@ class CompiledReplacement {
case '$':
if (i > last) {
// There is a substring before. Include the first "$".
parts->Add(ReplacementPart::ReplacementSubString(last, next_index));
parts->Add(ReplacementPart::ReplacementSubString(last, next_index),
zone);
last = next_index + 1; // Continue after the second "$".
} else {
// Let the next substring start with the second "$".
@ -2635,25 +2641,25 @@ class CompiledReplacement {
break;
case '`':
if (i > last) {
parts->Add(ReplacementPart::ReplacementSubString(last, i));
parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
}
parts->Add(ReplacementPart::SubjectPrefix());
parts->Add(ReplacementPart::SubjectPrefix(), zone);
i = next_index;
last = i + 1;
break;
case '\'':
if (i > last) {
parts->Add(ReplacementPart::ReplacementSubString(last, i));
parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
}
parts->Add(ReplacementPart::SubjectSuffix(subject_length));
parts->Add(ReplacementPart::SubjectSuffix(subject_length), zone);
i = next_index;
last = i + 1;
break;
case '&':
if (i > last) {
parts->Add(ReplacementPart::ReplacementSubString(last, i));
parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
}
parts->Add(ReplacementPart::SubjectMatch());
parts->Add(ReplacementPart::SubjectMatch(), zone);
i = next_index;
last = i + 1;
break;
@ -2686,10 +2692,10 @@ class CompiledReplacement {
}
if (capture_ref > 0) {
if (i > last) {
parts->Add(ReplacementPart::ReplacementSubString(last, i));
parts->Add(ReplacementPart::ReplacementSubString(last, i), zone);
}
ASSERT(capture_ref <= capture_count);
parts->Add(ReplacementPart::SubjectCapture(capture_ref));
parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone);
last = next_index + 1;
}
i = next_index;
@ -2703,10 +2709,10 @@ class CompiledReplacement {
}
if (length > last) {
if (last == 0) {
parts->Add(ReplacementPart::ReplacementString());
parts->Add(ReplacementPart::ReplacementString(), zone);
return true;
} else {
parts->Add(ReplacementPart::ReplacementSubString(last, length));
parts->Add(ReplacementPart::ReplacementSubString(last, length), zone);
}
}
return false;
@ -2715,6 +2721,7 @@ class CompiledReplacement {
ZoneList<ReplacementPart> parts_;
ZoneList<Handle<String> > replacement_substrings_;
bool simple_hint_;
Zone* zone_;
};
@ -2729,13 +2736,15 @@ void CompiledReplacement::Compile(Handle<String> replacement,
simple_hint_ = ParseReplacementPattern(&parts_,
content.ToAsciiVector(),
capture_count,
subject_length);
subject_length,
zone());
} else {
ASSERT(content.IsTwoByte());
simple_hint_ = ParseReplacementPattern(&parts_,
content.ToUC16Vector(),
capture_count,
subject_length);
subject_length,
zone());
}
}
Isolate* isolate = replacement->GetIsolate();
@ -2747,12 +2756,12 @@ void CompiledReplacement::Compile(Handle<String> replacement,
int from = -tag;
int to = parts_[i].data;
replacement_substrings_.Add(
isolate->factory()->NewSubString(replacement, from, to));
isolate->factory()->NewSubString(replacement, from, to), zone());
parts_[i].tag = REPLACEMENT_SUBSTRING;
parts_[i].data = substring_index;
substring_index++;
} else if (tag == REPLACEMENT_STRING) {
replacement_substrings_.Add(replacement);
replacement_substrings_.Add(replacement, zone());
parts_[i].data = substring_index;
substring_index++;
}
@ -2801,7 +2810,8 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
void FindAsciiStringIndices(Vector<const char> subject,
char pattern,
ZoneList<int>* indices,
unsigned int limit) {
unsigned int limit,
Zone* zone) {
ASSERT(limit > 0);
// Collect indices of pattern in subject using memchr.
// Stop after finding at most limit values.
@ -2812,7 +2822,7 @@ void FindAsciiStringIndices(Vector<const char> subject,
pos = reinterpret_cast<const char*>(
memchr(pos, pattern, subject_end - pos));
if (pos == NULL) return;
indices->Add(static_cast<int>(pos - subject_start));
indices->Add(static_cast<int>(pos - subject_start), zone);
pos++;
limit--;
}
@ -2824,7 +2834,8 @@ void FindStringIndices(Isolate* isolate,
Vector<const SubjectChar> subject,
Vector<const PatternChar> pattern,
ZoneList<int>* indices,
unsigned int limit) {
unsigned int limit,
Zone* zone) {
ASSERT(limit > 0);
// Collect indices of pattern in subject.
// Stop after finding at most limit values.
@ -2834,7 +2845,7 @@ void FindStringIndices(Isolate* isolate,
while (limit > 0) {
index = search.Search(subject, index);
if (index < 0) return;
indices->Add(index);
indices->Add(index, zone);
index += pattern_length;
limit--;
}
@ -2845,7 +2856,8 @@ void FindStringIndicesDispatch(Isolate* isolate,
String* subject,
String* pattern,
ZoneList<int>* indices,
unsigned int limit) {
unsigned int limit,
Zone* zone) {
{
AssertNoAllocation no_gc;
String::FlatContent subject_content = subject->GetFlatContent();
@ -2860,20 +2872,23 @@ void FindStringIndicesDispatch(Isolate* isolate,
FindAsciiStringIndices(subject_vector,
pattern_vector[0],
indices,
limit);
limit,
zone);
} else {
FindStringIndices(isolate,
subject_vector,
pattern_vector,
indices,
limit);
limit,
zone);
}
} else {
FindStringIndices(isolate,
subject_vector,
pattern_content.ToUC16Vector(),
indices,
limit);
limit,
zone);
}
} else {
Vector<const uc16> subject_vector = subject_content.ToUC16Vector();
@ -2882,13 +2897,15 @@ void FindStringIndicesDispatch(Isolate* isolate,
subject_vector,
pattern_content.ToAsciiVector(),
indices,
limit);
limit,
zone);
} else {
FindStringIndices(isolate,
subject_vector,
pattern_content.ToUC16Vector(),
indices,
limit);
limit,
zone);
}
}
}
@ -2967,12 +2984,13 @@ MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString(
Handle<String> subject,
Handle<JSRegExp> pattern_regexp,
Handle<String> replacement,
Handle<JSArray> last_match_info) {
Handle<JSArray> last_match_info,
Zone* zone) {
ASSERT(subject->IsFlat());
ASSERT(replacement->IsFlat());
ZoneScope zone_space(isolate, DELETE_ON_EXIT);
ZoneList<int> indices(8);
ZoneList<int> indices(8, isolate->zone());
ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
String* pattern =
String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex));
@ -2980,7 +2998,8 @@ MUST_USE_RESULT static MaybeObject* StringReplaceAtomRegExpWithString(
int pattern_len = pattern->length();
int replacement_len = replacement->length();
FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff);
FindStringIndicesDispatch(isolate, *subject, pattern, &indices, 0xffffffff,
zone);
int matches = indices.length();
if (matches == 0) return *subject;
@ -3049,7 +3068,8 @@ MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString(
String* subject,
JSRegExp* regexp,
String* replacement,
JSArray* last_match_info) {
JSArray* last_match_info,
Zone* zone) {
ASSERT(subject->IsFlat());
ASSERT(replacement->IsFlat());
@ -3075,8 +3095,8 @@ MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString(
int capture_count = regexp_handle->CaptureCount();
// CompiledReplacement uses zone allocation.
ZoneScope zone(isolate, DELETE_ON_EXIT);
CompiledReplacement compiled_replacement;
ZoneScope zonescope(isolate, DELETE_ON_EXIT);
CompiledReplacement compiled_replacement(isolate->zone());
compiled_replacement.Compile(replacement_handle,
capture_count,
length);
@ -3094,14 +3114,16 @@ MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString(
subject_handle,
regexp_handle,
replacement_handle,
last_match_info_handle);
last_match_info_handle,
zone);
} else {
return StringReplaceAtomRegExpWithString<SeqTwoByteString>(
isolate,
subject_handle,
regexp_handle,
replacement_handle,
last_match_info_handle);
last_match_info_handle,
zone);
}
}
@ -3184,7 +3206,8 @@ MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString(
Isolate* isolate,
String* subject,
JSRegExp* regexp,
JSArray* last_match_info) {
JSArray* last_match_info,
Zone* zone) {
ASSERT(subject->IsFlat());
HandleScope handles(isolate);
@ -3203,14 +3226,16 @@ MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString(
subject_handle,
regexp_handle,
empty_string_handle,
last_match_info_handle);
last_match_info_handle,
zone);
} else {
return StringReplaceAtomRegExpWithString<SeqTwoByteString>(
isolate,
subject_handle,
regexp_handle,
empty_string_handle,
last_match_info_handle);
last_match_info_handle,
zone);
}
}
@ -3369,13 +3394,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) {
ASSERT(last_match_info->HasFastObjectElements());
Zone* zone = isolate->zone();
if (replacement->length() == 0) {
if (subject->HasOnlyAsciiChars()) {
return StringReplaceRegExpWithEmptyString<SeqAsciiString>(
isolate, subject, regexp, last_match_info);
isolate, subject, regexp, last_match_info, zone);
} else {
return StringReplaceRegExpWithEmptyString<SeqTwoByteString>(
isolate, subject, regexp, last_match_info);
isolate, subject, regexp, last_match_info, zone);
}
}
@ -3383,7 +3409,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) {
subject,
regexp,
replacement,
last_match_info);
last_match_info,
zone);
}
@ -3717,8 +3744,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
}
int length = subject->length();
Zone* zone = isolate->zone();
ZoneScope zone_space(isolate, DELETE_ON_EXIT);
ZoneList<int> offsets(8);
ZoneList<int> offsets(8, zone);
int start;
int end;
do {
@ -3728,8 +3756,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value();
end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value();
}
offsets.Add(start);
offsets.Add(end);
offsets.Add(start, zone);
offsets.Add(end, zone);
if (start == end) if (++end > length) break;
match = RegExpImpl::Exec(regexp, subject, end, regexp_info,
isolate->zone());
@ -6435,17 +6463,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
static const int kMaxInitialListCapacity = 16;
Zone* zone = isolate->zone();
ZoneScope scope(isolate, DELETE_ON_EXIT);
// 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);
ZoneList<int> indices(initial_capacity, zone);
if (!pattern->IsFlat()) FlattenString(pattern);
FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit);
FindStringIndicesDispatch(isolate, *subject, *pattern, &indices, limit, zone);
if (static_cast<uint32_t>(indices.length()) < limit) {
indices.Add(subject_length);
indices.Add(subject_length, zone);
}
// The list indices now contains the end of each part to create.
@ -9284,13 +9313,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
ASSERT_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
Zone* zone = isolate->zone();
source = Handle<String>(source->TryFlattenGetString());
// Optimized fast case where we only have ASCII characters.
Handle<Object> result;
if (source->IsSeqAsciiString()) {
result = JsonParser<true>::Parse(source);
result = JsonParser<true>::Parse(source, zone);
} else {
result = JsonParser<false>::Parse(source);
result = JsonParser<false>::Parse(source, zone);
}
if (result.is_null()) {
// Syntax error or stack overflow in scanner.
@ -12745,7 +12775,8 @@ 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);
return *LiveEdit::CheckAndDropActivations(shared_array, do_drop,
isolate->zone());
}
// Compares 2 strings line-by-line, then token-wise and returns diff in form

View File

@ -116,8 +116,8 @@ void SafepointTable::PrintBits(uint8_t byte, int digits) {
}
void Safepoint::DefinePointerRegister(Register reg) {
registers_->Add(reg.code());
void Safepoint::DefinePointerRegister(Register reg, Zone* zone) {
registers_->Add(reg.code(), zone);
}
@ -128,18 +128,20 @@ Safepoint SafepointTableBuilder::DefineSafepoint(
Safepoint::DeoptMode deopt_mode) {
ASSERT(arguments >= 0);
DeoptimizationInfo info;
Zone* zone = assembler->zone();
info.pc = assembler->pc_offset();
info.arguments = arguments;
info.has_doubles = (kind & Safepoint::kWithDoubles);
deoptimization_info_.Add(info);
deopt_index_list_.Add(Safepoint::kNoDeoptimizationIndex);
deoptimization_info_.Add(info, zone);
deopt_index_list_.Add(Safepoint::kNoDeoptimizationIndex, zone);
if (deopt_mode == Safepoint::kNoLazyDeopt) {
last_lazy_safepoint_ = deopt_index_list_.length();
}
indexes_.Add(new ZoneList<int>(8));
indexes_.Add(new(zone) ZoneList<int>(8, zone), zone);
registers_.Add((kind & Safepoint::kWithRegisters)
? new ZoneList<int>(4)
: NULL);
? new(zone) ZoneList<int>(4, zone)
: NULL,
zone);
return Safepoint(indexes_.last(), registers_.last());
}
@ -160,6 +162,7 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
// For lazy deoptimization we need space to patch a call after every call.
// Ensure there is always space for such patching, even if the code ends
// in a call.
Zone* zone = assembler->zone();
int target_offset = assembler->pc_offset() + Deoptimizer::patch_size();
while (assembler->pc_offset() < target_offset) {
assembler->nop();
@ -190,12 +193,12 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
}
// Emit table of bitmaps.
ZoneList<uint8_t> bits(bytes_per_entry);
ZoneList<uint8_t> bits(bytes_per_entry, zone);
for (int i = 0; i < length; i++) {
ZoneList<int>* indexes = indexes_[i];
ZoneList<int>* registers = registers_[i];
bits.Clear();
bits.AddBlock(0, bytes_per_entry);
bits.AddBlock(0, bytes_per_entry, zone);
// Run through the registers (if any).
ASSERT(IsAligned(kNumSafepointRegisters, kBitsPerByte));

View File

@ -184,7 +184,7 @@ class Safepoint BASE_EMBEDDED {
(1 << (SafepointEntry::kDeoptIndexBits)) - 1;
void DefinePointerSlot(int index, Zone* zone) { indexes_->Add(index, zone); }
void DefinePointerRegister(Register reg);
void DefinePointerRegister(Register reg, Zone* zone);
private:
Safepoint(ZoneList<int>* indexes, ZoneList<int>* registers) :

View File

@ -38,10 +38,10 @@ namespace v8 {
namespace internal {
Handle<ScopeInfo> ScopeInfo::Create(Scope* scope) {
Handle<ScopeInfo> ScopeInfo::Create(Scope* scope, Zone* zone) {
// Collect stack and context locals.
ZoneList<Variable*> stack_locals(scope->StackLocalCount());
ZoneList<Variable*> context_locals(scope->ContextLocalCount());
ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone);
ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone);
scope->CollectStackAndContextLocals(&stack_locals, &context_locals);
const int stack_local_count = stack_locals.length();
const int context_local_count = context_locals.length();

View File

@ -57,7 +57,9 @@ static bool Match(void* key1, void* key2) {
}
VariableMap::VariableMap() : ZoneHashMap(Match, 8) {}
VariableMap::VariableMap(Zone* zone)
: ZoneHashMap(Match, 8, ZoneAllocationPolicy(zone)),
zone_(zone) {}
VariableMap::~VariableMap() {}
@ -69,24 +71,26 @@ Variable* VariableMap::Declare(
Variable::Kind kind,
InitializationFlag initialization_flag,
Interface* interface) {
Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), true);
Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), true,
ZoneAllocationPolicy(zone()));
if (p->value == NULL) {
// The variable has not been declared yet -> insert it.
ASSERT(p->key == name.location());
p->value = new Variable(scope,
name,
mode,
is_valid_lhs,
kind,
initialization_flag,
interface);
p->value = new(zone()) Variable(scope,
name,
mode,
is_valid_lhs,
kind,
initialization_flag,
interface);
}
return reinterpret_cast<Variable*>(p->value);
}
Variable* VariableMap::Lookup(Handle<String> name) {
Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), false);
Entry* p = ZoneHashMap::Lookup(name.location(), name->Hash(), false,
ZoneAllocationPolicy(NULL));
if (p != NULL) {
ASSERT(*reinterpret_cast<String**>(p->key) == *name);
ASSERT(p->value != NULL);
@ -99,18 +103,19 @@ Variable* VariableMap::Lookup(Handle<String> name) {
// ----------------------------------------------------------------------------
// Implementation of Scope
Scope::Scope(Scope* outer_scope, ScopeType type)
Scope::Scope(Scope* outer_scope, ScopeType type, Zone* zone)
: isolate_(Isolate::Current()),
inner_scopes_(4),
variables_(),
temps_(4),
params_(4),
unresolved_(16),
decls_(4),
inner_scopes_(4, zone),
variables_(zone),
temps_(4, zone),
params_(4, zone),
unresolved_(16, zone),
decls_(4, zone),
interface_(FLAG_harmony_modules &&
(type == MODULE_SCOPE || type == GLOBAL_SCOPE)
? Interface::NewModule() : NULL),
already_resolved_(false) {
? Interface::NewModule(zone) : NULL),
already_resolved_(false),
zone_(zone) {
SetDefaults(type, outer_scope, Handle<ScopeInfo>::null());
// At some point we might want to provide outer scopes to
// eval scopes (by walking the stack and reading the scope info).
@ -122,16 +127,18 @@ Scope::Scope(Scope* outer_scope, ScopeType type)
Scope::Scope(Scope* inner_scope,
ScopeType type,
Handle<ScopeInfo> scope_info)
Handle<ScopeInfo> scope_info,
Zone* zone)
: isolate_(Isolate::Current()),
inner_scopes_(4),
variables_(),
temps_(4),
params_(4),
unresolved_(16),
decls_(4),
inner_scopes_(4, zone),
variables_(zone),
temps_(4, zone),
params_(4, zone),
unresolved_(16, zone),
decls_(4, zone),
interface_(NULL),
already_resolved_(true) {
already_resolved_(true),
zone_(zone) {
SetDefaults(type, NULL, scope_info);
if (!scope_info.is_null()) {
num_heap_slots_ = scope_info_->ContextLength();
@ -143,16 +150,17 @@ Scope::Scope(Scope* inner_scope,
}
Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name)
Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone)
: isolate_(Isolate::Current()),
inner_scopes_(1),
variables_(),
temps_(0),
params_(0),
unresolved_(0),
decls_(0),
inner_scopes_(1, zone),
variables_(zone),
temps_(0, zone),
params_(0, zone),
unresolved_(0, zone),
decls_(0, zone),
interface_(NULL),
already_resolved_(true) {
already_resolved_(true),
zone_(zone) {
SetDefaults(CATCH_SCOPE, NULL, Handle<ScopeInfo>::null());
AddInnerScope(inner_scope);
++num_var_or_const_;
@ -200,16 +208,18 @@ void Scope::SetDefaults(ScopeType type,
}
Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope) {
Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope,
Zone* zone) {
// Reconstruct the outer scope chain from a closure's context chain.
Scope* current_scope = NULL;
Scope* innermost_scope = NULL;
bool contains_with = false;
while (!context->IsGlobalContext()) {
if (context->IsWithContext()) {
Scope* with_scope = new Scope(current_scope,
WITH_SCOPE,
Handle<ScopeInfo>::null());
Scope* with_scope = new(zone) Scope(current_scope,
WITH_SCOPE,
Handle<ScopeInfo>::null(),
zone);
current_scope = with_scope;
// All the inner scopes are inside a with.
contains_with = true;
@ -218,18 +228,21 @@ Scope* Scope::DeserializeScopeChain(Context* context, Scope* global_scope) {
}
} else if (context->IsFunctionContext()) {
ScopeInfo* scope_info = context->closure()->shared()->scope_info();
current_scope = new Scope(current_scope,
FUNCTION_SCOPE,
Handle<ScopeInfo>(scope_info));
current_scope = new(zone) Scope(current_scope,
FUNCTION_SCOPE,
Handle<ScopeInfo>(scope_info),
zone);
} else if (context->IsBlockContext()) {
ScopeInfo* scope_info = ScopeInfo::cast(context->extension());
current_scope = new Scope(current_scope,
BLOCK_SCOPE,
Handle<ScopeInfo>(scope_info));
current_scope = new(zone) Scope(current_scope,
BLOCK_SCOPE,
Handle<ScopeInfo>(scope_info),
zone);
} else {
ASSERT(context->IsCatchContext());
String* name = String::cast(context->extension());
current_scope = new Scope(current_scope, Handle<String>(name));
current_scope = new(zone) Scope(
current_scope, Handle<String>(name), zone);
}
if (contains_with) current_scope->RecordWithStatement();
if (innermost_scope == NULL) innermost_scope = current_scope;
@ -305,7 +318,7 @@ void Scope::Initialize() {
// Add this scope as a new inner scope of the outer scope.
if (outer_scope_ != NULL) {
outer_scope_->inner_scopes_.Add(this);
outer_scope_->inner_scopes_.Add(this, zone());
scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope();
} else {
scope_inside_with_ = is_with_scope();
@ -370,7 +383,7 @@ Scope* Scope::FinalizeBlockScope() {
// Move unresolved variables
for (int i = 0; i < unresolved_.length(); i++) {
outer_scope()->unresolved_.Add(unresolved_[i]);
outer_scope()->unresolved_.Add(unresolved_[i], zone());
}
return NULL;
@ -401,13 +414,8 @@ Variable* Scope::LocalLookup(Handle<String> name) {
init_flag = kCreatedInitialized;
}
Variable* var =
variables_.Declare(this,
name,
mode,
true,
Variable::NORMAL,
init_flag);
Variable* var = variables_.Declare(this, name, mode, true, Variable::NORMAL,
init_flag);
var->AllocateTo(location, index);
return var;
}
@ -422,7 +430,7 @@ Variable* Scope::LookupFunctionVar(Handle<String> name,
VariableMode mode;
int index = scope_info_->FunctionContextSlotIndex(*name, &mode);
if (index < 0) return NULL;
Variable* var = new Variable(
Variable* var = new(zone()) Variable(
this, name, mode, true /* is valid LHS */,
Variable::NORMAL, kCreatedInitialized);
VariableProxy* proxy = factory->NewVariableProxy(var);
@ -451,9 +459,9 @@ Variable* Scope::Lookup(Handle<String> name) {
void Scope::DeclareParameter(Handle<String> name, VariableMode mode) {
ASSERT(!already_resolved());
ASSERT(is_function_scope());
Variable* var = variables_.Declare(
this, name, mode, true, Variable::NORMAL, kCreatedInitialized);
params_.Add(var);
Variable* var = variables_.Declare(this, name, mode, true, Variable::NORMAL,
kCreatedInitialized);
params_.Add(var, zone());
}
@ -500,19 +508,19 @@ void Scope::RemoveUnresolved(VariableProxy* var) {
Variable* Scope::NewTemporary(Handle<String> name) {
ASSERT(!already_resolved());
Variable* var = new Variable(this,
name,
TEMPORARY,
true,
Variable::NORMAL,
kCreatedInitialized);
temps_.Add(var);
Variable* var = new(zone()) Variable(this,
name,
TEMPORARY,
true,
Variable::NORMAL,
kCreatedInitialized);
temps_.Add(var, zone());
return var;
}
void Scope::AddDeclaration(Declaration* declaration) {
decls_.Add(declaration);
decls_.Add(declaration, zone());
}
@ -588,7 +596,7 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
Variable* var = temps_[i];
if (var->is_used()) {
ASSERT(var->IsStackLocal());
stack_locals->Add(var);
stack_locals->Add(var, zone());
}
}
@ -599,9 +607,9 @@ void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
Variable* var = reinterpret_cast<Variable*>(p->value);
if (var->is_used()) {
if (var->IsStackLocal()) {
stack_locals->Add(var);
stack_locals->Add(var, zone());
} else if (var->IsContextSlot()) {
context_locals->Add(var);
context_locals->Add(var, zone());
}
}
}
@ -699,7 +707,7 @@ Scope* Scope::DeclarationScope() {
Handle<ScopeInfo> Scope::GetScopeInfo() {
if (scope_info_.is_null()) {
scope_info_ = ScopeInfo::Create(this);
scope_info_ = ScopeInfo::Create(this, zone());
}
return scope_info_;
}
@ -885,7 +893,7 @@ void Scope::Print(int n) {
Variable* Scope::NonLocal(Handle<String> name, VariableMode mode) {
if (dynamics_ == NULL) dynamics_ = new DynamicScopePart();
if (dynamics_ == NULL) dynamics_ = new(zone()) DynamicScopePart(zone());
VariableMap* map = dynamics_->GetMap(mode);
Variable* var = map->Lookup(name);
if (var == NULL) {
@ -1019,7 +1027,7 @@ bool Scope::ResolveVariable(CompilationInfo* info,
if (FLAG_print_interface_details)
PrintF("# Resolve %s:\n", var->name()->ToAsciiArray());
#endif
proxy->interface()->Unify(var->interface(), &ok);
proxy->interface()->Unify(var->interface(), zone(), &ok);
if (!ok) {
#ifdef DEBUG
if (FLAG_print_interfaces) {

View File

@ -40,7 +40,7 @@ class CompilationInfo;
// A hash map to support fast variable declaration and lookup.
class VariableMap: public ZoneHashMap {
public:
VariableMap();
explicit VariableMap(Zone* zone);
virtual ~VariableMap();
@ -53,6 +53,11 @@ class VariableMap: public ZoneHashMap {
Interface* interface = Interface::NewValue());
Variable* Lookup(Handle<String> name);
Zone* zone() const { return zone_; }
private:
Zone* zone_;
};
@ -62,14 +67,19 @@ class VariableMap: public ZoneHashMap {
// and setup time for scopes that don't need them.
class DynamicScopePart : public ZoneObject {
public:
explicit DynamicScopePart(Zone* zone) {
for (int i = 0; i < 3; i++)
maps_[i] = new(zone->New(sizeof(VariableMap))) VariableMap(zone);
}
VariableMap* GetMap(VariableMode mode) {
int index = mode - DYNAMIC;
ASSERT(index >= 0 && index < 3);
return &maps_[index];
return maps_[index];
}
private:
VariableMap maps_[3];
VariableMap *maps_[3];
};
@ -87,14 +97,15 @@ class Scope: public ZoneObject {
// ---------------------------------------------------------------------------
// Construction
Scope(Scope* outer_scope, ScopeType type);
Scope(Scope* outer_scope, ScopeType type, Zone* zone);
// Compute top scope and allocate variables. For lazy compilation the top
// scope only contains the single lazily compiled function, so this
// doesn't re-allocate variables repeatedly.
static bool Analyze(CompilationInfo* info);
static Scope* DeserializeScopeChain(Context* context, Scope* global_scope);
static Scope* DeserializeScopeChain(Context* context, Scope* global_scope,
Zone* zone);
// The scope name is only used for printing/debugging.
void SetScopeName(Handle<String> scope_name) { scope_name_ = scope_name; }
@ -106,6 +117,8 @@ class Scope: public ZoneObject {
// tree and its children are reparented.
Scope* FinalizeBlockScope();
Zone* zone() const { return zone_; }
// ---------------------------------------------------------------------------
// Declarations
@ -161,7 +174,7 @@ class Scope: public ZoneObject {
ASSERT(!already_resolved());
VariableProxy* proxy =
factory->NewVariableProxy(name, false, position, interface);
unresolved_.Add(proxy);
unresolved_.Add(proxy, zone_);
return proxy;
}
@ -581,14 +594,15 @@ class Scope: public ZoneObject {
private:
// Construct a scope based on the scope info.
Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info);
Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info,
Zone* zone);
// Construct a catch scope with a binding for the name.
Scope(Scope* inner_scope, Handle<String> catch_variable_name);
Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone);
void AddInnerScope(Scope* inner_scope) {
if (inner_scope != NULL) {
inner_scopes_.Add(inner_scope);
inner_scopes_.Add(inner_scope, zone_);
inner_scope->outer_scope_ = this;
}
}
@ -596,6 +610,8 @@ class Scope: public ZoneObject {
void SetDefaults(ScopeType type,
Scope* outer_scope,
Handle<ScopeInfo> scope_info);
Zone* zone_;
};
} } // namespace v8::internal

View File

@ -44,22 +44,22 @@ class SmallPointerList {
public:
SmallPointerList() : data_(kEmptyTag) {}
explicit SmallPointerList(int capacity) : data_(kEmptyTag) {
Reserve(capacity);
SmallPointerList(int capacity, Zone* zone) : data_(kEmptyTag) {
Reserve(capacity, zone);
}
void Reserve(int capacity) {
void Reserve(int capacity, Zone* zone) {
if (capacity < 2) return;
if ((data_ & kTagMask) == kListTag) {
if (list()->capacity() >= capacity) return;
int old_length = list()->length();
list()->AddBlock(NULL, capacity - list()->capacity());
list()->AddBlock(NULL, capacity - list()->capacity(), zone);
list()->Rewind(old_length);
return;
}
PointerList* list = new PointerList(capacity);
PointerList* list = new(zone) PointerList(capacity, zone);
if ((data_ & kTagMask) == kSingletonTag) {
list->Add(single_value());
list->Add(single_value(), zone);
}
ASSERT(IsAligned(reinterpret_cast<intptr_t>(list), kPointerAlignment));
data_ = reinterpret_cast<intptr_t>(list) | kListTag;
@ -83,21 +83,21 @@ class SmallPointerList {
return list()->length();
}
void Add(T* pointer) {
void Add(T* pointer, Zone* zone) {
ASSERT(IsAligned(reinterpret_cast<intptr_t>(pointer), kPointerAlignment));
if ((data_ & kTagMask) == kEmptyTag) {
data_ = reinterpret_cast<intptr_t>(pointer) | kSingletonTag;
return;
}
if ((data_ & kTagMask) == kSingletonTag) {
PointerList* list = new PointerList(2);
list->Add(single_value());
list->Add(pointer);
PointerList* list = new(zone) PointerList(2, zone);
list->Add(single_value(), zone);
list->Add(pointer, zone);
ASSERT(IsAligned(reinterpret_cast<intptr_t>(list), kPointerAlignment));
data_ = reinterpret_cast<intptr_t>(list) | kListTag;
return;
}
list()->Add(pointer);
list()->Add(pointer, zone);
}
// Note: returns T* and not T*& (unlike List from list.h).

View File

@ -43,11 +43,10 @@ SplayTree<Config, Allocator>::~SplayTree() {
template<typename Config, class Allocator>
bool SplayTree<Config, Allocator>::Insert(const Key& key,
Locator* locator,
Allocator allocator) {
Locator* locator) {
if (is_empty()) {
// If the tree is empty, insert the new node.
root_ = new(allocator) Node(key, Config::NoValue());
root_ = new(allocator_) Node(key, Config::NoValue());
} else {
// Splay on the key to move the last node on the search path
// for the key to the root of the tree.
@ -59,7 +58,7 @@ bool SplayTree<Config, Allocator>::Insert(const Key& key,
return false;
}
// Insert the new node.
Node* node = new(allocator) Node(key, Config::NoValue());
Node* node = new(allocator_) Node(key, Config::NoValue());
InsertInternal(cmp, node);
}
locator->bind(root_);
@ -293,16 +292,15 @@ void SplayTree<Config, Allocator>::ForEach(Callback* callback) {
template <typename Config, class Allocator> template <class Callback>
void SplayTree<Config, Allocator>::ForEachNode(Callback* callback,
Allocator allocator) {
void SplayTree<Config, Allocator>::ForEachNode(Callback* callback) {
// Pre-allocate some space for tiny trees.
List<Node*, Allocator> nodes_to_visit(10);
if (root_ != NULL) nodes_to_visit.Add(root_, allocator);
List<Node*, Allocator> nodes_to_visit(10, allocator_);
if (root_ != NULL) nodes_to_visit.Add(root_, allocator_);
int pos = 0;
while (pos < nodes_to_visit.length()) {
Node* node = nodes_to_visit[pos++];
if (node->left() != NULL) nodes_to_visit.Add(node->left(), allocator);
if (node->right() != NULL) nodes_to_visit.Add(node->right(), allocator);
if (node->left() != NULL) nodes_to_visit.Add(node->left(), allocator_);
if (node->right() != NULL) nodes_to_visit.Add(node->right(), allocator_);
callback->Call(node);
}
}

View File

@ -58,7 +58,8 @@ class SplayTree {
class Locator;
SplayTree() : root_(NULL) { }
SplayTree(AllocationPolicy allocator = AllocationPolicy())
: root_(NULL), allocator_(allocator) { }
~SplayTree();
INLINE(void* operator new(size_t size,
@ -72,8 +73,7 @@ class SplayTree {
// Inserts the given key in this tree with the given value. Returns
// true if a node was inserted, otherwise false. If found the locator
// is enabled and provides access to the mapping for the key.
bool Insert(const Key& key, Locator* locator,
AllocationPolicy allocator = AllocationPolicy());
bool Insert(const Key& key, Locator* locator);
// Looks up the key in this tree and returns true if it was found,
// otherwise false. If the node is found the locator is enabled and
@ -195,10 +195,10 @@ class SplayTree {
};
template <class Callback>
void ForEachNode(Callback* callback,
AllocationPolicy allocator = AllocationPolicy());
void ForEachNode(Callback* callback);
Node* root_;
AllocationPolicy allocator_;
DISALLOW_COPY_AND_ASSIGN(SplayTree);
};

View File

@ -43,7 +43,8 @@ namespace internal {
// StubCache implementation.
StubCache::StubCache(Isolate* isolate) : isolate_(isolate) {
StubCache::StubCache(Isolate* isolate, Zone* zone)
: isolate_(isolate), zone_(zone) {
ASSERT(isolate == Isolate::Current());
}
@ -919,7 +920,7 @@ void StubCache::CollectMatchingMaps(SmallMapList* types,
int offset = PrimaryOffset(name, flags, map);
if (entry(primary_, offset) == &primary_[i] &&
!TypeFeedbackOracle::CanRetainOtherContext(map, *global_context)) {
types->Add(Handle<Map>(map));
types->Add(Handle<Map>(map), zone());
}
}
}
@ -943,7 +944,7 @@ void StubCache::CollectMatchingMaps(SmallMapList* types,
int offset = SecondaryOffset(name, flags, primary_offset);
if (entry(secondary_, offset) == &secondary_[i] &&
!TypeFeedbackOracle::CanRetainOtherContext(map, *global_context)) {
types->Add(Handle<Map>(map));
types->Add(Handle<Map>(map), zone());
}
}
}

View File

@ -305,9 +305,10 @@ class StubCache {
Isolate* isolate() { return isolate_; }
Heap* heap() { return isolate()->heap(); }
Factory* factory() { return isolate()->factory(); }
Zone* zone() const { return zone_; }
private:
explicit StubCache(Isolate* isolate);
StubCache(Isolate* isolate, Zone* zone);
Handle<Code> ComputeCallInitialize(int argc,
RelocInfo::Mode mode,
@ -380,6 +381,7 @@ class StubCache {
Entry primary_[kPrimaryTableSize];
Entry secondary_[kSecondaryTableSize];
Isolate* isolate_;
Zone* zone_;
friend class Isolate;
friend class SCTableReference;

View File

@ -61,9 +61,11 @@ TypeInfo TypeInfo::TypeFromValue(Handle<Object> value) {
TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code,
Handle<Context> global_context,
Isolate* isolate) {
Isolate* isolate,
Zone* zone) {
global_context_ = global_context;
isolate_ = isolate;
zone_ = zone;
BuildDictionary(code);
ASSERT(reinterpret_cast<Address>(*dictionary_.location()) != kHandleZapValue);
}
@ -501,10 +503,10 @@ void TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id,
// we need a generic store (or load) here.
ASSERT(Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC);
} else if (object->IsMap()) {
types->Add(Handle<Map>::cast(object));
types->Add(Handle<Map>::cast(object), zone());
} else if (FLAG_collect_megamorphic_maps_from_stub_cache &&
Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) {
types->Reserve(4);
types->Reserve(4, zone());
ASSERT(object->IsCode());
isolate_->stub_cache()->CollectMatchingMaps(types,
*name,
@ -548,11 +550,12 @@ bool TypeFeedbackOracle::CanRetainOtherContext(JSFunction* function,
}
static void AddMapIfMissing(Handle<Map> map, SmallMapList* list) {
static void AddMapIfMissing(Handle<Map> map, SmallMapList* list,
Zone* zone) {
for (int i = 0; i < list->length(); ++i) {
if (list->at(i).is_identical_to(map)) return;
}
list->Add(map);
list->Add(map, zone);
}
@ -571,7 +574,7 @@ void TypeFeedbackOracle::CollectKeyedReceiverTypes(unsigned ast_id,
if (object->IsMap()) {
Map* map = Map::cast(object);
if (!CanRetainOtherContext(map, *global_context_)) {
AddMapIfMissing(Handle<Map>(map), types);
AddMapIfMissing(Handle<Map>(map), types, zone());
}
}
}
@ -591,7 +594,7 @@ byte TypeFeedbackOracle::ToBooleanTypes(unsigned ast_id) {
// infos before we process them.
void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) {
AssertNoAllocation no_allocation;
ZoneList<RelocInfo> infos(16);
ZoneList<RelocInfo> infos(16, zone());
HandleScope scope;
GetRelocInfos(code, &infos);
CreateDictionary(code, &infos);
@ -606,7 +609,7 @@ void TypeFeedbackOracle::GetRelocInfos(Handle<Code> code,
ZoneList<RelocInfo>* infos) {
int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID);
for (RelocIterator it(*code, mask); !it.done(); it.next()) {
infos->Add(*it.rinfo());
infos->Add(*it.rinfo(), zone());
}
}

View File

@ -236,7 +236,8 @@ class TypeFeedbackOracle BASE_EMBEDDED {
public:
TypeFeedbackOracle(Handle<Code> code,
Handle<Context> global_context,
Isolate* isolate);
Isolate* isolate,
Zone* zone);
bool LoadIsMonomorphicNormal(Property* expr);
bool LoadIsUninitialized(Property* expr);
@ -293,6 +294,8 @@ class TypeFeedbackOracle BASE_EMBEDDED {
TypeInfo SwitchType(CaseClause* clause);
TypeInfo IncrementType(CountOperation* expr);
Zone* zone() const { return zone_; }
private:
void CollectReceiverTypes(unsigned ast_id,
Handle<String> name,
@ -317,6 +320,7 @@ class TypeFeedbackOracle BASE_EMBEDDED {
Handle<Context> global_context_;
Isolate* isolate_;
Handle<UnseededNumberDictionary> dictionary_;
Zone* zone_;
DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);
};

View File

@ -345,7 +345,7 @@ static void InitCoverageLog();
#endif
Assembler::Assembler(Isolate* arg_isolate, void* buffer, int buffer_size)
: AssemblerBase(arg_isolate),
: AssemblerBase(arg_isolate, arg_isolate->zone()),
code_targets_(100),
positions_recorder_(this),
emit_debug_code_(FLAG_debug_code) {

View File

@ -779,10 +779,11 @@ void FullCodeGenerator::VisitVariableDeclaration(
bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET;
switch (variable->location()) {
case Variable::UNALLOCATED:
globals_->Add(variable->name());
globals_->Add(variable->name(), zone());
globals_->Add(variable->binding_needs_init()
? isolate()->factory()->the_hole_value()
: isolate()->factory()->undefined_value());
: isolate()->factory()->undefined_value(),
zone());
break;
case Variable::PARAMETER:
@ -837,12 +838,12 @@ void FullCodeGenerator::VisitFunctionDeclaration(
Variable* variable = proxy->var();
switch (variable->location()) {
case Variable::UNALLOCATED: {
globals_->Add(variable->name());
globals_->Add(variable->name(), zone());
Handle<SharedFunctionInfo> function =
Compiler::BuildFunctionInfo(declaration->fun(), script());
// Check for stack-overflow exception.
if (function.is_null()) return SetStackOverflow();
globals_->Add(function);
globals_->Add(function, zone());
break;
}
@ -894,8 +895,8 @@ void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
switch (variable->location()) {
case Variable::UNALLOCATED: {
Comment cmnt(masm_, "[ ModuleDeclaration");
globals_->Add(variable->name());
globals_->Add(instance);
globals_->Add(variable->name(), zone());
globals_->Add(instance, zone());
Visit(declaration->module());
break;
}
@ -1567,7 +1568,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
// Mark all computed expressions that are bound to a key that
// is shadowed by a later occurrence of the same key. For the
// marked expressions, no store code is emitted.
expr->CalculateEmitStore();
expr->CalculateEmitStore(zone());
AccessorTable accessor_table(isolate()->zone());
for (int i = 0; i < expr->properties()->length(); i++) {

View File

@ -553,7 +553,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) {
// jump entry if this is the case.
if (jump_table_.is_empty() ||
jump_table_.last().address != entry) {
jump_table_.Add(JumpTableEntry(entry));
jump_table_.Add(JumpTableEntry(entry), zone());
}
__ j(cc, &jump_table_.last().label);
}
@ -598,7 +598,7 @@ int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
for (int i = 0; i < deoptimization_literals_.length(); ++i) {
if (deoptimization_literals_[i].is_identical_to(literal)) return i;
}
deoptimization_literals_.Add(literal);
deoptimization_literals_.Add(literal, zone());
return result;
}
@ -647,12 +647,12 @@ void LCodeGen::RecordSafepoint(
if (pointer->IsStackSlot()) {
safepoint.DefinePointerSlot(pointer->index(), zone());
} else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
safepoint.DefinePointerRegister(ToRegister(pointer));
safepoint.DefinePointerRegister(ToRegister(pointer), zone());
}
}
if (kind & Safepoint::kWithRegisters) {
// Register rsi always contains a pointer to the context.
safepoint.DefinePointerRegister(rsi);
safepoint.DefinePointerRegister(rsi, zone());
}
}
@ -664,7 +664,7 @@ void LCodeGen::RecordSafepoint(LPointerMap* pointers,
void LCodeGen::RecordSafepoint(Safepoint::DeoptMode deopt_mode) {
LPointerMap empty_pointers(RelocInfo::kNoPosition);
LPointerMap empty_pointers(RelocInfo::kNoPosition, zone());
RecordSafepoint(&empty_pointers, deopt_mode);
}
@ -1942,7 +1942,7 @@ void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
DeferredInstanceOfKnownGlobal* deferred;
deferred = new DeferredInstanceOfKnownGlobal(this, instr);
deferred = new(zone()) DeferredInstanceOfKnownGlobal(this, instr);
Label done, false_result;
Register object = ToRegister(instr->InputAt(0));
@ -2880,7 +2880,7 @@ void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) {
EmitIntegerMathAbs(instr);
} else { // Tagged case.
DeferredMathAbsTaggedHeapNumber* deferred =
new DeferredMathAbsTaggedHeapNumber(this, instr);
new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr);
Register input_reg = ToRegister(instr->InputAt(0));
// Smi check.
__ JumpIfNotSmi(input_reg, deferred->entry());
@ -3072,7 +3072,7 @@ void LCodeGen::DoRandom(LRandom* instr) {
LRandom* instr_;
};
DeferredDoRandom* deferred = new DeferredDoRandom(this, instr);
DeferredDoRandom* deferred = new(zone()) DeferredDoRandom(this, instr);
// Having marked this instruction as a call we can use any
// registers.
@ -3614,7 +3614,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
};
DeferredStringCharCodeAt* deferred =
new DeferredStringCharCodeAt(this, instr);
new(zone()) DeferredStringCharCodeAt(this, instr);
StringCharLoadGenerator::Generate(masm(),
ToRegister(instr->string()),
@ -3668,7 +3668,7 @@ void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
};
DeferredStringCharFromCode* deferred =
new DeferredStringCharFromCode(this, instr);
new(zone()) DeferredStringCharFromCode(this, instr);
ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
Register char_code = ToRegister(instr->char_code());
@ -3748,7 +3748,7 @@ void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
Register reg = ToRegister(instr->result());
Register tmp = ToRegister(instr->TempAt(0));
DeferredNumberTagD* deferred = new DeferredNumberTagD(this, instr);
DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr);
if (FLAG_inline_new) {
__ AllocateHeapNumber(reg, tmp, deferred->entry());
} else {
@ -3908,7 +3908,7 @@ void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
ASSERT(input->Equals(instr->result()));
Register input_reg = ToRegister(input);
DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr);
DeferredTaggedToI* deferred = new(zone()) DeferredTaggedToI(this, instr);
__ JumpIfNotSmi(input_reg, deferred->entry());
__ SmiToInteger32(input_reg, input_reg);
__ bind(deferred->exit());
@ -4162,7 +4162,8 @@ void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
LAllocateObject* instr_;
};
DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
DeferredAllocateObject* deferred =
new(zone()) DeferredAllocateObject(this, instr);
Register result = ToRegister(instr->result());
Register scratch = ToRegister(instr->TempAt(0));
@ -4784,7 +4785,7 @@ void LCodeGen::DoStackCheck(LStackCheck* instr) {
ASSERT(instr->hydrogen()->is_backwards_branch());
// Perform stack overflow check if this goto needs it before jumping.
DeferredStackCheck* deferred_stack_check =
new DeferredStackCheck(this, instr);
new(zone()) DeferredStackCheck(this, instr);
__ CompareRoot(rsp, Heap::kStackLimitRootIndex);
__ j(below, deferred_stack_check->entry());
EnsureSpaceForLazyDeopt(Deoptimizer::patch_size());

View File

@ -53,20 +53,20 @@ class LCodeGen BASE_EMBEDDED {
current_block_(-1),
current_instruction_(-1),
instructions_(chunk->instructions()),
deoptimizations_(4),
jump_table_(4),
deoptimization_literals_(8),
deoptimizations_(4, zone),
jump_table_(4, zone),
deoptimization_literals_(8, zone),
inlined_function_count_(0),
scope_(info->scope()),
status_(UNUSED),
translations_(zone),
deferred_(8),
deferred_(8, zone),
osr_pc_offset_(-1),
last_lazy_deopt_pc_(0),
safepoints_(zone),
zone_(zone),
resolver_(this),
expected_safepoint_kind_(Safepoint::kSimple),
zone_(zone) {
expected_safepoint_kind_(Safepoint::kSimple) {
PopulateDeoptimizationLiteralsWithInlinedFunctions();
}
@ -160,7 +160,7 @@ class LCodeGen BASE_EMBEDDED {
void Abort(const char* format, ...);
void Comment(const char* format, ...);
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); }
void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code, zone()); }
// Code generation passes. Returns true if code generation should
// continue.
@ -346,13 +346,13 @@ class LCodeGen BASE_EMBEDDED {
// itself is emitted at the end of the generated code.
SafepointTableBuilder safepoints_;
Zone* zone_;
// Compiler from a set of parallel moves to a sequential list of moves.
LGapResolver resolver_;
Safepoint::Kind expected_safepoint_kind_;
Zone* zone_;
class PushSafepointRegistersScope BASE_EMBEDDED {
public:
explicit PushSafepointRegistersScope(LCodeGen* codegen)

View File

@ -36,7 +36,7 @@ namespace v8 {
namespace internal {
LGapResolver::LGapResolver(LCodeGen* owner)
: cgen_(owner), moves_(32) {}
: cgen_(owner), moves_(32, owner->zone()) {}
void LGapResolver::Resolve(LParallelMove* parallel_move) {
@ -74,7 +74,7 @@ void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) {
const ZoneList<LMoveOperands>* moves = parallel_move->move_operands();
for (int i = 0; i < moves->length(); ++i) {
LMoveOperands move = moves->at(i);
if (!move.IsRedundant()) moves_.Add(move);
if (!move.IsRedundant()) moves_.Add(move, cgen_->zone());
}
Verify();
}

View File

@ -369,9 +369,9 @@ LOperand* LChunk::GetNextSpillSlot(bool is_double) {
// stack slots for int32 values.
int index = GetNextSpillIndex(is_double);
if (is_double) {
return LDoubleStackSlot::Create(index);
return LDoubleStackSlot::Create(index, zone());
} else {
return LStackSlot::Create(index);
return LStackSlot::Create(index, zone());
}
}
@ -467,23 +467,23 @@ void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block);
int index = -1;
if (instr->IsControl()) {
instructions_.Add(gap);
instructions_.Add(gap, zone());
index = instructions_.length();
instructions_.Add(instr);
instructions_.Add(instr, zone());
} else {
index = instructions_.length();
instructions_.Add(instr);
instructions_.Add(gap);
instructions_.Add(instr, zone());
instructions_.Add(gap, zone());
}
if (instr->HasPointerMap()) {
pointer_maps_.Add(instr->pointer_map());
pointer_maps_.Add(instr->pointer_map(), zone());
instr->pointer_map()->set_lithium_position(index);
}
}
LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) {
return LConstantOperand::Create(constant->id());
return LConstantOperand::Create(constant->id(), zone());
}
@ -522,7 +522,8 @@ int LChunk::NearestGapPos(int index) const {
void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to);
GetGapAt(index)->GetOrCreateParallelMove(
LGap::START, zone())->AddMove(from, to, zone());
}
@ -757,7 +758,7 @@ LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
ASSERT(!instr->HasPointerMap());
instr->set_pointer_map(new(zone()) LPointerMap(position_));
instr->set_pointer_map(new(zone()) LPointerMap(position_, zone()));
return instr;
}
@ -1594,7 +1595,7 @@ LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
LOperand* object = UseFixed(instr->value(), rax);
LDateField* result = new LDateField(object, instr->index());
LDateField* result = new(zone()) LDateField(object, instr->index());
return MarkAsCall(DefineFixed(result, rax), instr);
}
@ -2103,7 +2104,7 @@ LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) {
LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) {
LAllocateObject* result = new LAllocateObject(TempRegister());
LAllocateObject* result = new(zone()) LAllocateObject(TempRegister());
return AssignPointerMap(DefineAsRegister(result));
}

View File

@ -333,8 +333,11 @@ class LGap: public LTemplateInstruction<0, 0, 0> {
LAST_INNER_POSITION = AFTER
};
LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
Zone* zone) {
if (parallel_moves_[pos] == NULL) {
parallel_moves_[pos] = new(zone) LParallelMove(zone);
}
return parallel_moves_[pos];
}
@ -2161,13 +2164,13 @@ class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> {
class LChunkBuilder;
class LChunk: public ZoneObject {
public:
explicit LChunk(CompilationInfo* info, HGraph* graph)
LChunk(CompilationInfo* info, HGraph* graph)
: spill_slot_count_(0),
info_(info),
graph_(graph),
instructions_(32),
pointer_maps_(8),
inlined_closures_(1) { }
instructions_(32, graph->zone()),
pointer_maps_(8, graph->zone()),
inlined_closures_(1, graph->zone()) { }
void AddInstruction(LInstruction* instruction, HBasicBlock* block);
LConstantOperand* DefineConstantOperand(HConstant* constant);
@ -2212,9 +2215,11 @@ class LChunk: public ZoneObject {
}
void AddInlinedClosure(Handle<JSFunction> closure) {
inlined_closures_.Add(closure);
inlined_closures_.Add(closure, zone());
}
Zone* zone() const { return graph_->zone(); }
private:
int spill_slot_count_;
CompilationInfo* info_;

View File

@ -117,10 +117,12 @@ namespace internal {
RegExpMacroAssemblerX64::RegExpMacroAssemblerX64(
Mode mode,
int registers_to_save)
: masm_(Isolate::Current(), NULL, kRegExpCodeSize),
int registers_to_save,
Zone* zone)
: NativeRegExpMacroAssembler(zone),
masm_(Isolate::Current(), NULL, kRegExpCodeSize),
no_root_array_scope_(&masm_),
code_relative_fixup_positions_(4),
code_relative_fixup_positions_(4, zone),
mode_(mode),
num_registers_(registers_to_save),
num_saved_registers_(registers_to_save),

View File

@ -41,7 +41,7 @@ namespace internal {
class RegExpMacroAssemblerX64: public NativeRegExpMacroAssembler {
public:
RegExpMacroAssemblerX64(Mode mode, int registers_to_save);
RegExpMacroAssemblerX64(Mode mode, int registers_to_save, Zone* zone);
virtual ~RegExpMacroAssemblerX64();
virtual int stack_limit_slack();
virtual void AdvanceCurrentPosition(int by);
@ -240,7 +240,7 @@ class RegExpMacroAssemblerX64: public NativeRegExpMacroAssembler {
void BranchOrBacktrack(Condition condition, Label* to);
void MarkPositionForCodeRelativeFixup() {
code_relative_fixup_positions_.Add(masm_.pc_offset());
code_relative_fixup_positions_.Add(masm_.pc_offset(), zone());
}
void FixupCodeRelativePositions();

View File

@ -94,29 +94,13 @@ ZoneSplayTree<Config>::~ZoneSplayTree() {
}
// TODO(isolates): for performance reasons, this should be replaced with a new
// operator that takes the zone in which the object should be
// allocated.
void* ZoneObject::operator new(size_t size) {
return ZONE->New(static_cast<int>(size));
}
void* ZoneObject::operator new(size_t size, Zone* zone) {
return zone->New(static_cast<int>(size));
}
inline void* ZoneAllocationPolicy::New(size_t size) {
if (zone_) {
return zone_->New(size);
} else {
return ZONE->New(size);
}
}
template <typename T>
void* ZoneList<T>::operator new(size_t size) {
return ZONE->New(static_cast<int>(size));
ASSERT(zone_);
return zone_->New(size);
}

View File

@ -148,7 +148,6 @@ class Zone {
class ZoneObject {
public:
// Allocate a new ZoneObject of 'size' bytes in the Zone.
INLINE(void* operator new(size_t size));
INLINE(void* operator new(size_t size, Zone* zone));
// Ideally, the delete operator should be private instead of
@ -168,7 +167,7 @@ class ZoneObject {
// structures to allocate themselves and their elements in the Zone.
struct ZoneAllocationPolicy {
public:
explicit ZoneAllocationPolicy(Zone* zone = NULL) : zone_(zone) { }
explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) { }
INLINE(void* New(size_t size));
INLINE(static void Delete(void *pointer)) { }
@ -186,14 +185,13 @@ class ZoneList: public List<T, ZoneAllocationPolicy> {
public:
// Construct a new ZoneList with the given capacity; the length is
// always zero. The capacity must be non-negative.
explicit ZoneList(int capacity, Zone* zone = NULL)
ZoneList(int capacity, Zone* zone)
: List<T, ZoneAllocationPolicy>(capacity, ZoneAllocationPolicy(zone)) { }
INLINE(void* operator new(size_t size, Zone* zone));
INLINE(void* operator new(size_t size));
// Construct a new ZoneList by copying the elements of the given ZoneList.
explicit ZoneList(const ZoneList<T>& other, Zone* zone = NULL)
ZoneList(const ZoneList<T>& other, Zone* zone)
: List<T, ZoneAllocationPolicy>(other.length(),
ZoneAllocationPolicy(zone)) {
AddAll(other, ZoneAllocationPolicy(zone));
@ -201,28 +199,28 @@ class ZoneList: public List<T, ZoneAllocationPolicy> {
// We add some convenience wrappers so that we can pass in a Zone
// instead of a (less convenient) ZoneAllocationPolicy.
INLINE(void Add(const T& element, Zone* zone = NULL)) {
INLINE(void Add(const T& element, Zone* zone)) {
List<T, ZoneAllocationPolicy>::Add(element, ZoneAllocationPolicy(zone));
}
INLINE(void AddAll(const List<T, ZoneAllocationPolicy>& other,
Zone* zone = NULL)) {
Zone* zone)) {
List<T, ZoneAllocationPolicy>::AddAll(other, ZoneAllocationPolicy(zone));
}
INLINE(void AddAll(const Vector<T>& other, Zone* zone = NULL)) {
INLINE(void AddAll(const Vector<T>& other, Zone* zone)) {
List<T, ZoneAllocationPolicy>::AddAll(other, ZoneAllocationPolicy(zone));
}
INLINE(void InsertAt(int index, const T& element, Zone* zone = NULL)) {
INLINE(void InsertAt(int index, const T& element, Zone* zone)) {
List<T, ZoneAllocationPolicy>::InsertAt(index, element,
ZoneAllocationPolicy(zone));
}
INLINE(Vector<T> AddBlock(T value, int count, Zone* zone = NULL)) {
INLINE(Vector<T> AddBlock(T value, int count, Zone* zone)) {
return List<T, ZoneAllocationPolicy>::AddBlock(value, count,
ZoneAllocationPolicy(zone));
}
INLINE(void Allocate(int length, Zone* zone = NULL)) {
INLINE(void Allocate(int length, Zone* zone)) {
List<T, ZoneAllocationPolicy>::Allocate(length, ZoneAllocationPolicy(zone));
}
INLINE(void Initialize(int capacity, Zone* zone = NULL)) {
INLINE(void Initialize(int capacity, Zone* zone)) {
List<T, ZoneAllocationPolicy>::Initialize(capacity,
ZoneAllocationPolicy(zone));
}
@ -263,8 +261,8 @@ class ZoneScope BASE_EMBEDDED {
template <typename Config>
class ZoneSplayTree: public SplayTree<Config, ZoneAllocationPolicy> {
public:
ZoneSplayTree()
: SplayTree<Config, ZoneAllocationPolicy>() {}
explicit ZoneSplayTree(Zone* zone)
: SplayTree<Config, ZoneAllocationPolicy>(ZoneAllocationPolicy(zone)) {}
~ZoneSplayTree();
};

View File

@ -37,7 +37,7 @@ using namespace v8::internal;
TEST(BitVector) {
v8::internal::V8::Initialize(NULL);
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
Zone* zone = ZONE;
Zone* zone = Isolate::Current()->zone();
{
BitVector v(15, zone);
v.Add(1);

View File

@ -81,7 +81,8 @@ class ListDiffOutputWriter : public Comparator::Output {
(*next_chunk_pointer_) = NULL;
}
void AddChunk(int pos1, int pos2, int len1, int len2) {
current_chunk_ = new DiffChunkStruct(pos1, pos2, len1, len2);
current_chunk_ =
new(Isolate::Current()->zone()) DiffChunkStruct(pos1, pos2, len1, len2);
(*next_chunk_pointer_) = current_chunk_;
next_chunk_pointer_ = &current_chunk_->next;
}

View File

@ -88,7 +88,8 @@ static SmartArrayPointer<const char> Parse(const char* input) {
CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result));
CHECK(result.tree != NULL);
CHECK(result.error.is_null());
SmartArrayPointer<const char> output = result.tree->ToString();
SmartArrayPointer<const char> output =
result.tree->ToString(Isolate::Current()->zone());
return output;
}
@ -469,8 +470,10 @@ static bool NotWord(uc16 c) {
static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) {
ZoneScope scope(Isolate::Current(), DELETE_ON_EXIT);
ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
CharacterRange::AddClassEscape(c, ranges);
Zone* zone = Isolate::Current()->zone();
ZoneList<CharacterRange>* ranges =
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++) {
@ -564,7 +567,7 @@ TEST(SplayTreeSimple) {
v8::internal::V8::Initialize(NULL);
static const unsigned kLimit = 1000;
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
ZoneSplayTree<TestConfig> tree;
ZoneSplayTree<TestConfig> tree(Isolate::Current()->zone());
bool seen[kLimit];
for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
#define CHECK_MAPS_EQUAL() do { \
@ -632,11 +635,12 @@ TEST(DispatchTableConstruction) {
}
// Enter test data into dispatch table.
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
DispatchTable table;
DispatchTable table(Isolate::Current()->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);
table.AddRange(CharacterRange(range[j], range[j + 1]), i,
Isolate::Current()->zone());
}
// Check that the table looks as we would expect
for (int p = 0; p < kLimit; p++) {
@ -736,7 +740,8 @@ TEST(MacroAssemblerNativeSuccess) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
Isolate::Current()->zone());
m.Succeed();
@ -771,7 +776,8 @@ TEST(MacroAssemblerNativeSimple) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
Isolate::Current()->zone());
uc16 foo_chars[3] = {'f', 'o', 'o'};
Vector<const uc16> foo(foo_chars, 3);
@ -828,7 +834,8 @@ TEST(MacroAssemblerNativeSimpleUC16) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4,
Isolate::Current()->zone());
uc16 foo_chars[3] = {'f', 'o', 'o'};
Vector<const uc16> foo(foo_chars, 3);
@ -890,7 +897,8 @@ TEST(MacroAssemblerNativeBacktrack) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0,
Isolate::Current()->zone());
Label fail;
Label backtrack;
@ -928,7 +936,8 @@ TEST(MacroAssemblerNativeBackReferenceASCII) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
Isolate::Current()->zone());
m.WriteCurrentPositionToRegister(0, 0);
m.AdvanceCurrentPosition(2);
@ -975,7 +984,8 @@ TEST(MacroAssemblerNativeBackReferenceUC16) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::UC16, 4,
Isolate::Current()->zone());
m.WriteCurrentPositionToRegister(0, 0);
m.AdvanceCurrentPosition(2);
@ -1025,7 +1035,8 @@ TEST(MacroAssemblernativeAtStart) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0,
Isolate::Current()->zone());
Label not_at_start, newline, fail;
m.CheckNotAtStart(&not_at_start);
@ -1082,7 +1093,8 @@ TEST(MacroAssemblerNativeBackRefNoCase) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4,
Isolate::Current()->zone());
Label fail, succ;
@ -1139,7 +1151,8 @@ TEST(MacroAssemblerNativeRegisters) {
ContextInitializer initializer;
Factory* factory = Isolate::Current()->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6,
Isolate::Current()->zone());
uc16 foo_chars[3] = {'f', 'o', 'o'};
Vector<const uc16> foo(foo_chars, 3);
@ -1241,7 +1254,8 @@ TEST(MacroAssemblerStackOverflow) {
Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0,
Isolate::Current()->zone());
Label loop;
m.Bind(&loop);
@ -1279,7 +1293,8 @@ TEST(MacroAssemblerNativeLotsOfRegisters) {
Isolate* isolate = Isolate::Current();
Factory* factory = isolate->factory();
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2);
ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2,
Isolate::Current()->zone());
// At least 2048, to ensure the allocated space for registers
// span one full page.
@ -1397,16 +1412,18 @@ TEST(AddInverseToTable) {
static const int kRangeCount = 16;
for (int t = 0; t < 10; t++) {
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
Zone* zone = Isolate::Current()->zone();
ZoneList<CharacterRange>* ranges =
new ZoneList<CharacterRange>(kRangeCount);
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));
ranges->Add(CharacterRange(from, to), zone);
}
DispatchTable table;
DispatchTableConstructor cons(&table, false);
DispatchTable table(zone);
DispatchTableConstructor cons(&table, false, Isolate::Current()->zone());
cons.set_choice_index(0);
cons.AddInverse(ranges);
for (int i = 0; i < kLimit; i++) {
@ -1418,11 +1435,12 @@ TEST(AddInverseToTable) {
}
}
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
Zone* zone = Isolate::Current()->zone();
ZoneList<CharacterRange>* ranges =
new ZoneList<CharacterRange>(1);
ranges->Add(CharacterRange(0xFFF0, 0xFFFE));
DispatchTable table;
DispatchTableConstructor cons(&table, false);
new(zone) ZoneList<CharacterRange>(1, zone);
ranges->Add(CharacterRange(0xFFF0, 0xFFFE), zone);
DispatchTable table(zone);
DispatchTableConstructor cons(&table, false, Isolate::Current()->zone());
cons.set_choice_index(0);
cons.AddInverse(ranges);
CHECK(!table.Get(0xFFFE)->Get(0));
@ -1531,9 +1549,11 @@ TEST(UncanonicalizeEquivalence) {
static void TestRangeCaseIndependence(CharacterRange input,
Vector<CharacterRange> expected) {
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
Zone* zone = Isolate::Current()->zone();
int count = expected.length();
ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(count);
input.AddCaseEquivalents(list, false);
ZoneList<CharacterRange>* list =
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());
@ -1595,12 +1615,15 @@ static bool InClass(uc16 c, ZoneList<CharacterRange>* ranges) {
TEST(CharClassDifference) {
v8::internal::V8::Initialize(NULL);
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
ZoneList<CharacterRange>* base = new ZoneList<CharacterRange>(1);
base->Add(CharacterRange::Everything());
Zone* zone = Isolate::Current()->zone();
ZoneList<CharacterRange>* base =
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);
CharacterRange::Split(base, overlay, &included, &excluded,
Isolate::Current()->zone());
for (int i = 0; i < (1 << 16); i++) {
bool in_base = InClass(i, base);
if (in_base) {
@ -1622,12 +1645,14 @@ TEST(CharClassDifference) {
TEST(CanonicalizeCharacterSets) {
v8::internal::V8::Initialize(NULL);
ZoneScope scope(Isolate::Current(), DELETE_ON_EXIT);
ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(4);
Zone* zone = Isolate::Current()->zone();
ZoneList<CharacterRange>* list =
new(zone) ZoneList<CharacterRange>(4, zone);
CharacterSet set(list);
list->Add(CharacterRange(10, 20));
list->Add(CharacterRange(30, 40));
list->Add(CharacterRange(50, 60));
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());
@ -1638,9 +1663,9 @@ TEST(CanonicalizeCharacterSets) {
ASSERT_EQ(60, list->at(2).to());
list->Rewind(0);
list->Add(CharacterRange(10, 20));
list->Add(CharacterRange(50, 60));
list->Add(CharacterRange(30, 40));
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());
@ -1651,11 +1676,11 @@ TEST(CanonicalizeCharacterSets) {
ASSERT_EQ(60, list->at(2).to());
list->Rewind(0);
list->Add(CharacterRange(30, 40));
list->Add(CharacterRange(10, 20));
list->Add(CharacterRange(25, 25));
list->Add(CharacterRange(100, 100));
list->Add(CharacterRange(1, 1));
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());
@ -1670,9 +1695,9 @@ TEST(CanonicalizeCharacterSets) {
ASSERT_EQ(100, list->at(4).to());
list->Rewind(0);
list->Add(CharacterRange(10, 19));
list->Add(CharacterRange(21, 30));
list->Add(CharacterRange(20, 20));
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());
@ -1683,8 +1708,9 @@ TEST(CanonicalizeCharacterSets) {
TEST(CharacterRangeMerge) {
v8::internal::V8::Initialize(NULL);
ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
ZoneList<CharacterRange> l1(4);
ZoneList<CharacterRange> l2(4);
ZoneList<CharacterRange> l1(4, Isolate::Current()->zone());
ZoneList<CharacterRange> l2(4, Isolate::Current()->zone());
Zone* zone = Isolate::Current()->zone();
// Create all combinations of intersections of ranges, both singletons and
// longer.
@ -1699,8 +1725,8 @@ TEST(CharacterRangeMerge) {
// Y - outside after
for (int i = 0; i < 5; i++) {
l1.Add(CharacterRange::Singleton(offset + 2));
l2.Add(CharacterRange::Singleton(offset + i));
l1.Add(CharacterRange::Singleton(offset + 2), zone);
l2.Add(CharacterRange::Singleton(offset + i), zone);
offset += 6;
}
@ -1715,8 +1741,8 @@ TEST(CharacterRangeMerge) {
// Y - disjoint after
for (int i = 0; i < 7; i++) {
l1.Add(CharacterRange::Range(offset + 2, offset + 4));
l2.Add(CharacterRange::Singleton(offset + i));
l1.Add(CharacterRange::Range(offset + 2, offset + 4), zone);
l2.Add(CharacterRange::Singleton(offset + i), zone);
offset += 8;
}
@ -1736,35 +1762,35 @@ TEST(CharacterRangeMerge) {
// YYYYYYYYYYYY - containing entirely.
for (int i = 0; i < 9; i++) {
l1.Add(CharacterRange::Range(offset + 6, offset + 15)); // Length 8.
l2.Add(CharacterRange::Range(offset + 2 * i, offset + 2 * i + 3));
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));
l2.Add(CharacterRange::Range(offset + 6, offset + 15));
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));
l2.Add(CharacterRange::Range(offset + 4, offset + 17));
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));
l1.Add(CharacterRange::Range(offset + 31, offset + 52));
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));
l2.Add(CharacterRange::Singleton(offset + 8));
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);
ZoneList<CharacterRange> second_only(4);
ZoneList<CharacterRange> both(4);
ZoneList<CharacterRange> first_only(4, Isolate::Current()->zone());
ZoneList<CharacterRange> second_only(4, Isolate::Current()->zone());
ZoneList<CharacterRange> both(4, Isolate::Current()->zone());
}

View File

@ -82,6 +82,7 @@ static void InitializeBuildingBlocks(
Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS]) {
// 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.
Zone* zone = Isolate::Current()->zone();
for (int i = 0; i < NUMBER_OF_BUILDING_BLOCKS; i++) {
int len = gen() % 16;
if (len > 14) {
@ -113,11 +114,11 @@ static void InitializeBuildingBlocks(
break;
}
case 2: {
uc16* buf = ZONE->NewArray<uc16>(len);
uc16* buf = zone->NewArray<uc16>(len);
for (int j = 0; j < len; j++) {
buf[j] = gen() % 65536;
}
Resource* resource = new Resource(Vector<const uc16>(buf, len));
Resource* resource = new(zone) Resource(Vector<const uc16>(buf, len));
building_blocks[i] = FACTORY->NewExternalStringFromTwoByte(resource);
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
@ -348,10 +349,11 @@ TEST(Utf8Conversion) {
TEST(ExternalShortStringAdd) {
ZoneScope zone(Isolate::Current(), DELETE_ON_EXIT);
ZoneScope zonescope(Isolate::Current(), DELETE_ON_EXIT);
InitializeVM();
v8::HandleScope handle_scope;
Zone* zone = Isolate::Current()->zone();
// Make sure we cover all always-flat lengths and at least one above.
static const int kMaxLength = 20;
@ -365,25 +367,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 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 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),