⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assembler.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
// Copyright (c) 1994-2006 Sun Microsystems Inc.// All Rights Reserved.//// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are// met://// - Redistributions of source code must retain the above copyright notice,// this list of conditions and the following disclaimer.//// - Redistribution in binary form must reproduce the above copyright// notice, this list of conditions and the following disclaimer in the// documentation and/or other materials provided with the distribution.//// - Neither the name of Sun Microsystems or the names of contributors may// be used to endorse or promote products derived from this software without// specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.// The original source code covered by the above license above has been// modified significantly by Google Inc.// Copyright 2006-2008 the V8 project authors. All rights reserved.#ifndef V8_ASSEMBLER_H_#define V8_ASSEMBLER_H_#include "runtime.h"#include "top.h"#include "zone-inl.h"namespace v8 { namespace internal {// -----------------------------------------------------------------------------// Labels represent pc locations; they are typically jump or call targets.// After declaration, a label can be freely used to denote known or (yet)// unknown pc location. Assembler::bind() is used to bind a label to the// current pc. A label can be bound only once.class Label : public ZoneObject {  // ShadowLables are dynamically allocated. public:  INLINE(Label())                 { Unuse(); }  INLINE(~Label())                { ASSERT(!is_linked()); }  INLINE(void Unuse())            { pos_ = 0; }  INLINE(bool is_bound()  const)  { return pos_ <  0; }  INLINE(bool is_unused() const)  { return pos_ == 0; }  INLINE(bool is_linked() const)  { return pos_ >  0; }  // Returns the position of bound or linked labels. Cannot be used  // for unused labels.  int pos() const; private:  // pos_ encodes both the binding state (via its sign)  // and the binding position (via its value) of a label.  //  // pos_ <  0  bound label, pos() returns the jump target position  // pos_ == 0  unused label  // pos_ >  0  linked label, pos() returns the last reference position  int pos_;  void bind_to(int pos)  {    pos_ = -pos - 1;    ASSERT(is_bound());  }  void link_to(int pos)  {    pos_ =  pos + 1;    ASSERT(is_linked());  }  friend class Assembler;  friend class Displacement;  friend class LabelShadow;};// A LabelShadow is a label that temporarily shadows another label. It// is used to catch linking and binding of labels in certain scopes,// e.g. try blocks. LabelShadows are themselves labels which can be// used (only) after they are not shadowing anymore.class LabelShadow: public Label { public:  explicit LabelShadow(Label* shadowed) {    ASSERT(shadowed != NULL);    shadowed_ = shadowed;    shadowed_pos_ = shadowed->pos_;    shadowed->Unuse();#ifdef DEBUG    is_shadowing_ = true;#endif  }  ~LabelShadow() {    ASSERT(!is_shadowing_);  }  void StopShadowing() {    ASSERT(is_shadowing_ && is_unused());    pos_ = shadowed_->pos_;    shadowed_->pos_ = shadowed_pos_;#ifdef DEBUG    is_shadowing_ = false;#endif  }  Label* shadowed() const { return shadowed_; } private:  Label* shadowed_;  int shadowed_pos_;#ifdef DEBUG  bool is_shadowing_;#endif};// -----------------------------------------------------------------------------// Relocation information// Relocation information consists of the address (pc) of the datum// to which the relocation information applies, the relocation mode// (rmode), and an optional data field. The relocation mode may be// "descriptive" and not indicate a need for relocation, but simply// describe a property of the datum. Such rmodes are useful for GC// and nice disassembly output.class RelocInfo BASE_EMBEDDED { public:  // The constant kNoPosition is used with the collecting of source positions  // in the relocation information. Two types of source positions are collected  // "position" (RelocMode position) and "statement position" (RelocMode  // statement_position). The "position" is collected at places in the source  // code which are of interest when making stack traces to pin-point the source  // location of a stack frame as close as possible. The "statement position" is  // collected at the beginning at each statement, and is used to indicate  // possible break locations. kNoPosition is used to indicate an  // invalid/uninitialized position value.  static const int kNoPosition = -1;  enum Mode {    // Please note the order is important (see IsCodeTarget, IsGCRelocMode).    CONSTRUCT_CALL,  // code target that is a call to a JavaScript constructor.    CODE_TARGET_CONTEXT,  // code target used for contextual loads.    CODE_TARGET,         // code target which is not any of the above.    EMBEDDED_OBJECT,    EMBEDDED_STRING,    // Everything after runtime_entry (inclusive) is not GC'ed.    RUNTIME_ENTRY,    JS_RETURN,  // Marks start of the ExitJSFrame code.    COMMENT,    POSITION,  // See comment for kNoPosition above.    STATEMENT_POSITION,  // See comment for kNoPosition above.    EXTERNAL_REFERENCE,  // The address of an external C++ function.    INTERNAL_REFERENCE,  // An address inside the same function.    // add more as needed    // Pseudo-types    NUMBER_OF_MODES,  // must be no greater than 14 - see RelocInfoWriter    NONE,  // never recorded    LAST_CODE_ENUM = CODE_TARGET,    LAST_GCED_ENUM = EMBEDDED_STRING  };  RelocInfo() {}  RelocInfo(byte* pc, Mode rmode, intptr_t data)      : pc_(pc), rmode_(rmode), data_(data) {  }  static inline bool IsConstructCall(Mode mode) {    return mode == CONSTRUCT_CALL;  }  static inline bool IsCodeTarget(Mode mode) {    return mode <= LAST_CODE_ENUM;  }  // Is the relocation mode affected by GC?  static inline bool IsGCRelocMode(Mode mode) {    return mode <= LAST_GCED_ENUM;  }  static inline bool IsJSReturn(Mode mode) {    return mode == JS_RETURN;  }  static inline bool IsComment(Mode mode) {    return mode == COMMENT;  }  static inline bool IsPosition(Mode mode) {    return mode == POSITION || mode == STATEMENT_POSITION;  }  static inline bool IsStatementPosition(Mode mode) {    return mode == STATEMENT_POSITION;  }  static inline bool IsExternalReference(Mode mode) {    return mode == EXTERNAL_REFERENCE;  }  static inline bool IsInternalReference(Mode mode) {    return mode == INTERNAL_REFERENCE;  }  static inline int ModeMask(Mode mode) { return 1 << mode; }  // Accessors  byte* pc() const  { return pc_; }  void set_pc(byte* pc) { pc_ = pc; }  Mode rmode() const {  return rmode_; }  intptr_t data() const  { return data_; }  // Apply a relocation by delta bytes  INLINE(void apply(int delta));  // Read/modify the code target in the branch/call instruction this relocation  // applies to; can only be called if IsCodeTarget(rmode_)  INLINE(Address target_address());  INLINE(void set_target_address(Address target));  INLINE(Object* target_object());  INLINE(Object** target_object_address());  INLINE(void set_target_object(Object* target));  // Read/modify the reference in the instruction this relocation  // applies to; can only be called if rmode_ is external_reference  INLINE(Address* target_reference_address());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -