1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_ARM_CODEGEN_ARM_H_
29 #define V8_ARM_CODEGEN_ARM_H_
36 // Forward declarations
37 class CompilationInfo;
39 class RegisterAllocator;
42 enum InitState { CONST_INIT, NOT_CONST_INIT };
43 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
46 // -------------------------------------------------------------------------
49 // A reference is a C++ stack-allocated object that puts a
50 // reference on the virtual frame. The reference may be consumed
51 // by GetValue, TakeValue, SetValue, and Codegen::UnloadReference.
52 // When the lifetime (scope) of a valid reference ends, it must have
53 // been consumed, and be in state UNLOADED.
54 class Reference BASE_EMBEDDED {
56 // The values of the types is important, see size().
57 enum Type { UNLOADED = -2, ILLEGAL = -1, SLOT = 0, NAMED = 1, KEYED = 2 };
58 Reference(CodeGenerator* cgen,
59 Expression* expression,
60 bool persist_after_get = false);
63 Expression* expression() const { return expression_; }
64 Type type() const { return type_; }
65 void set_type(Type value) {
66 ASSERT_EQ(ILLEGAL, type_);
71 ASSERT_NE(ILLEGAL, type_);
72 ASSERT_NE(UNLOADED, type_);
75 // The size the reference takes up on the stack.
77 return (type_ < SLOT) ? 0 : type_;
80 bool is_illegal() const { return type_ == ILLEGAL; }
81 bool is_slot() const { return type_ == SLOT; }
82 bool is_property() const { return type_ == NAMED || type_ == KEYED; }
83 bool is_unloaded() const { return type_ == UNLOADED; }
85 // Return the name. Only valid for named property references.
86 Handle<String> GetName();
88 // Generate code to push the value of the reference on top of the
89 // expression stack. The reference is expected to be already on top of
90 // the expression stack, and it is consumed by the call unless the
91 // reference is for a compound assignment.
92 // If the reference is not consumed, it is left in place under its value.
95 // Generate code to store the value on top of the expression stack in the
96 // reference. The reference is expected to be immediately below the value
97 // on the expression stack. The value is stored in the location specified
98 // by the reference, and is left on top of the stack, after the reference
99 // is popped from beneath it (unloaded).
100 void SetValue(InitState init_state);
103 CodeGenerator* cgen_;
104 Expression* expression_;
106 // Keep the reference on the stack after get, so it can be used by set later.
107 bool persist_after_get_;
111 // -------------------------------------------------------------------------
112 // Code generation state
114 // The state is passed down the AST by the code generator (and back up, in
115 // the form of the state of the label pair). It is threaded through the
116 // call stack. Constructing a state implicitly pushes it on the owning code
117 // generator's stack of states, and destroying one implicitly pops it.
119 class CodeGenState BASE_EMBEDDED {
121 // Create an initial code generator state. Destroying the initial state
122 // leaves the code generator with a NULL state.
123 explicit CodeGenState(CodeGenerator* owner);
125 // Create a code generator state based on a code generator's current
126 // state. The new state has its own pair of branch labels.
127 CodeGenState(CodeGenerator* owner,
128 JumpTarget* true_target,
129 JumpTarget* false_target);
131 // Destroy a code generator state and restore the owning code generator's
135 JumpTarget* true_target() const { return true_target_; }
136 JumpTarget* false_target() const { return false_target_; }
139 CodeGenerator* owner_;
140 JumpTarget* true_target_;
141 JumpTarget* false_target_;
142 CodeGenState* previous_;
146 // -------------------------------------------------------------------------
147 // Arguments allocation mode
149 enum ArgumentsAllocationMode {
150 NO_ARGUMENTS_ALLOCATION,
151 EAGER_ARGUMENTS_ALLOCATION,
152 LAZY_ARGUMENTS_ALLOCATION
156 // -------------------------------------------------------------------------
159 class CodeGenerator: public AstVisitor {
161 // Takes a function literal, generates code for it. This function should only
162 // be called by compiler.cc.
163 static Handle<Code> MakeCode(CompilationInfo* info);
165 // Printing of AST, etc. as requested by flags.
166 static void MakeCodePrologue(CompilationInfo* info);
168 // Allocate and install the code.
169 static Handle<Code> MakeCodeEpilogue(MacroAssembler* masm,
171 CompilationInfo* info);
173 #ifdef ENABLE_LOGGING_AND_PROFILING
174 static bool ShouldGenerateLog(Expression* type);
177 static void SetFunctionInfo(Handle<JSFunction> fun,
178 FunctionLiteral* lit,
180 Handle<Script> script);
182 static void RecordPositions(MacroAssembler* masm, int pos);
185 MacroAssembler* masm() { return masm_; }
186 VirtualFrame* frame() const { return frame_; }
187 inline Handle<Script> script();
189 bool has_valid_frame() const { return frame_ != NULL; }
191 // Set the virtual frame to be new_frame, with non-frame register
192 // reference counts given by non_frame_registers. The non-frame
193 // register reference counts of the old frame are returned in
194 // non_frame_registers.
195 void SetFrame(VirtualFrame* new_frame, RegisterFile* non_frame_registers);
199 RegisterAllocator* allocator() const { return allocator_; }
201 CodeGenState* state() { return state_; }
202 void set_state(CodeGenState* state) { state_ = state; }
204 void AddDeferred(DeferredCode* code) { deferred_.Add(code); }
206 static const int kUnknownIntValue = -1;
208 // If the name is an inline runtime function call return the number of
209 // expected arguments. Otherwise return -1.
210 static int InlineRuntimeCallArgumentsCount(Handle<String> name);
213 // Construction/Destruction
214 explicit CodeGenerator(MacroAssembler* masm);
217 inline bool is_eval();
218 inline Scope* scope();
220 // Generating deferred code.
221 void ProcessDeferred();
224 bool has_cc() const { return cc_reg_ != al; }
225 JumpTarget* true_target() const { return state_->true_target(); }
226 JumpTarget* false_target() const { return state_->false_target(); }
228 // Track loop nesting level.
229 int loop_nesting() const { return loop_nesting_; }
230 void IncrementLoopNesting() { loop_nesting_++; }
231 void DecrementLoopNesting() { loop_nesting_--; }
234 void VisitStatements(ZoneList<Statement*>* statements);
236 #define DEF_VISIT(type) \
237 void Visit##type(type* node);
238 AST_NODE_LIST(DEF_VISIT)
241 // Visit a statement and then spill the virtual frame if control flow can
242 // reach the end of the statement (ie, it does not exit via break,
243 // continue, return, or throw). This function is used temporarily while
244 // the code generator is being transformed.
245 inline void VisitAndSpill(Statement* statement);
247 // Visit a list of statements and then spill the virtual frame if control
248 // flow can reach the end of the list.
249 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements);
251 // Main code generation function
252 void Generate(CompilationInfo* info);
254 // Returns the arguments allocation mode.
255 ArgumentsAllocationMode ArgumentsMode();
257 // Store the arguments object and allocate it if necessary.
258 void StoreArgumentsObject(bool initial);
260 // The following are used by class Reference.
261 void LoadReference(Reference* ref);
262 void UnloadReference(Reference* ref);
264 static MemOperand ContextOperand(Register context, int index) {
265 return MemOperand(context, Context::SlotOffset(index));
268 MemOperand SlotOperand(Slot* slot, Register tmp);
270 MemOperand ContextSlotOperandCheckExtensions(Slot* slot,
276 static MemOperand GlobalObject() {
277 return ContextOperand(cp, Context::GLOBAL_INDEX);
280 void LoadCondition(Expression* x,
281 JumpTarget* true_target,
282 JumpTarget* false_target,
284 void Load(Expression* expr);
286 void LoadGlobalReceiver(Register scratch);
288 // Generate code to push the value of an expression on top of the frame
289 // and then spill the frame fully to memory. This function is used
290 // temporarily while the code generator is being transformed.
291 inline void LoadAndSpill(Expression* expression);
293 // Call LoadCondition and then spill the virtual frame unless control flow
294 // cannot reach the end of the expression (ie, by emitting only
295 // unconditional jumps to the control targets).
296 inline void LoadConditionAndSpill(Expression* expression,
297 JumpTarget* true_target,
298 JumpTarget* false_target,
301 // Read a value from a slot and leave it on top of the expression stack.
302 void LoadFromSlot(Slot* slot, TypeofState typeof_state);
303 void LoadFromSlotCheckForArguments(Slot* slot, TypeofState state);
304 // Store the value on top of the stack to a slot.
305 void StoreToSlot(Slot* slot, InitState init_state);
307 // Load a named property, leaving it in r0. The receiver is passed on the
308 // stack, and remain there.
309 void EmitNamedLoad(Handle<String> name, bool is_contextual);
311 // Load a keyed property, leaving it in r0. The receiver and key are
312 // passed on the stack, and remain there.
313 void EmitKeyedLoad(bool is_global);
315 void LoadFromGlobalSlotCheckExtensions(Slot* slot,
316 TypeofState typeof_state,
321 // Special code for typeof expressions: Unfortunately, we must
322 // be careful when loading the expression in 'typeof'
323 // expressions. We are not allowed to throw reference errors for
324 // non-existing properties of the global object, so we must make it
325 // look like an explicit property access, instead of an access
326 // through the context chain.
327 void LoadTypeofExpression(Expression* x);
329 void ToBoolean(JumpTarget* true_target, JumpTarget* false_target);
331 // Generate code that computes a shortcutting logical operation.
332 void GenerateLogicalBooleanOperation(BinaryOperation* node);
334 void GenericBinaryOperation(Token::Value op,
335 OverwriteMode overwrite_mode,
336 int known_rhs = kUnknownIntValue);
337 void VirtualFrameBinaryOperation(Token::Value op,
338 OverwriteMode overwrite_mode,
339 int known_rhs = kUnknownIntValue);
340 void Comparison(Condition cc,
343 bool strict = false);
345 void SmiOperation(Token::Value op,
346 Handle<Object> value,
350 void VirtualFrameSmiOperation(Token::Value op,
351 Handle<Object> value,
355 void CallWithArguments(ZoneList<Expression*>* arguments,
356 CallFunctionFlags flags,
359 // An optimized implementation of expressions of the form
360 // x.apply(y, arguments). We call x the applicand and y the receiver.
361 // The optimization avoids allocating an arguments object if possible.
362 void CallApplyLazy(Expression* applicand,
363 Expression* receiver,
364 VariableProxy* arguments,
368 void Branch(bool if_true, JumpTarget* target);
371 struct InlineRuntimeLUT {
372 void (CodeGenerator::*method)(ZoneList<Expression*>*);
377 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name);
378 bool CheckForInlineRuntimeCall(CallRuntime* node);
379 static bool PatchInlineRuntimeEntry(Handle<String> name,
380 const InlineRuntimeLUT& new_entry,
381 InlineRuntimeLUT* old_entry);
383 static Handle<Code> ComputeLazyCompile(int argc);
384 void ProcessDeclarations(ZoneList<Declaration*>* declarations);
386 static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop);
388 // Declare global variables and functions in the given array of
390 void DeclareGlobals(Handle<FixedArray> pairs);
392 // Instantiate the function based on the shared function info.
393 void InstantiateFunction(Handle<SharedFunctionInfo> function_info);
395 // Support for type checks.
396 void GenerateIsSmi(ZoneList<Expression*>* args);
397 void GenerateIsNonNegativeSmi(ZoneList<Expression*>* args);
398 void GenerateIsArray(ZoneList<Expression*>* args);
399 void GenerateIsRegExp(ZoneList<Expression*>* args);
400 void GenerateIsObject(ZoneList<Expression*>* args);
401 void GenerateIsFunction(ZoneList<Expression*>* args);
402 void GenerateIsUndetectableObject(ZoneList<Expression*>* args);
404 // Support for construct call checks.
405 void GenerateIsConstructCall(ZoneList<Expression*>* args);
407 // Support for arguments.length and arguments[?].
408 void GenerateArgumentsLength(ZoneList<Expression*>* args);
409 void GenerateArguments(ZoneList<Expression*>* args);
411 // Support for accessing the class and value fields of an object.
412 void GenerateClassOf(ZoneList<Expression*>* args);
413 void GenerateValueOf(ZoneList<Expression*>* args);
414 void GenerateSetValueOf(ZoneList<Expression*>* args);
416 // Fast support for charCodeAt(n).
417 void GenerateFastCharCodeAt(ZoneList<Expression*>* args);
419 // Fast support for string.charAt(n) and string[n].
420 void GenerateCharFromCode(ZoneList<Expression*>* args);
422 // Fast support for object equality testing.
423 void GenerateObjectEquals(ZoneList<Expression*>* args);
425 void GenerateLog(ZoneList<Expression*>* args);
427 // Fast support for Math.random().
428 void GenerateRandomHeapNumber(ZoneList<Expression*>* args);
430 // Fast support for StringAdd.
431 void GenerateStringAdd(ZoneList<Expression*>* args);
433 // Fast support for SubString.
434 void GenerateSubString(ZoneList<Expression*>* args);
436 // Fast support for StringCompare.
437 void GenerateStringCompare(ZoneList<Expression*>* args);
439 // Support for direct calls from JavaScript to native RegExp code.
440 void GenerateRegExpExec(ZoneList<Expression*>* args);
442 void GenerateRegExpConstructResult(ZoneList<Expression*>* args);
444 // Support for fast native caches.
445 void GenerateGetFromCache(ZoneList<Expression*>* args);
447 // Fast support for number to string.
448 void GenerateNumberToString(ZoneList<Expression*>* args);
450 // Fast call for custom callbacks.
451 void GenerateCallFunction(ZoneList<Expression*>* args);
453 // Fast call to math functions.
454 void GenerateMathPow(ZoneList<Expression*>* args);
455 void GenerateMathSin(ZoneList<Expression*>* args);
456 void GenerateMathCos(ZoneList<Expression*>* args);
457 void GenerateMathSqrt(ZoneList<Expression*>* args);
459 // Simple condition analysis.
460 enum ConditionAnalysis {
465 ConditionAnalysis AnalyzeCondition(Expression* cond);
467 // Methods used to indicate which source code is generated for. Source
468 // positions are collected by the assembler and emitted with the relocation
470 void CodeForFunctionPosition(FunctionLiteral* fun);
471 void CodeForReturnPosition(FunctionLiteral* fun);
472 void CodeForStatementPosition(Statement* node);
473 void CodeForDoWhileConditionPosition(DoWhileStatement* stmt);
474 void CodeForSourcePosition(int pos);
477 // True if the registers are valid for entry to a block.
478 bool HasValidEntryRegisters();
481 List<DeferredCode*> deferred_;
484 MacroAssembler* masm_; // to generate code
486 CompilationInfo* info_;
488 // Code generation state
489 VirtualFrame* frame_;
490 RegisterAllocator* allocator_;
492 CodeGenState* state_;
496 BreakTarget function_return_;
498 // True if the function return is shadowed (ie, jumping to the target
499 // function_return_ does not jump to the true function return, but rather
500 // to some unlinking code).
501 bool function_return_is_shadowed_;
503 static InlineRuntimeLUT kInlineRuntimeLUT[];
505 friend class VirtualFrame;
506 friend class JumpTarget;
507 friend class Reference;
508 friend class FastCodeGenerator;
509 friend class FullCodeGenerator;
510 friend class FullCodeGenSyntaxChecker;
512 DISALLOW_COPY_AND_ASSIGN(CodeGenerator);
516 class GenericBinaryOpStub : public CodeStub {
518 GenericBinaryOpStub(Token::Value op,
522 int constant_rhs = CodeGenerator::kUnknownIntValue)
527 constant_rhs_(constant_rhs),
528 specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op, constant_rhs)),
529 runtime_operands_type_(BinaryOpIC::DEFAULT),
532 GenericBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info)
533 : op_(OpBits::decode(key)),
534 mode_(ModeBits::decode(key)),
535 lhs_(LhsRegister(RegisterBits::decode(key))),
536 rhs_(RhsRegister(RegisterBits::decode(key))),
537 constant_rhs_(KnownBitsForMinorKey(KnownIntBits::decode(key))),
538 specialized_on_rhs_(RhsIsOneWeWantToOptimizeFor(op_, constant_rhs_)),
539 runtime_operands_type_(type_info),
548 bool specialized_on_rhs_;
549 BinaryOpIC::TypeInfo runtime_operands_type_;
552 static const int kMaxKnownRhs = 0x40000000;
553 static const int kKnownRhsKeyBits = 6;
555 // Minor key encoding in 17 bits.
556 class ModeBits: public BitField<OverwriteMode, 0, 2> {};
557 class OpBits: public BitField<Token::Value, 2, 6> {};
558 class TypeInfoBits: public BitField<int, 8, 2> {};
559 class RegisterBits: public BitField<bool, 10, 1> {};
560 class KnownIntBits: public BitField<int, 11, kKnownRhsKeyBits> {};
562 Major MajorKey() { return GenericBinaryOp; }
564 ASSERT((lhs_.is(r0) && rhs_.is(r1)) ||
565 (lhs_.is(r1) && rhs_.is(r0)));
566 // Encode the parameters in a unique 18 bit value.
567 return OpBits::encode(op_)
568 | ModeBits::encode(mode_)
569 | KnownIntBits::encode(MinorKeyForKnownInt())
570 | TypeInfoBits::encode(runtime_operands_type_)
571 | RegisterBits::encode(lhs_.is(r0));
574 void Generate(MacroAssembler* masm);
575 void HandleNonSmiBitwiseOp(MacroAssembler* masm, Register lhs, Register rhs);
576 void HandleBinaryOpSlowCases(MacroAssembler* masm,
580 const Builtins::JavaScript& builtin);
581 void GenerateTypeTransition(MacroAssembler* masm);
583 static bool RhsIsOneWeWantToOptimizeFor(Token::Value op, int constant_rhs) {
584 if (constant_rhs == CodeGenerator::kUnknownIntValue) return false;
585 if (op == Token::DIV) return constant_rhs >= 2 && constant_rhs <= 3;
586 if (op == Token::MOD) {
587 if (constant_rhs <= 1) return false;
588 if (constant_rhs <= 10) return true;
589 if (constant_rhs <= kMaxKnownRhs && IsPowerOf2(constant_rhs)) return true;
595 int MinorKeyForKnownInt() {
596 if (!specialized_on_rhs_) return 0;
597 if (constant_rhs_ <= 10) return constant_rhs_ + 1;
598 ASSERT(IsPowerOf2(constant_rhs_));
600 int d = constant_rhs_;
601 while ((d & 1) == 0) {
605 ASSERT(key >= 0 && key < (1 << kKnownRhsKeyBits));
609 int KnownBitsForMinorKey(int key) {
611 if (key <= 11) return key - 1;
620 Register LhsRegister(bool lhs_is_r0) {
621 return lhs_is_r0 ? r0 : r1;
624 Register RhsRegister(bool lhs_is_r0) {
625 return lhs_is_r0 ? r1 : r0;
628 bool ShouldGenerateSmiCode() {
629 return ((op_ != Token::DIV && op_ != Token::MOD) || specialized_on_rhs_) &&
630 runtime_operands_type_ != BinaryOpIC::HEAP_NUMBERS &&
631 runtime_operands_type_ != BinaryOpIC::STRINGS;
634 bool ShouldGenerateFPCode() {
635 return runtime_operands_type_ != BinaryOpIC::STRINGS;
638 virtual int GetCodeKind() { return Code::BINARY_OP_IC; }
640 virtual InlineCacheState GetICState() {
641 return BinaryOpIC::ToState(runtime_operands_type_);
644 const char* GetName();
648 if (!specialized_on_rhs_) {
649 PrintF("GenericBinaryOpStub (%s)\n", Token::String(op_));
651 PrintF("GenericBinaryOpStub (%s by %d)\n",
660 class StringStubBase: public CodeStub {
662 // Generate code for copying characters using a simple loop. This should only
663 // be used in places where the number of characters is small and the
664 // additional setup and checking in GenerateCopyCharactersLong adds too much
665 // overhead. Copying of overlapping regions is not supported.
666 // Dest register ends at the position after the last character written.
667 void GenerateCopyCharacters(MacroAssembler* masm,
674 // Generate code for copying a large number of characters. This function
675 // is allowed to spend extra time setting up conditions to make copying
676 // faster. Copying of overlapping regions is not supported.
677 // Dest register ends at the position after the last character written.
678 void GenerateCopyCharactersLong(MacroAssembler* masm,
690 // Probe the symbol table for a two character string. If the string is
691 // not found by probing a jump to the label not_found is performed. This jump
692 // does not guarantee that the string is not in the symbol table. If the
693 // string is found the code falls through with the string in register r0.
694 // Contents of both c1 and c2 registers are modified. At the exit c1 is
695 // guaranteed to contain halfword with low and high bytes equal to
696 // initial contents of c1 and c2 respectively.
697 void GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm,
707 // Generate string hash.
708 void GenerateHashInit(MacroAssembler* masm,
712 void GenerateHashAddCharacter(MacroAssembler* masm,
716 void GenerateHashGetHash(MacroAssembler* masm,
721 // Flag that indicates how to generate code for the stub StringAddStub.
722 enum StringAddFlags {
723 NO_STRING_ADD_FLAGS = 0,
724 NO_STRING_CHECK_IN_STUB = 1 << 0 // Omit string check in stub.
728 class StringAddStub: public StringStubBase {
730 explicit StringAddStub(StringAddFlags flags) {
731 string_check_ = ((flags & NO_STRING_CHECK_IN_STUB) == 0);
735 Major MajorKey() { return StringAdd; }
736 int MinorKey() { return string_check_ ? 0 : 1; }
738 void Generate(MacroAssembler* masm);
740 // Should the stub check whether arguments are strings?
745 class SubStringStub: public StringStubBase {
750 Major MajorKey() { return SubString; }
751 int MinorKey() { return 0; }
753 void Generate(MacroAssembler* masm);
758 class StringCompareStub: public CodeStub {
760 StringCompareStub() { }
762 // Compare two flat ASCII strings and returns result in r0.
763 // Does not use the stack.
764 static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
773 Major MajorKey() { return StringCompare; }
774 int MinorKey() { return 0; }
776 void Generate(MacroAssembler* masm);
780 // This stub can convert a signed int32 to a heap number (double). It does
781 // not work for int32s that are in Smi range! No GC occurs during this stub
782 // so you don't have to set up the frame.
783 class WriteInt32ToHeapNumberStub : public CodeStub {
785 WriteInt32ToHeapNumberStub(Register the_int,
786 Register the_heap_number,
789 the_heap_number_(the_heap_number),
790 scratch_(scratch) { }
794 Register the_heap_number_;
797 // Minor key encoding in 16 bits.
798 class IntRegisterBits: public BitField<int, 0, 4> {};
799 class HeapNumberRegisterBits: public BitField<int, 4, 4> {};
800 class ScratchRegisterBits: public BitField<int, 8, 4> {};
802 Major MajorKey() { return WriteInt32ToHeapNumber; }
804 // Encode the parameters in a unique 16 bit value.
805 return IntRegisterBits::encode(the_int_.code())
806 | HeapNumberRegisterBits::encode(the_heap_number_.code())
807 | ScratchRegisterBits::encode(scratch_.code());
810 void Generate(MacroAssembler* masm);
812 const char* GetName() { return "WriteInt32ToHeapNumberStub"; }
815 void Print() { PrintF("WriteInt32ToHeapNumberStub\n"); }
820 class NumberToStringStub: public CodeStub {
822 NumberToStringStub() { }
824 // Generate code to do a lookup in the number string cache. If the number in
825 // the register object is found in the cache the generated code falls through
826 // with the result in the result register. The object and the result register
827 // can be the same. If the number is not found in the cache the code jumps to
828 // the label not_found with only the content of register object unchanged.
829 static void GenerateLookupNumberStringCache(MacroAssembler* masm,
838 Major MajorKey() { return NumberToString; }
839 int MinorKey() { return 0; }
841 void Generate(MacroAssembler* masm);
843 const char* GetName() { return "NumberToStringStub"; }
847 PrintF("NumberToStringStub\n");
853 } } // namespace v8::internal
855 #endif // V8_ARM_CODEGEN_ARM_H_