314
316
static bool ShouldGenerateLog(Expression* type);
317
static void RecordPositions(MacroAssembler* masm, int pos);
319
static bool RecordPositions(MacroAssembler* masm,
321
bool right_here = false);
320
324
MacroAssembler* masm() { return masm_; }
354
358
return FieldOperand(array, index_as_smi, times_half_pointer_size, offset);
361
static Operand ContextOperand(Register context, int index) {
362
return Operand(context, Context::SlotOffset(index));
358
366
// Construction/Destruction
359
367
explicit CodeGenerator(MacroAssembler* masm);
426
434
// The following are used by class Reference.
427
435
void LoadReference(Reference* ref);
429
static Operand ContextOperand(Register context, int index) {
430
return Operand(context, Context::SlotOffset(index));
433
437
Operand SlotOperand(Slot* slot, Register tmp);
435
439
Operand ContextSlotOperandCheckExtensions(Slot* slot,
515
519
void GenericBinaryOperation(BinaryOperation* expr,
516
520
OverwriteMode overwrite_mode);
522
// Emits code sequence that jumps to a JumpTarget if the inputs
523
// are both smis. Cannot be in MacroAssembler because it takes
524
// advantage of TypeInfo to skip unneeded checks.
525
// Allocates a temporary register, possibly spilling from the frame,
526
// if it needs to check both left and right.
527
void JumpIfBothSmiUsingTypeInfo(Result* left,
529
JumpTarget* both_smi);
531
// Emits code sequence that jumps to deferred code if the inputs
532
// are not both smis. Cannot be in MacroAssembler because it takes
533
// a deferred code object.
534
void JumpIfNotBothSmiUsingTypeInfo(Register left,
539
DeferredCode* deferred);
541
// Emits code sequence that jumps to the label if the inputs
542
// are not both smis.
543
void JumpIfNotBothSmiUsingTypeInfo(Register left,
518
550
// If possible, combine two constant smi values using op to produce
519
551
// a smi result, and push it on the virtual frame, all at compile time.
520
552
// Returns true if it succeeds. Otherwise it has no effect.
548
580
ControlDestination* destination);
582
// If at least one of the sides is a constant smi, generate optimized code.
583
void ConstantSmiComparison(Condition cc,
585
ControlDestination* destination,
588
bool left_side_constant_smi,
589
bool right_side_constant_smi,
590
bool is_loop_condition);
549
592
void GenerateInlineNumberComparison(Result* left_side,
550
593
Result* right_side,
593
636
static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop);
638
static Handle<Code> ComputeKeyedCallInitialize(int argc, InLoopFlag in_loop);
595
640
// Declare global variables and functions in the given array of
596
641
// name/value pairs.
597
642
void DeclareGlobals(Handle<FixedArray> pairs);
599
644
// Instantiate the function based on the shared function info.
600
645
Result InstantiateFunction(Handle<SharedFunctionInfo> function_info);
602
// Support for type checks.
647
// Support for types.
603
648
void GenerateIsSmi(ZoneList<Expression*>* args);
604
649
void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args);
605
650
void GenerateIsArray(ZoneList<Expression*>* args);
606
651
void GenerateIsRegExp(ZoneList<Expression*>* args);
607
652
void GenerateIsObject(ZoneList<Expression*>* args);
653
void GenerateIsSpecObject(ZoneList<Expression*>* args);
608
654
void GenerateIsFunction(ZoneList<Expression*>* args);
609
655
void GenerateIsUndetectableObject(ZoneList<Expression*>* args);
656
void GenerateIsStringWrapperSafeForDefaultValueOf(
657
ZoneList<Expression*>* args);
611
659
// Support for construct call checks.
612
660
void GenerateIsConstructCall(ZoneList<Expression*>* args);
621
669
void GenerateSetValueOf(ZoneList<Expression*>* args);
623
671
// Fast support for charCodeAt(n).
624
void GenerateFastCharCodeAt(ZoneList<Expression*>* args);
626
// Fast support for string.charAt(n) and string[n].
627
void GenerateCharFromCode(ZoneList<Expression*>* args);
672
void GenerateStringCharCodeAt(ZoneList<Expression*>* args);
674
// Fast support for string.charAt(n) and string[n].
675
void GenerateStringCharFromCode(ZoneList<Expression*>* args);
677
// Fast support for string.charAt(n) and string[n].
678
void GenerateStringCharAt(ZoneList<Expression*>* args);
629
680
// Fast support for object equality testing.
630
681
void GenerateObjectEquals(ZoneList<Expression*>* args);
670
721
void GenerateMathCos(ZoneList<Expression*>* args);
671
722
void GenerateMathSqrt(ZoneList<Expression*>* args);
724
// Check whether two RegExps are equivalent
725
void GenerateIsRegExpEquivalent(ZoneList<Expression*>* args);
673
727
// Simple condition analysis.
674
728
enum ConditionAnalysis {
816
class ToBooleanStub: public CodeStub {
820
void Generate(MacroAssembler* masm);
823
Major MajorKey() { return ToBoolean; }
824
int MinorKey() { return 0; }
762
828
// Flag that indicates how to generate code for the stub GenericBinaryOpStub.
763
829
enum GenericBinaryFlags {
764
830
NO_GENERIC_BINARY_FLAGS = 0,
911
977
class StringHelper : public AllStatic {
913
// Generates fast code for getting a char code out of a string
914
// object at the given index. May bail out for four reasons (in the
916
// * Receiver is not a string (receiver_not_string label).
917
// * Index is not a smi (index_not_smi label).
918
// * Index is out of range (index_out_of_range).
919
// * Some other reason (slow_case label). In this case it's
920
// guaranteed that the above conditions are not violated,
921
// e.g. it's safe to assume the receiver is a string and the
922
// index is a non-negative smi < length.
923
// When successful, object, index, and scratch are clobbered.
924
// Otherwise, scratch and result are clobbered.
925
static void GenerateFastCharCodeAt(MacroAssembler* masm,
930
Label* receiver_not_string,
931
Label* index_not_smi,
932
Label* index_out_of_range,
935
// Generates code for creating a one-char string from the given char
936
// code. May do a runtime call, so any register can be clobbered
937
// and, if the given invoke flag specifies a call, an internal frame
938
// is required. In tail call mode the result must be eax register.
939
static void GenerateCharFromCode(MacroAssembler* masm,
944
979
// Generate code for copying characters using a simple loop. This should only
945
980
// be used in places where the number of characters is small and the
946
981
// additional setup and checking in GenerateCopyCharactersREP adds too much
1086
class RecordWriteStub : public CodeStub {
1088
RecordWriteStub(Register object, Register addr, Register scratch)
1089
: object_(object), addr_(addr), scratch_(scratch) { }
1091
void Generate(MacroAssembler* masm);
1100
PrintF("RecordWriteStub (object reg %d), (addr reg %d), (scratch reg %d)\n",
1101
object_.code(), addr_.code(), scratch_.code());
1105
// Minor key encoding in 12 bits. 4 bits for each of the three
1106
// registers (object, address and scratch) OOOOAAAASSSS.
1107
class ScratchBits: public BitField<uint32_t, 0, 4> {};
1108
class AddressBits: public BitField<uint32_t, 4, 4> {};
1109
class ObjectBits: public BitField<uint32_t, 8, 4> {};
1111
Major MajorKey() { return RecordWrite; }
1114
// Encode the registers.
1115
return ObjectBits::encode(object_.code()) |
1116
AddressBits::encode(addr_.code()) |
1117
ScratchBits::encode(scratch_.code());
1122
1121
} } // namespace v8::internal
1124
1123
#endif // V8_IA32_CODEGEN_IA32_H_