Home | History | Annotate | Download | only in arm64
      1 // Copyright 2013 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "src/arm64/assembler-arm64.h"
      6 #include "src/arm64/constants-arm64.h"
      7 
      8 #ifndef V8_ARM64_FRAMES_ARM64_H_
      9 #define V8_ARM64_FRAMES_ARM64_H_
     10 
     11 namespace v8 {
     12 namespace internal {
     13 
     14 const int kNumRegs = kNumberOfRegisters;
     15 // Registers x0-x17 are caller-saved.
     16 const int kNumJSCallerSaved = 18;
     17 const RegList kJSCallerSaved = 0x3ffff;
     18 
     19 // Number of registers for which space is reserved in safepoints. Must be a
     20 // multiple of eight.
     21 // TODO(all): Refine this number.
     22 const int kNumSafepointRegisters = 32;
     23 
     24 // Define the list of registers actually saved at safepoints.
     25 // Note that the number of saved registers may be smaller than the reserved
     26 // space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters.
     27 #define kSafepointSavedRegisters CPURegList::GetSafepointSavedRegisters().list()
     28 #define kNumSafepointSavedRegisters \
     29   CPURegList::GetSafepointSavedRegisters().Count();
     30 
     31 class EntryFrameConstants : public AllStatic {
     32  public:
     33   static const int kCallerFPOffset =
     34       -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
     35 };
     36 
     37 
     38 class ExitFrameConstants : public AllStatic {
     39  public:
     40   static const int kFrameSize            =  2 * kPointerSize;
     41 
     42   static const int kCallerSPDisplacement =  2 * kPointerSize;
     43   static const int kCallerPCOffset       =  1 * kPointerSize;
     44   static const int kCallerFPOffset       =  0 * kPointerSize;   // <- fp
     45   static const int kSPOffset             = -1 * kPointerSize;
     46   static const int kCodeOffset           = -2 * kPointerSize;
     47   static const int kLastExitFrameField   = kCodeOffset;
     48 
     49   static const int kConstantPoolOffset   = 0;  // Not used
     50 };
     51 
     52 
     53 class JavaScriptFrameConstants : public AllStatic {
     54  public:
     55   // FP-relative.
     56   static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
     57 
     58   // There are two words on the stack (saved fp and saved lr) between fp and
     59   // the arguments.
     60   static const int kLastParameterOffset = 2 * kPointerSize;
     61 
     62   static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
     63 };
     64 
     65 
     66 class ArgumentsAdaptorFrameConstants : public AllStatic {
     67  public:
     68   // FP-relative.
     69   static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
     70 
     71   static const int kFrameSize =
     72       StandardFrameConstants::kFixedFrameSize + kPointerSize;
     73 };
     74 
     75 
     76 class ConstructFrameConstants : public AllStatic {
     77  public:
     78   // FP-relative.
     79   static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
     80   static const int kLengthOffset           = -4 * kPointerSize;
     81   static const int kConstructorOffset      = -5 * kPointerSize;
     82   static const int kImplicitReceiverOffset = -6 * kPointerSize;
     83 
     84   static const int kFrameSize =
     85       StandardFrameConstants::kFixedFrameSize + 4 * kPointerSize;
     86 };
     87 
     88 
     89 class InternalFrameConstants : public AllStatic {
     90  public:
     91   // FP-relative.
     92   static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
     93 };
     94 
     95 
     96 inline Object* JavaScriptFrame::function_slot_object() const {
     97   const int offset = JavaScriptFrameConstants::kFunctionOffset;
     98   return Memory::Object_at(fp() + offset);
     99 }
    100 
    101 
    102 inline void StackHandler::SetFp(Address slot, Address fp) {
    103   Memory::Address_at(slot) = fp;
    104 }
    105 
    106 
    107 } }  // namespace v8::internal
    108 
    109 #endif  // V8_ARM64_FRAMES_ARM64_H_
    110