~ubuntu-branches/ubuntu/precise/nodejs/precise

« back to all changes in this revision

Viewing changes to deps/v8/src/ia32/codegen-ia32.h

  • Committer: Bazaar Package Importer
  • Author(s): Jérémy Lal
  • Date: 2010-08-20 11:49:04 UTC
  • mfrom: (7.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100820114904-lz22w6fkth7yh179
Tags: 0.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
// Forward declarations
39
39
class CompilationInfo;
40
40
class DeferredCode;
 
41
class FrameRegisterState;
41
42
class RegisterAllocator;
42
43
class RegisterFile;
 
44
class RuntimeCallHelper;
43
45
 
44
46
enum InitState { CONST_INIT, NOT_CONST_INIT };
45
47
enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
314
316
  static bool ShouldGenerateLog(Expression* type);
315
317
#endif
316
318
 
317
 
  static void RecordPositions(MacroAssembler* masm, int pos);
 
319
  static bool RecordPositions(MacroAssembler* masm,
 
320
                              int pos,
 
321
                              bool right_here = false);
318
322
 
319
323
  // Accessors
320
324
  MacroAssembler* masm() { return masm_; }
354
358
    return FieldOperand(array, index_as_smi, times_half_pointer_size, offset);
355
359
  }
356
360
 
 
361
  static Operand ContextOperand(Register context, int index) {
 
362
    return Operand(context, Context::SlotOffset(index));
 
363
  }
 
364
 
357
365
 private:
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);
428
436
 
429
 
  static Operand ContextOperand(Register context, int index) {
430
 
    return Operand(context, Context::SlotOffset(index));
431
 
  }
432
 
 
433
437
  Operand SlotOperand(Slot* slot, Register tmp);
434
438
 
435
439
  Operand ContextSlotOperandCheckExtensions(Slot* slot,
515
519
  void GenericBinaryOperation(BinaryOperation* expr,
516
520
                              OverwriteMode overwrite_mode);
517
521
 
 
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,
 
528
                                  Result* right,
 
529
                                  JumpTarget* both_smi);
 
530
 
 
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,
 
535
                                     Register right,
 
536
                                     Register scratch,
 
537
                                     TypeInfo left_info,
 
538
                                     TypeInfo right_info,
 
539
                                     DeferredCode* deferred);
 
540
 
 
541
  // Emits code sequence that jumps to the label if the inputs
 
542
  // are not both smis.
 
543
  void JumpIfNotBothSmiUsingTypeInfo(Register left,
 
544
                                     Register right,
 
545
                                     Register scratch,
 
546
                                     TypeInfo left_info,
 
547
                                     TypeInfo right_info,
 
548
                                     Label* on_non_smi);
 
549
 
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.
546
578
                  Condition cc,
547
579
                  bool strict,
548
580
                  ControlDestination* destination);
 
581
 
 
582
  // If at least one of the sides is a constant smi, generate optimized code.
 
583
  void ConstantSmiComparison(Condition cc,
 
584
                             bool strict,
 
585
                             ControlDestination* destination,
 
586
                             Result* left_side,
 
587
                             Result* right_side,
 
588
                             bool left_side_constant_smi,
 
589
                             bool right_side_constant_smi,
 
590
                             bool is_loop_condition);
 
591
 
549
592
  void GenerateInlineNumberComparison(Result* left_side,
550
593
                                      Result* right_side,
551
594
                                      Condition cc,
592
635
 
593
636
  static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop);
594
637
 
 
638
  static Handle<Code> ComputeKeyedCallInitialize(int argc, InLoopFlag in_loop);
 
639
 
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);
601
646
 
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);
610
658
 
611
659
  // Support for construct call checks.
612
660
  void GenerateIsConstructCall(ZoneList<Expression*>* args);
621
669
  void GenerateSetValueOf(ZoneList<Expression*>* args);
622
670
 
623
671
  // Fast support for charCodeAt(n).
624
 
  void GenerateFastCharCodeAt(ZoneList<Expression*>* args);
625
 
 
626
 
  // Fast support for string.charAt(n) and string[n].
627
 
  void GenerateCharFromCode(ZoneList<Expression*>* args);
 
672
  void GenerateStringCharCodeAt(ZoneList<Expression*>* args);
 
673
 
 
674
  // Fast support for string.charAt(n) and string[n].
 
675
  void GenerateStringCharFromCode(ZoneList<Expression*>* args);
 
676
 
 
677
  // Fast support for string.charAt(n) and string[n].
 
678
  void GenerateStringCharAt(ZoneList<Expression*>* args);
628
679
 
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);
672
723
 
 
724
  // Check whether two RegExps are equivalent
 
725
  void GenerateIsRegExpEquivalent(ZoneList<Expression*>* args);
 
726
 
673
727
  // Simple condition analysis.
674
728
  enum ConditionAnalysis {
675
729
    ALWAYS_TRUE,
759
813
};
760
814
 
761
815
 
 
816
class ToBooleanStub: public CodeStub {
 
817
 public:
 
818
  ToBooleanStub() { }
 
819
 
 
820
  void Generate(MacroAssembler* masm);
 
821
 
 
822
 private:
 
823
  Major MajorKey() { return ToBoolean; }
 
824
  int MinorKey() { return 0; }
 
825
};
 
826
 
 
827
 
762
828
// Flag that indicates how to generate code for the stub GenericBinaryOpStub.
763
829
enum GenericBinaryFlags {
764
830
  NO_GENERIC_BINARY_FLAGS = 0,
910
976
 
911
977
class StringHelper : public AllStatic {
912
978
 public:
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
915
 
  // listed order):
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,
926
 
                                     Register object,
927
 
                                     Register index,
928
 
                                     Register scratch,
929
 
                                     Register result,
930
 
                                     Label* receiver_not_string,
931
 
                                     Label* index_not_smi,
932
 
                                     Label* index_out_of_range,
933
 
                                     Label* slow_case);
934
 
 
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,
940
 
                                   Register code,
941
 
                                   Register result,
942
 
                                   InvokeFlag flag);
943
 
 
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
1083
1118
};
1084
1119
 
1085
1120
 
1086
 
class RecordWriteStub : public CodeStub {
1087
 
 public:
1088
 
  RecordWriteStub(Register object, Register addr, Register scratch)
1089
 
      : object_(object), addr_(addr), scratch_(scratch) { }
1090
 
 
1091
 
  void Generate(MacroAssembler* masm);
1092
 
 
1093
 
 private:
1094
 
  Register object_;
1095
 
  Register addr_;
1096
 
  Register scratch_;
1097
 
 
1098
 
#ifdef DEBUG
1099
 
  void Print() {
1100
 
    PrintF("RecordWriteStub (object reg %d), (addr reg %d), (scratch reg %d)\n",
1101
 
           object_.code(), addr_.code(), scratch_.code());
1102
 
  }
1103
 
#endif
1104
 
 
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> {};
1110
 
 
1111
 
  Major MajorKey() { return RecordWrite; }
1112
 
 
1113
 
  int MinorKey() {
1114
 
    // Encode the registers.
1115
 
    return ObjectBits::encode(object_.code()) |
1116
 
           AddressBits::encode(addr_.code()) |
1117
 
           ScratchBits::encode(scratch_.code());
1118
 
  }
1119
 
};
1120
 
 
1121
 
 
1122
1121
} }  // namespace v8::internal
1123
1122
 
1124
1123
#endif  // V8_IA32_CODEGEN_IA32_H_