Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: src/ia32/codegen-ia32.cc

Issue 6759031: Cleanup of isolate(), FACTORY and HEAP usage in ia32/codegen-ia32.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/codegen-ia32.cc
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc
index cf990a00e4ae2ff0476ef75d50f1c31dfd79b2fe..1de768e2cdddedfb9164a8a7a9989e41382b6db9 100644
--- a/src/ia32/codegen-ia32.cc
+++ b/src/ia32/codegen-ia32.cc
@@ -549,6 +549,7 @@ void CodeGenerator::ConvertInt32ResultToSmi(Result* value) {
void CodeGenerator::ConvertInt32ResultToNumber(Result* value) {
ASSERT(value->is_untagged_int32());
if (value->is_register()) {
+ Isolate* isolate = masm()->isolate();
Register val = value->reg();
JumpTarget done;
__ add(val, Operand(val));
@@ -556,7 +557,7 @@ void CodeGenerator::ConvertInt32ResultToNumber(Result* value) {
__ sar(val, 1);
// If there was an overflow, bits 30 and 31 of the original number disagree.
__ xor_(val, 0x80000000u);
- if (masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ if (isolate->cpu_features()->IsSupported(SSE2)) {
CpuFeatures::Scope fscope(SSE2);
__ cvtsi2sd(xmm0, Operand(val));
} else {
@@ -574,7 +575,7 @@ void CodeGenerator::ConvertInt32ResultToNumber(Result* value) {
no_reg, &allocation_failed);
VirtualFrame* clone = new VirtualFrame(frame_);
scratch.Unuse();
- if (masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ if (isolate->cpu_features()->IsSupported(SSE2)) {
CpuFeatures::Scope fscope(SSE2);
__ movdbl(FieldOperand(val, HeapNumber::kValueOffset), xmm0);
} else {
@@ -587,7 +588,7 @@ void CodeGenerator::ConvertInt32ResultToNumber(Result* value) {
RegisterFile empty_regs;
SetFrame(clone, &empty_regs);
__ bind(&allocation_failed);
- if (!masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ if (!isolate->cpu_features()->IsSupported(SSE2)) {
// Pop the value from the floating point stack.
__ fstp(0);
}
@@ -607,6 +608,8 @@ void CodeGenerator::Load(Expression* expr) {
int original_height = frame_->height();
#endif
ASSERT(!in_spilled_code());
+ Isolate* isolate = masm()->isolate();
+ Factory* factory = isolate->factory();
// If the expression should be a side-effect-free 32-bit int computation,
// compile that SafeInt32 path, and a bailout path.
@@ -614,7 +617,7 @@ void CodeGenerator::Load(Expression* expr) {
safe_int32_mode_enabled() &&
expr->side_effect_free() &&
expr->num_bit_ops() > 2 &&
- masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ isolate->cpu_features()->IsSupported(SSE2)) {
BreakTarget unsafe_bailout;
JumpTarget done;
unsafe_bailout.set_expected_height(frame_->height());
@@ -635,12 +638,12 @@ void CodeGenerator::Load(Expression* expr) {
if (dest.false_was_fall_through()) {
// The false target was just bound.
JumpTarget loaded;
- frame_->Push(FACTORY->false_value());
+ frame_->Push(factory->false_value());
// There may be dangling jumps to the true target.
if (true_target.is_linked()) {
loaded.Jump();
true_target.Bind();
- frame_->Push(FACTORY->true_value());
+ frame_->Push(factory->true_value());
loaded.Bind();
}
@@ -648,11 +651,11 @@ void CodeGenerator::Load(Expression* expr) {
// There is true, and possibly false, control flow (with true as
// the fall through).
JumpTarget loaded;
- frame_->Push(FACTORY->true_value());
+ frame_->Push(factory->true_value());
if (false_target.is_linked()) {
loaded.Jump();
false_target.Bind();
- frame_->Push(FACTORY->false_value());
+ frame_->Push(factory->false_value());
loaded.Bind();
}
@@ -667,14 +670,14 @@ void CodeGenerator::Load(Expression* expr) {
loaded.Jump(); // Don't lose the current TOS.
if (true_target.is_linked()) {
true_target.Bind();
- frame_->Push(FACTORY->true_value());
+ frame_->Push(factory->true_value());
if (false_target.is_linked()) {
loaded.Jump();
}
}
if (false_target.is_linked()) {
false_target.Bind();
- frame_->Push(FACTORY->false_value());
+ frame_->Push(factory->false_value());
}
loaded.Bind();
}
@@ -748,11 +751,13 @@ Result CodeGenerator::StoreArgumentsObject(bool initial) {
ASSERT(mode != NO_ARGUMENTS_ALLOCATION);
Comment cmnt(masm_, "[ store arguments object");
+
+ Factory* factory = masm()->isolate()->factory();
if (mode == LAZY_ARGUMENTS_ALLOCATION && initial) {
// When using lazy arguments allocation, we store the arguments marker value
// as a sentinel indicating that the arguments object hasn't been
// allocated yet.
- frame_->Push(FACTORY->arguments_marker());
+ frame_->Push(factory->arguments_marker());
} else {
ArgumentsAccessStub stub(is_strict_mode()
? ArgumentsAccessStub::NEW_STRICT
@@ -784,7 +789,7 @@ Result CodeGenerator::StoreArgumentsObject(bool initial) {
// been assigned a proper value.
skip_arguments = !probe.handle()->IsArgumentsMarker();
} else {
- __ cmp(Operand(probe.reg()), Immediate(FACTORY->arguments_marker()));
+ __ cmp(Operand(probe.reg()), Immediate(factory->arguments_marker()));
probe.Unuse();
done.Branch(not_equal);
}
@@ -913,17 +918,18 @@ void CodeGenerator::ToBoolean(ControlDestination* dest) {
value.Unuse();
dest->Split(not_zero);
} else {
+ Factory* factory = masm()->isolate()->factory();
// Fast case checks.
// 'false' => false.
- __ cmp(value.reg(), FACTORY->false_value());
+ __ cmp(value.reg(), factory->false_value());
dest->false_target()->Branch(equal);
// 'true' => true.
- __ cmp(value.reg(), FACTORY->true_value());
+ __ cmp(value.reg(), factory->true_value());
dest->true_target()->Branch(equal);
// 'undefined' => false.
- __ cmp(value.reg(), FACTORY->undefined_value());
+ __ cmp(value.reg(), factory->undefined_value());
dest->false_target()->Branch(equal);
// Smi => false iff zero.
@@ -1016,9 +1022,11 @@ void DeferredInlineBinaryOperation::JumpToConstantRhs(Condition cond,
void DeferredInlineBinaryOperation::Generate() {
+ Isolate* isolate = masm()->isolate();
+ Factory* factory = isolate->factory();
// Registers are not saved implicitly for this stub, so we should not
// tread on the registers that were not passed to us.
- if (masm()->isolate()->cpu_features()->IsSupported(SSE2) &&
+ if (isolate->cpu_features()->IsSupported(SSE2) &&
((op_ == Token::ADD) ||
(op_ == Token::SUB) ||
(op_ == Token::MUL) ||
@@ -1031,7 +1039,7 @@ void DeferredInlineBinaryOperation::Generate() {
__ j(zero, &left_smi);
if (!left_info_.IsNumber()) {
__ cmp(FieldOperand(left_, HeapObject::kMapOffset),
- FACTORY->heap_number_map());
+ factory->heap_number_map());
__ j(not_equal, &call_runtime);
}
__ movdbl(xmm0, FieldOperand(left_, HeapNumber::kValueOffset));
@@ -1060,7 +1068,7 @@ void DeferredInlineBinaryOperation::Generate() {
__ j(zero, &right_smi);
if (!right_info_.IsNumber()) {
__ cmp(FieldOperand(right_, HeapObject::kMapOffset),
- FACTORY->heap_number_map());
+ factory->heap_number_map());
__ j(not_equal, &call_runtime);
}
__ movdbl(xmm1, FieldOperand(right_, HeapNumber::kValueOffset));
@@ -3014,6 +3022,7 @@ void CodeGenerator::ConstantSmiComparison(Condition cc,
right_side->Unuse();
dest->Split(cc);
} else {
+ Isolate* isolate = masm()->isolate();
// Only the case where the left side could possibly be a non-smi is left.
JumpTarget is_smi;
if (cc == equal) {
@@ -3032,13 +3041,13 @@ void CodeGenerator::ConstantSmiComparison(Condition cc,
// constant smi. If the non-smi is a heap number and this is not
// a loop condition, inline the floating point code.
if (!is_loop_condition &&
- masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ isolate->cpu_features()->IsSupported(SSE2)) {
// Right side is a constant smi and left side has been checked
// not to be a smi.
CpuFeatures::Scope use_sse2(SSE2);
JumpTarget not_number;
__ cmp(FieldOperand(left_reg, HeapObject::kMapOffset),
- Immediate(FACTORY->heap_number_map()));
+ Immediate(isolate->factory()->heap_number_map()));
not_number.Branch(not_equal, left_side);
__ movdbl(xmm1,
FieldOperand(left_reg, HeapNumber::kValueOffset));
@@ -3274,11 +3283,13 @@ void CodeGenerator::CallApplyLazy(Expression* applicand,
ASSERT(ArgumentsMode() == LAZY_ARGUMENTS_ALLOCATION);
ASSERT(arguments->IsArguments());
+ Isolate* isolate = masm()->isolate();
+ Factory* factory = isolate->factory();
// Load applicand.apply onto the stack. This will usually
// give us a megamorphic load site. Not super, but it works.
Load(applicand);
frame()->Dup();
- Handle<String> name = FACTORY->LookupAsciiSymbol("apply");
+ Handle<String> name = factory->LookupAsciiSymbol("apply");
frame()->Push(name);
Result answer = frame()->CallLoadIC(RelocInfo::CODE_TARGET);
__ nop();
@@ -3310,7 +3321,7 @@ void CodeGenerator::CallApplyLazy(Expression* applicand,
if (probe.is_constant()) {
try_lazy = probe.handle()->IsArgumentsMarker();
} else {
- __ cmp(Operand(probe.reg()), Immediate(FACTORY->arguments_marker()));
+ __ cmp(Operand(probe.reg()), Immediate(factory->arguments_marker()));
probe.Unuse();
__ j(not_equal, &slow);
}
@@ -3346,7 +3357,7 @@ void CodeGenerator::CallApplyLazy(Expression* applicand,
__ j(not_equal, &build_args);
__ mov(ecx, FieldOperand(eax, JSFunction::kCodeEntryOffset));
__ sub(Operand(ecx), Immediate(Code::kHeaderSize - kHeapObjectTag));
- Handle<Code> apply_code(masm()->isolate()->builtins()->builtin(
+ Handle<Code> apply_code(isolate->builtins()->builtin(
Builtins::kFunctionApply));
__ cmp(Operand(ecx), Immediate(apply_code));
__ j(not_equal, &build_args);
@@ -4356,6 +4367,8 @@ void CodeGenerator::VisitForInStatement(ForInStatement* node) {
Comment cmnt(masm_, "[ ForInStatement");
CodeForStatementPosition(node);
+ Factory* factory = masm()->isolate()->factory();
+
JumpTarget primitive;
JumpTarget jsobject;
JumpTarget fixed_array;
@@ -4371,9 +4384,9 @@ void CodeGenerator::VisitForInStatement(ForInStatement* node) {
frame_->EmitPop(eax);
// eax: value to be iterated over
- __ cmp(eax, FACTORY->undefined_value());
+ __ cmp(eax, factory->undefined_value());
exit.Branch(equal);
- __ cmp(eax, FACTORY->null_value());
+ __ cmp(eax, factory->null_value());
exit.Branch(equal);
// Stack layout in body:
@@ -4412,14 +4425,14 @@ void CodeGenerator::VisitForInStatement(ForInStatement* node) {
loop.Bind();
// Check that there are no elements.
__ mov(edx, FieldOperand(ecx, JSObject::kElementsOffset));
- __ cmp(Operand(edx), Immediate(FACTORY->empty_fixed_array()));
+ __ cmp(Operand(edx), Immediate(factory->empty_fixed_array()));
call_runtime.Branch(not_equal);
// Check that instance descriptors are not empty so that we can
// check for an enum cache. Leave the map in ebx for the subsequent
// prototype load.
__ mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset));
__ mov(edx, FieldOperand(ebx, Map::kInstanceDescriptorsOffset));
- __ cmp(Operand(edx), Immediate(FACTORY->empty_descriptor_array()));
+ __ cmp(Operand(edx), Immediate(factory->empty_descriptor_array()));
call_runtime.Branch(equal);
// Check that there in an enum cache in the non-empty instance
// descriptors. This is the case if the next enumeration index
@@ -4431,12 +4444,12 @@ void CodeGenerator::VisitForInStatement(ForInStatement* node) {
__ cmp(ecx, Operand(eax));
check_prototype.Branch(equal);
__ mov(edx, FieldOperand(edx, DescriptorArray::kEnumCacheBridgeCacheOffset));
- __ cmp(Operand(edx), Immediate(FACTORY->empty_fixed_array()));
+ __ cmp(Operand(edx), Immediate(factory->empty_fixed_array()));
call_runtime.Branch(not_equal);
check_prototype.Bind();
// Load the prototype from the map and loop if non-null.
__ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset));
- __ cmp(Operand(ecx), Immediate(FACTORY->null_value()));
+ __ cmp(Operand(ecx), Immediate(factory->null_value()));
loop.Branch(not_equal);
// The enum cache is valid. Load the map of the object being
// iterated over and use the cache for the iteration.
@@ -4455,7 +4468,7 @@ void CodeGenerator::VisitForInStatement(ForInStatement* node) {
// Runtime::kGetPropertyNamesFast)
__ mov(edx, Operand(eax));
__ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset));
- __ cmp(ecx, FACTORY->meta_map());
+ __ cmp(ecx, factory->meta_map());
fixed_array.Branch(not_equal);
use_cache.Bind();
@@ -4717,6 +4730,9 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) {
Comment cmnt(masm_, "[ TryFinallyStatement");
CodeForStatementPosition(node);
+ Isolate* isolate = masm()->isolate();
+ Factory* factory = isolate->factory();
+
// State: Used to keep track of reason for entering the finally
// block. Should probably be extended to hold information for
// break/continue from within the try block.
@@ -4775,7 +4791,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) {
// Get an external reference to the handler address.
ExternalReference handler_address(Isolate::k_handler_address,
- masm()->isolate());
+ isolate);
// If we can fall off the end of the try block, unlink from the try
// chain and set the state on the frame to FALLING.
@@ -4787,7 +4803,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) {
// Fake a top of stack value (unneeded when FALLING) and set the
// state in ecx, then jump around the unlink blocks if any.
- frame_->EmitPush(Immediate(FACTORY->undefined_value()));
+ frame_->EmitPush(Immediate(factory->undefined_value()));
__ Set(ecx, Immediate(Smi::FromInt(FALLING)));
if (nof_unlinks > 0) {
finally_block.Jump();
@@ -4830,7 +4846,7 @@ void CodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* node) {
frame_->EmitPush(eax);
} else {
// Fake TOS for targets that shadowed breaks and continues.
- frame_->EmitPush(Immediate(FACTORY->undefined_value()));
+ frame_->EmitPush(Immediate(factory->undefined_value()));
}
__ Set(ecx, Immediate(Smi::FromInt(JUMPING + i)));
if (--nof_unlinks > 0) {
@@ -5045,11 +5061,12 @@ void CodeGenerator::LoadFromSlot(Slot* slot, TypeofState typeof_state) {
// potentially unsafe direct-frame access of SlotOperand.
VirtualFrame::SpilledScope spilled_scope;
Comment cmnt(masm_, "[ Load const");
+ Factory* factory = masm()->isolate()->factory();
Label exit;
__ mov(ecx, SlotOperand(slot, ecx));
- __ cmp(ecx, FACTORY->the_hole_value());
+ __ cmp(ecx, factory->the_hole_value());
__ j(not_equal, &exit);
- __ mov(ecx, FACTORY->undefined_value());
+ __ mov(ecx, factory->undefined_value());
__ bind(&exit);
frame()->EmitPush(ecx);
@@ -5213,9 +5230,10 @@ void CodeGenerator::EmitDynamicLoadFromSlotFastCase(Slot* slot,
__ mov(result->reg(),
ContextSlotOperandCheckExtensions(potential_slot, *result, slow));
if (potential_slot->var()->mode() == Variable::CONST) {
- __ cmp(result->reg(), FACTORY->the_hole_value());
+ Factory* factory = masm()->isolate()->factory();
+ __ cmp(result->reg(), factory->the_hole_value());
done->Branch(not_equal, result);
- __ mov(result->reg(), FACTORY->undefined_value());
+ __ mov(result->reg(), factory->undefined_value());
}
done->Jump(result);
} else if (rewrite != NULL) {
@@ -5692,11 +5710,13 @@ void CodeGenerator::VisitArrayLiteral(ArrayLiteral* node) {
frame_->Push(node->constant_elements());
int length = node->values()->length();
Result clone;
- if (node->constant_elements()->map() == HEAP->fixed_cow_array_map()) {
+ Isolate* isolate = masm()->isolate();
+ if (node->constant_elements()->map() ==
+ isolate->heap()->fixed_cow_array_map()) {
FastCloneShallowArrayStub stub(
FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length);
clone = frame_->CallStub(&stub, 3);
- Counters* counters = masm()->isolate()->counters();
+ Counters* counters = isolate->counters();
__ IncrementCounter(counters->cow_arrays_created_stub(), 1);
} else if (node->depth() > 1) {
clone = frame_->CallRuntime(Runtime::kCreateArrayLiteral, 3);
@@ -6072,6 +6092,7 @@ void CodeGenerator::VisitCall(Call* node) {
Expression* function = node->expression();
ZoneList<Expression*>* args = node->arguments();
+ Factory* factory = masm()->isolate()->factory();
// Check if the function is a variable or a property.
Variable* var = function->AsVariableProxy()->AsVariable();
@@ -6100,7 +6121,7 @@ void CodeGenerator::VisitCall(Call* node) {
Load(function);
// Allocate a frame slot for the receiver.
- frame_->Push(FACTORY->undefined_value());
+ frame_->Push(factory->undefined_value());
// Load the arguments.
int arg_count = args->length();
@@ -6132,7 +6153,7 @@ void CodeGenerator::VisitCall(Call* node) {
if (arg_count > 0) {
frame_->PushElementAt(arg_count);
} else {
- frame_->Push(FACTORY->undefined_value());
+ frame_->Push(factory->undefined_value());
}
frame_->PushParameterAt(-1);
@@ -6154,7 +6175,7 @@ void CodeGenerator::VisitCall(Call* node) {
if (arg_count > 0) {
frame_->PushElementAt(arg_count);
} else {
- frame_->Push(FACTORY->undefined_value());
+ frame_->Push(factory->undefined_value());
}
frame_->PushParameterAt(-1);
@@ -6485,19 +6506,20 @@ class DeferredStringCharCodeAt : public DeferredCode {
}
virtual void Generate() {
+ Factory* factory = masm()->isolate()->factory();
VirtualFrameRuntimeCallHelper call_helper(frame_state());
char_code_at_generator_.GenerateSlow(masm(), call_helper);
__ bind(&need_conversion_);
// Move the undefined value into the result register, which will
// trigger conversion.
- __ Set(result_, Immediate(FACTORY->undefined_value()));
+ __ Set(result_, Immediate(factory->undefined_value()));
__ jmp(exit_label());
__ bind(&index_out_of_range_);
// When the index is out of range, the spec requires us to return
// NaN.
- __ Set(result_, Immediate(FACTORY->nan_value()));
+ __ Set(result_, Immediate(factory->nan_value()));
__ jmp(exit_label());
}
@@ -6694,6 +6716,7 @@ void CodeGenerator::GenerateFastAsciiArrayJoin(ZoneList<Expression*>* args) {
loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
ASSERT(args->length() == 2);
+ Factory* factory = masm()->isolate()->factory();
// We will leave the separator on the stack until the end of the function.
Load(args->at(1));
// Load this to eax (= array)
@@ -6738,7 +6761,7 @@ void CodeGenerator::GenerateFastAsciiArrayJoin(ZoneList<Expression*>* args) {
__ mov(array_length, FieldOperand(array, JSArray::kLengthOffset));
__ sar(array_length, 1);
__ j(not_zero, &non_trivial_array);
- __ mov(result_operand, FACTORY->empty_string());
+ __ mov(result_operand, factory->empty_string());
__ jmp(&done);
// Save the array length.
@@ -6949,7 +6972,7 @@ void CodeGenerator::GenerateFastAsciiArrayJoin(ZoneList<Expression*>* args) {
__ bind(&bailout);
- __ mov(result_operand, FACTORY->undefined_value());
+ __ mov(result_operand, factory->undefined_value());
__ bind(&done);
__ mov(eax, result_operand);
// Drop temp values from the stack, and restore context register.
@@ -7050,6 +7073,7 @@ class DeferredIsStringWrapperSafeForDefaultValueOf : public DeferredCode {
scratch2_(scratch2) { }
virtual void Generate() {
+ Factory* factory = masm()->isolate()->factory();
Label false_result;
// Check that map is loaded as expected.
@@ -7061,7 +7085,7 @@ class DeferredIsStringWrapperSafeForDefaultValueOf : public DeferredCode {
// Check for fast case object. Generate false result for slow case object.
__ mov(scratch1_, FieldOperand(object_, JSObject::kPropertiesOffset));
__ mov(scratch1_, FieldOperand(scratch1_, HeapObject::kMapOffset));
- __ cmp(scratch1_, FACTORY->hash_table_map());
+ __ cmp(scratch1_, factory->hash_table_map());
__ j(equal, &false_result);
// Look for valueOf symbol in the descriptor array, and indicate false if
@@ -7088,7 +7112,7 @@ class DeferredIsStringWrapperSafeForDefaultValueOf : public DeferredCode {
__ jmp(&entry);
__ bind(&loop);
__ mov(scratch2_, FieldOperand(map_result_, 0));
- __ cmp(scratch2_, FACTORY->value_of_symbol());
+ __ cmp(scratch2_, factory->value_of_symbol());
__ j(equal, &false_result);
__ add(Operand(map_result_), Immediate(kPointerSize));
__ bind(&entry);
@@ -7262,6 +7286,7 @@ void CodeGenerator::GenerateArgumentsLength(ZoneList<Expression*>* args) {
void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
+ Factory* factory = masm()->isolate()->factory();
JumpTarget leave, null, function, non_function_constructor;
Load(args->at(0)); // Load the object.
Result obj = frame_->Pop();
@@ -7303,17 +7328,17 @@ void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) {
// Functions have class 'Function'.
function.Bind();
- frame_->Push(FACTORY->function_class_symbol());
+ frame_->Push(factory->function_class_symbol());
leave.Jump();
// Objects with a non-function constructor have class 'Object'.
non_function_constructor.Bind();
- frame_->Push(FACTORY->Object_symbol());
+ frame_->Push(factory->Object_symbol());
leave.Jump();
// Non-JS objects have class null.
null.Bind();
- frame_->Push(FACTORY->null_value());
+ frame_->Push(factory->null_value());
// All done.
leave.Bind();
@@ -7435,6 +7460,8 @@ void CodeGenerator::GenerateRandomHeapNumber(
ASSERT(args->length() == 0);
frame_->SpillAll();
+ Isolate* isolate = masm()->isolate();
+
Label slow_allocate_heapnumber;
Label heapnumber_allocated;
@@ -7449,14 +7476,14 @@ void CodeGenerator::GenerateRandomHeapNumber(
__ bind(&heapnumber_allocated);
__ PrepareCallCFunction(0, ebx);
- __ CallCFunction(ExternalReference::random_uint32_function(masm()->isolate()),
+ __ CallCFunction(ExternalReference::random_uint32_function(isolate),
0);
// Convert 32 random bits in eax to 0.(32 random bits) in a double
// by computing:
// ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
// This is implemented on both SSE2 and FPU.
- if (masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ if (isolate->cpu_features()->IsSupported(SSE2)) {
CpuFeatures::Scope fscope(SSE2);
__ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single.
__ movd(xmm1, Operand(ebx));
@@ -7754,6 +7781,7 @@ void CodeGenerator::GenerateSwapElements(ZoneList<Expression*>* args) {
Comment cmnt(masm_, "[ GenerateSwapElements");
ASSERT_EQ(3, args->length());
+ Factory* factory = masm()->isolate()->factory();
Load(args->at(0));
Load(args->at(1));
@@ -7793,7 +7821,7 @@ void CodeGenerator::GenerateSwapElements(ZoneList<Expression*>* args) {
// Check the object's elements are in fast case and writable.
__ mov(tmp1.reg(), FieldOperand(object.reg(), JSObject::kElementsOffset));
__ cmp(FieldOperand(tmp1.reg(), HeapObject::kMapOffset),
- Immediate(FACTORY->fixed_array_map()));
+ Immediate(factory->fixed_array_map()));
deferred->Branch(not_equal);
// Smi-tagging is equivalent to multiplying by 2.
@@ -7834,7 +7862,7 @@ void CodeGenerator::GenerateSwapElements(ZoneList<Expression*>* args) {
__ bind(&done);
deferred->BindExit();
- frame_->Push(FACTORY->undefined_value());
+ frame_->Push(factory->undefined_value());
}
@@ -7860,12 +7888,14 @@ void CodeGenerator::GenerateCallFunction(ZoneList<Expression*>* args) {
// on both arguments.
void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) {
ASSERT(args->length() == 2);
+ Isolate* isolate = masm()->isolate();
Load(args->at(0));
Load(args->at(1));
- if (!masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ if (!isolate->cpu_features()->IsSupported(SSE2)) {
Result res = frame_->CallRuntime(Runtime::kMath_pow, 2);
frame_->Push(&res);
} else {
+ Factory* factory = isolate->factory();
CpuFeatures::Scope use_sse2(SSE2);
Label allocate_return;
// Load the two operands while leaving the values on the frame.
@@ -7903,7 +7933,7 @@ void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) {
// exponent is smi and base is a heapnumber.
__ bind(&base_nonsmi);
__ cmp(FieldOperand(base.reg(), HeapObject::kMapOffset),
- FACTORY->heap_number_map());
+ factory->heap_number_map());
call_runtime.Branch(not_equal);
__ movdbl(xmm0, FieldOperand(base.reg(), HeapNumber::kValueOffset));
@@ -7954,7 +7984,7 @@ void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) {
// on doubles.
__ bind(&exponent_nonsmi);
__ cmp(FieldOperand(exponent.reg(), HeapObject::kMapOffset),
- FACTORY->heap_number_map());
+ factory->heap_number_map());
call_runtime.Branch(not_equal);
__ movdbl(xmm1, FieldOperand(exponent.reg(), HeapNumber::kValueOffset));
// Test if exponent is nan.
@@ -7970,7 +8000,7 @@ void CodeGenerator::GenerateMathPow(ZoneList<Expression*>* args) {
__ jmp(&handle_special_cases);
__ bind(&base_not_smi);
__ cmp(FieldOperand(base.reg(), HeapObject::kMapOffset),
- FACTORY->heap_number_map());
+ factory->heap_number_map());
call_runtime.Branch(not_equal);
__ mov(answer.reg(), FieldOperand(base.reg(), HeapNumber::kExponentOffset));
__ and_(answer.reg(), HeapNumber::kExponentMask);
@@ -8078,8 +8108,9 @@ void CodeGenerator::GenerateMathLog(ZoneList<Expression*>* args) {
void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) {
ASSERT_EQ(args->length(), 1);
Load(args->at(0));
+ Isolate* isolate = masm()->isolate();
- if (!masm()->isolate()->cpu_features()->IsSupported(SSE2)) {
+ if (!isolate->cpu_features()->IsSupported(SSE2)) {
Result result = frame()->CallRuntime(Runtime::kMath_sqrt, 1);
frame()->Push(&result);
} else {
@@ -8101,7 +8132,7 @@ void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) {
__ jmp(&load_done);
__ bind(&non_smi);
__ cmp(FieldOperand(result.reg(), HeapObject::kMapOffset),
- FACTORY->heap_number_map());
+ isolate->factory()->heap_number_map());
__ j(not_equal, &runtime);
__ movdbl(xmm0, FieldOperand(result.reg(), HeapNumber::kValueOffset));
@@ -8243,6 +8274,7 @@ void CodeGenerator::VisitCallRuntime(CallRuntime* node) {
void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) {
Comment cmnt(masm_, "[ UnaryOperation");
+ Factory* factory = masm()->isolate()->factory();
Token::Value op = node->op();
if (op == Token::NOT) {
@@ -8290,12 +8322,12 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) {
} else {
// Default: Result of deleting non-global, not dynamically
// introduced variables is false.
- frame_->Push(FACTORY->false_value());
+ frame_->Push(factory->false_value());
}
} else {
// Default: Result of deleting expressions is true.
Load(node->expression()); // may have side-effects
- frame_->SetElementAt(0, FACTORY->true_value());
+ frame_->SetElementAt(0, factory->true_value());
}
} else if (op == Token::TYPEOF) {
@@ -8316,10 +8348,10 @@ void CodeGenerator::VisitUnaryOperation(UnaryOperation* node) {
expression->AsLiteral()->IsNull())) {
// Omit evaluating the value of the primitive literal.
// It will be discarded anyway, and can have no side effect.
- frame_->Push(FACTORY->undefined_value());
+ frame_->Push(factory->undefined_value());
} else {
Load(node->expression());
- frame_->SetElementAt(0, FACTORY->undefined_value());
+ frame_->SetElementAt(0, factory->undefined_value());
}
} else {
@@ -9110,6 +9142,9 @@ void CodeGenerator::VisitCompareOperation(CompareOperation* node) {
// efficient, we generate special code for expressions of the form:
// 'typeof <expression> == <string>'.
UnaryOperation* operation = left->AsUnaryOperation();
+ Isolate* isolate = masm()->isolate();
+ Factory* factory = isolate->factory();
+ Heap* heap = isolate->heap();
if ((op == Token::EQ || op == Token::EQ_STRICT) &&
(operation != NULL && operation->op() == Token::TYPEOF) &&
(right->AsLiteral() != NULL &&
@@ -9121,16 +9156,16 @@ void CodeGenerator::VisitCompareOperation(CompareOperation* node) {
Result answer = frame_->Pop();
answer.ToRegister();
- if (check->Equals(HEAP->number_symbol())) {
+ if (check->Equals(heap->number_symbol())) {
__ test(answer.reg(), Immediate(kSmiTagMask));
destination()->true_target()->Branch(zero);
frame_->Spill(answer.reg());
__ mov(answer.reg(), FieldOperand(answer.reg(), HeapObject::kMapOffset));
- __ cmp(answer.reg(), FACTORY->heap_number_map());
+ __ cmp(answer.reg(), factory->heap_number_map());
answer.Unuse();
destination()->Split(equal);
- } else if (check->Equals(HEAP->string_symbol())) {
+ } else if (check->Equals(heap->string_symbol())) {
__ test(answer.reg(), Immediate(kSmiTagMask));
destination()->false_target()->Branch(zero);
@@ -9146,15 +9181,15 @@ void CodeGenerator::VisitCompareOperation(CompareOperation* node) {
answer.Unuse();
destination()->Split(below);
- } else if (check->Equals(HEAP->boolean_symbol())) {
- __ cmp(answer.reg(), FACTORY->true_value());
+ } else if (check->Equals(heap->boolean_symbol())) {
+ __ cmp(answer.reg(), factory->true_value());
destination()->true_target()->Branch(equal);
- __ cmp(answer.reg(), FACTORY->false_value());
+ __ cmp(answer.reg(), factory->false_value());
answer.Unuse();
destination()->Split(equal);
- } else if (check->Equals(HEAP->undefined_symbol())) {
- __ cmp(answer.reg(), FACTORY->undefined_value());
+ } else if (check->Equals(heap->undefined_symbol())) {
+ __ cmp(answer.reg(), factory->undefined_value());
destination()->true_target()->Branch(equal);
__ test(answer.reg(), Immediate(kSmiTagMask));
@@ -9168,7 +9203,7 @@ void CodeGenerator::VisitCompareOperation(CompareOperation* node) {
answer.Unuse();
destination()->Split(not_zero);
- } else if (check->Equals(HEAP->function_symbol())) {
+ } else if (check->Equals(heap->function_symbol())) {
__ test(answer.reg(), Immediate(kSmiTagMask));
destination()->false_target()->Branch(zero);
frame_->Spill(answer.reg());
@@ -9178,10 +9213,10 @@ void CodeGenerator::VisitCompareOperation(CompareOperation* node) {
__ CmpInstanceType(answer.reg(), JS_REGEXP_TYPE);
answer.Unuse();
destination()->Split(equal);
- } else if (check->Equals(HEAP->object_symbol())) {
+ } else if (check->Equals(heap->object_symbol())) {
__ test(answer.reg(), Immediate(kSmiTagMask));
destination()->false_target()->Branch(zero);
- __ cmp(answer.reg(), FACTORY->null_value());
+ __ cmp(answer.reg(), factory->null_value());
destination()->true_target()->Branch(equal);
Result map = allocator()->Allocate();
@@ -9224,7 +9259,7 @@ void CodeGenerator::VisitCompareOperation(CompareOperation* node) {
Result scratch = allocator()->Allocate();
ASSERT(scratch.is_valid());
__ mov(scratch.reg(), FieldOperand(lhs.reg(), HeapObject::kMapOffset));
- __ cmp(scratch.reg(), FACTORY->heap_number_map());
+ __ cmp(scratch.reg(), factory->heap_number_map());
JumpTarget not_a_number;
not_a_number.Branch(not_equal, &lhs);
__ mov(scratch.reg(),
@@ -9308,10 +9343,11 @@ void CodeGenerator::VisitCompareToNull(CompareToNull* node) {
ASSERT(!in_safe_int32_mode());
Comment cmnt(masm_, "[ CompareToNull");
+ Factory* factory = masm()->isolate()->factory();
Load(node->expression());
Result operand = frame_->Pop();
operand.ToRegister();
- __ cmp(operand.reg(), FACTORY->null_value());
+ __ cmp(operand.reg(), factory->null_value());
if (node->is_strict()) {
operand.Unuse();
destination()->Split(equal);
@@ -9319,7 +9355,7 @@ void CodeGenerator::VisitCompareToNull(CompareToNull* node) {
// The 'null' value is only equal to 'undefined' if using non-strict
// comparisons.
destination()->true_target()->Branch(equal);
- __ cmp(operand.reg(), FACTORY->undefined_value());
+ __ cmp(operand.reg(), factory->undefined_value());
destination()->true_target()->Branch(equal);
__ test(operand.reg(), Immediate(kSmiTagMask));
destination()->false_target()->Branch(equal);
@@ -9392,7 +9428,8 @@ void DeferredReferenceGetNamedValue::Generate() {
__ mov(eax, receiver_);
}
__ Set(ecx, Immediate(name_));
- Handle<Code> ic(masm()->isolate()->builtins()->builtin(
+ Isolate* isolate = masm()->isolate();
+ Handle<Code> ic(isolate->builtins()->builtin(
Builtins::kLoadIC_Initialize));
RelocInfo::Mode mode = is_contextual_
? RelocInfo::CODE_TARGET_CONTEXT
@@ -9410,7 +9447,7 @@ void DeferredReferenceGetNamedValue::Generate() {
int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(patch_site());
// Here we use masm_-> instead of the __ macro because this is the
// instruction that gets patched and coverage code gets in the way.
- Counters* counters = masm()->isolate()->counters();
+ Counters* counters = isolate->counters();
if (is_contextual_) {
masm_->mov(is_dont_delete_ ? edx : ecx, -delta_to_patch_site);
__ IncrementCounter(counters->named_load_global_inline_miss(), 1);
@@ -9448,6 +9485,7 @@ class DeferredReferenceGetKeyedValue: public DeferredCode {
void DeferredReferenceGetKeyedValue::Generate() {
+ Isolate* isolate = masm()->isolate();
if (!receiver_.is(eax)) {
// Register eax is available for key.
if (!key_.is(eax)) {
@@ -9473,7 +9511,7 @@ void DeferredReferenceGetKeyedValue::Generate() {
// it in the IC initialization code and patch the cmp instruction.
// This means that we cannot allow test instructions after calls to
// KeyedLoadIC stubs in other places.
- Handle<Code> ic(masm()->isolate()->builtins()->builtin(
+ Handle<Code> ic(isolate->builtins()->builtin(
Builtins::kKeyedLoadIC_Initialize));
__ call(ic, RelocInfo::CODE_TARGET);
// The delta from the start of the map-compare instruction to the
@@ -9485,7 +9523,7 @@ void DeferredReferenceGetKeyedValue::Generate() {
// Here we use masm_-> instead of the __ macro because this is the
// instruction that gets patched and coverage code gets in the way.
masm_->test(eax, Immediate(-delta_to_patch_site));
- Counters* counters = masm()->isolate()->counters();
+ Counters* counters = isolate->counters();
__ IncrementCounter(counters->keyed_load_inline_miss(), 1);
if (!dst_.is(eax)) __ mov(dst_, eax);
@@ -9522,7 +9560,8 @@ class DeferredReferenceSetKeyedValue: public DeferredCode {
void DeferredReferenceSetKeyedValue::Generate() {
- Counters* counters = masm()->isolate()->counters();
+ Isolate* isolate = masm()->isolate();
+ Counters* counters = isolate->counters();
__ IncrementCounter(counters->keyed_store_inline_miss(), 1);
// Move value_ to eax, key_ to ecx, and receiver_ to edx.
Register old_value = value_;
@@ -9577,7 +9616,7 @@ void DeferredReferenceSetKeyedValue::Generate() {
}
// Call the IC stub.
- Handle<Code> ic(masm()->isolate()->builtins()->builtin(
+ Handle<Code> ic(isolate->builtins()->builtin(
(strict_mode_ == kStrictMode) ? Builtins::kKeyedStoreIC_Initialize_Strict
: Builtins::kKeyedStoreIC_Initialize));
__ call(ic, RelocInfo::CODE_TARGET);
@@ -9841,6 +9880,9 @@ Result CodeGenerator::EmitKeyedLoad() {
Result elements = allocator()->Allocate();
ASSERT(elements.is_valid());
+ Isolate* isolate = masm()->isolate();
+ Factory* factory = isolate->factory();
+
Result key = frame_->Pop();
Result receiver = frame_->Pop();
key.ToRegister();
@@ -9864,7 +9906,7 @@ Result CodeGenerator::EmitKeyedLoad() {
// Use masm-> here instead of the double underscore macro since extra
// coverage code can interfere with the patching.
masm_->cmp(FieldOperand(receiver.reg(), HeapObject::kMapOffset),
- Immediate(FACTORY->null_value()));
+ Immediate(factory->null_value()));
deferred->Branch(not_equal);
// Check that the key is a smi.
@@ -9894,9 +9936,9 @@ Result CodeGenerator::EmitKeyedLoad() {
times_2,
FixedArray::kHeaderSize));
result = elements;
- __ cmp(Operand(result.reg()), Immediate(FACTORY->the_hole_value()));
+ __ cmp(Operand(result.reg()), Immediate(factory->the_hole_value()));
deferred->Branch(equal);
- __ IncrementCounter(masm_->isolate()->counters()->keyed_load_inline(), 1);
+ __ IncrementCounter(isolate->counters()->keyed_load_inline(), 1);
deferred->BindExit();
} else {
@@ -10196,6 +10238,9 @@ MemCopyFunction CreateMemCopyFunction() {
int stack_offset = 0; // Update if we change the stack height.
+ Isolate* isolate = masm.isolate();
+ Counters* counters = isolate->counters();
+
if (FLAG_debug_code) {
__ cmp(Operand(esp, kSizeOffset + stack_offset),
Immediate(kMinComplexMemCopy));
@@ -10204,7 +10249,7 @@ MemCopyFunction CreateMemCopyFunction() {
__ int3();
__ bind(&ok);
}
- if (masm.isolate()->cpu_features()->IsSupported(SSE2)) {
+ if (isolate->cpu_features()->IsSupported(SSE2)) {
CpuFeatures::Scope enable(SSE2);
__ push(edi);
__ push(esi);
@@ -10232,7 +10277,7 @@ MemCopyFunction CreateMemCopyFunction() {
__ test(Operand(src), Immediate(0x0F));
__ j(not_zero, &unaligned_source);
{
- __ IncrementCounter(masm.isolate()->counters()->memcopy_aligned(), 1);
+ __ IncrementCounter(counters->memcopy_aligned(), 1);
// Copy loop for aligned source and destination.
__ mov(edx, count);
Register loop_count = ecx;
@@ -10280,7 +10325,7 @@ MemCopyFunction CreateMemCopyFunction() {
// Copy loop for unaligned source and aligned destination.
// If source is not aligned, we can't read it as efficiently.
__ bind(&unaligned_source);
- __ IncrementCounter(masm.isolate()->counters()->memcopy_unaligned(), 1);
+ __ IncrementCounter(counters->memcopy_unaligned(), 1);
__ mov(edx, ecx);
Register loop_count = ecx;
Register count = edx;
@@ -10324,7 +10369,7 @@ MemCopyFunction CreateMemCopyFunction() {
}
} else {
- __ IncrementCounter(masm.isolate()->counters()->memcopy_noxmm(), 1);
+ __ IncrementCounter(counters->memcopy_noxmm(), 1);
// SSE2 not supported. Unlikely to happen in practice.
__ push(edi);
__ push(esi);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698