11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#include "src/codegen/arm64/assembler-arm64-inl.h" 61cb0ef41Sopenharmony_ci#include "src/diagnostics/eh-frame.h" 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cinamespace v8 { 91cb0ef41Sopenharmony_cinamespace internal { 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cistatic const int kX0DwarfCode = 0; 121cb0ef41Sopenharmony_cistatic const int kFpDwarfCode = 29; 131cb0ef41Sopenharmony_cistatic const int kLrDwarfCode = 30; 141cb0ef41Sopenharmony_cistatic const int kSpDwarfCode = 31; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst int EhFrameConstants::kCodeAlignmentFactor = 4; 171cb0ef41Sopenharmony_ciconst int EhFrameConstants::kDataAlignmentFactor = -8; 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_civoid EhFrameWriter::WriteReturnAddressRegisterCode() { 201cb0ef41Sopenharmony_ci WriteULeb128(kLrDwarfCode); 211cb0ef41Sopenharmony_ci} 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_civoid EhFrameWriter::WriteInitialStateInCie() { 241cb0ef41Sopenharmony_ci SetBaseAddressRegisterAndOffset(x29, 0); 251cb0ef41Sopenharmony_ci RecordRegisterNotModified(x30); 261cb0ef41Sopenharmony_ci} 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci// static 291cb0ef41Sopenharmony_ciint EhFrameWriter::RegisterToDwarfCode(Register name) { 301cb0ef41Sopenharmony_ci switch (name.code()) { 311cb0ef41Sopenharmony_ci case kRegCode_x29: 321cb0ef41Sopenharmony_ci return kFpDwarfCode; 331cb0ef41Sopenharmony_ci case kRegCode_x30: 341cb0ef41Sopenharmony_ci return kLrDwarfCode; 351cb0ef41Sopenharmony_ci case kSPRegInternalCode: 361cb0ef41Sopenharmony_ci return kSpDwarfCode; 371cb0ef41Sopenharmony_ci case kRegCode_x0: 381cb0ef41Sopenharmony_ci return kX0DwarfCode; 391cb0ef41Sopenharmony_ci default: 401cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 411cb0ef41Sopenharmony_ci } 421cb0ef41Sopenharmony_ci} 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci#ifdef ENABLE_DISASSEMBLER 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci// static 471cb0ef41Sopenharmony_ciconst char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { 481cb0ef41Sopenharmony_ci switch (code) { 491cb0ef41Sopenharmony_ci case kFpDwarfCode: 501cb0ef41Sopenharmony_ci return "fp"; 511cb0ef41Sopenharmony_ci case kLrDwarfCode: 521cb0ef41Sopenharmony_ci return "lr"; 531cb0ef41Sopenharmony_ci case kSpDwarfCode: 541cb0ef41Sopenharmony_ci return "sp"; // This could be zr as well 551cb0ef41Sopenharmony_ci default: 561cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 571cb0ef41Sopenharmony_ci } 581cb0ef41Sopenharmony_ci} 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci#endif 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ci} // namespace internal 631cb0ef41Sopenharmony_ci} // namespace v8 64