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

📄 objects.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
// Copyright 2006-2008 the V8 project authors. 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.//     * Redistributions 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 Google Inc. nor the names of its//       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.#ifndef V8_OBJECTS_H_#define V8_OBJECTS_H_#include "builtins.h"#include "code-stubs.h"#include "smart-pointer.h"#include "unicode-inl.h"//// All object types in the V8 JavaScript are described in this file.//// Inheritance hierarchy://   - Object//     - Smi          (immediate small integer)//     - Failure      (immediate for marking failed operation)//     - HeapObject   (superclass for everything allocated in the heap)//       - JSObject//         - JSArray//         - JSRegExp//         - JSFunction//         - GlobalObject//           - JSGlobalObject//           - JSBuiltinsObject//         - JSValue//         - Script//       - Array//         - ByteArray//         - FixedArray//           - DescriptorArray//           - HashTable//             - Dictionary//             - SymbolTable//           - Context//           - GlobalContext//       - String//         - SeqString//           - AsciiString//           - TwoByteString//         - ConsString//         - SlicedString//         - ExternalString//           - ExternalAsciiString//           - ExternalTwoByteString//       - HeapNumber//       - Code//       - Map//       - Oddball//       - Proxy//       - SharedFunctionInfo//       - Struct//         - AccessorInfo//         - AccessCheckInfo//         - InterceptorInfo//         - CallHandlerInfo//         - FunctionTemplateInfo//         - ObjectTemplateInfo//         - SignatureInfo//         - TypeSwitchInfo//         - DebugInfo//         - BreakPointInfo//// Formats of Object*://  Smi:        [31 bit signed int] 0//  HeapObject: [32 bit direct pointer] (4 byte aligned) | 01//  Failure:    [30 bit signed int] 11// Ecma-262 3rd 8.6.1enum PropertyAttributes {  NONE              = v8::None,  READ_ONLY         = v8::ReadOnly,  DONT_ENUM         = v8::DontEnum,  DONT_DELETE       = v8::DontDelete,  ABSENT            = 16  // Used in runtime to indicate a property is absent.  // ABSENT can never be stored in or returned from a descriptor's attributes  // bitfield.  It is only used as a return value meaning the attributes of  // a non-existent property.};namespace v8 { namespace internal {// PropertyDetails captures type and attributes for a property.// They are used both in property dictionaries and instance descriptors.class PropertyDetails BASE_EMBEDDED { public:  PropertyDetails(PropertyAttributes attributes,                  PropertyType type,                  int index = 0) {    ASSERT(TypeField::is_valid(type));    ASSERT(AttributesField::is_valid(attributes));    ASSERT(IndexField::is_valid(index));    value_ = TypeField::encode(type)        | AttributesField::encode(attributes)        | IndexField::encode(index);    ASSERT(type == this->type());    ASSERT(attributes == this->attributes());    ASSERT(index == this->index());  }  // Conversion for storing details as Object*.  inline PropertyDetails(Smi* smi);  inline Smi* AsSmi();  PropertyType type() { return TypeField::decode(value_); }  bool IsTransition() {    PropertyType t = type();    ASSERT(t != INTERCEPTOR);    return t == MAP_TRANSITION || t == CONSTANT_TRANSITION;  }  PropertyAttributes attributes() { return AttributesField::decode(value_); }  int index() { return IndexField::decode(value_); }  static bool IsValidIndex(int index) { return IndexField::is_valid(index); }  bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; }  bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; }  bool IsDontEnum() { return (attributes() & DONT_ENUM) != 0; }  // Bit fields in value_ (type, shift, size). Must be public so the  // constants can be embedded in generated code.  class TypeField:       public BitField<PropertyType,       0, 3> {};  class AttributesField: public BitField<PropertyAttributes, 3, 3> {};  class IndexField:      public BitField<uint32_t,           6, 32-6> {};  static const int kInitialIndex = 1; private:  uint32_t value_;};// All Maps have a field instance_type containing a InstanceType.// It describes the type of the instances.//// As an example, a JavaScript object is a heap object and its map// instance_type is JS_OBJECT_TYPE.//// The names of the string instance types are intended to systematically// mirror their encoding in the instance_type field of the map.  The length// (SHORT, MEDIUM, or LONG) is always mentioned.  The default encoding is// considered TWO_BYTE.  It is not mentioned in the name.  ASCII encoding is// mentioned explicitly in the name.  Likewise, the default representation is// considered sequential.  It is not mentioned in the name.  The other// representations (eg, CONS, SLICED, EXTERNAL) are explicitly mentioned.// Finally, the string is either a SYMBOL_TYPE (if it is a symbol) or a// STRING_TYPE (if it is not a symbol).//// NOTE: The following things are some that depend on the string types having// instance_types that are less than those of all other types:// HeapObject::Size, HeapObject::IterateBody, the typeof operator, and// Object::IsString.//// NOTE: Everything following JS_VALUE_TYPE is considered a// JSObject for GC purposes. The first four entries here have typeof// 'object', whereas JS_FUNCTION_TYPE has typeof 'function'.#define INSTANCE_TYPE_LIST(V)                   \  V(SHORT_SYMBOL_TYPE)                          \  V(MEDIUM_SYMBOL_TYPE)                         \  V(LONG_SYMBOL_TYPE)                           \  V(SHORT_ASCII_SYMBOL_TYPE)                    \  V(MEDIUM_ASCII_SYMBOL_TYPE)                   \  V(LONG_ASCII_SYMBOL_TYPE)                     \  V(SHORT_CONS_SYMBOL_TYPE)                     \  V(MEDIUM_CONS_SYMBOL_TYPE)                    \  V(LONG_CONS_SYMBOL_TYPE)                      \  V(SHORT_CONS_ASCII_SYMBOL_TYPE)               \  V(MEDIUM_CONS_ASCII_SYMBOL_TYPE)              \  V(LONG_CONS_ASCII_SYMBOL_TYPE)                \  V(SHORT_SLICED_SYMBOL_TYPE)                   \  V(MEDIUM_SLICED_SYMBOL_TYPE)                  \  V(LONG_SLICED_SYMBOL_TYPE)                    \  V(SHORT_SLICED_ASCII_SYMBOL_TYPE)             \  V(MEDIUM_SLICED_ASCII_SYMBOL_TYPE)            \  V(LONG_SLICED_ASCII_SYMBOL_TYPE)              \  V(SHORT_EXTERNAL_SYMBOL_TYPE)                 \  V(MEDIUM_EXTERNAL_SYMBOL_TYPE)                \  V(LONG_EXTERNAL_SYMBOL_TYPE)                  \  V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE)           \  V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE)          \  V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE)            \  V(SHORT_STRING_TYPE)                          \  V(MEDIUM_STRING_TYPE)                         \  V(LONG_STRING_TYPE)                           \  V(SHORT_ASCII_STRING_TYPE)                    \  V(MEDIUM_ASCII_STRING_TYPE)                   \  V(LONG_ASCII_STRING_TYPE)                     \  V(SHORT_CONS_STRING_TYPE)                     \  V(MEDIUM_CONS_STRING_TYPE)                    \  V(LONG_CONS_STRING_TYPE)                      \  V(SHORT_CONS_ASCII_STRING_TYPE)               \  V(MEDIUM_CONS_ASCII_STRING_TYPE)              \  V(LONG_CONS_ASCII_STRING_TYPE)                \  V(SHORT_SLICED_STRING_TYPE)                   \  V(MEDIUM_SLICED_STRING_TYPE)                  \  V(LONG_SLICED_STRING_TYPE)                    \  V(SHORT_SLICED_ASCII_STRING_TYPE)             \  V(MEDIUM_SLICED_ASCII_STRING_TYPE)            \  V(LONG_SLICED_ASCII_STRING_TYPE)              \  V(SHORT_EXTERNAL_STRING_TYPE)                 \  V(MEDIUM_EXTERNAL_STRING_TYPE)                \  V(LONG_EXTERNAL_STRING_TYPE)                  \  V(SHORT_EXTERNAL_ASCII_STRING_TYPE)           \  V(MEDIUM_EXTERNAL_ASCII_STRING_TYPE)          \  V(LONG_EXTERNAL_ASCII_STRING_TYPE)            \  V(LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE)    \                                                \  V(MAP_TYPE)                                   \  V(HEAP_NUMBER_TYPE)                           \  V(FIXED_ARRAY_TYPE)                           \  V(CODE_TYPE)                                  \  V(ODDBALL_TYPE)                               \  V(PROXY_TYPE)                                 \  V(BYTE_ARRAY_TYPE)                            \  V(FILLER_TYPE)                                \                                                \  V(ACCESSOR_INFO_TYPE)                         \  V(ACCESS_CHECK_INFO_TYPE)                     \  V(INTERCEPTOR_INFO_TYPE)                      \  V(SHARED_FUNCTION_INFO_TYPE)                  \  V(CALL_HANDLER_INFO_TYPE)                     \  V(FUNCTION_TEMPLATE_INFO_TYPE)                \  V(OBJECT_TEMPLATE_INFO_TYPE)                  \  V(SIGNATURE_INFO_TYPE)                        \  V(TYPE_SWITCH_INFO_TYPE)                      \  V(DEBUG_INFO_TYPE)                            \  V(BREAK_POINT_INFO_TYPE)                      \  V(SCRIPT_TYPE)                                \                                                \  V(JS_VALUE_TYPE)                              \  V(JS_OBJECT_TYPE)                             \  V(JS_GLOBAL_OBJECT_TYPE)                      \  V(JS_BUILTINS_OBJECT_TYPE)                    \  V(JS_ARRAY_TYPE)                              \  V(JS_REGEXP_TYPE)                             \                                                \  V(JS_FUNCTION_TYPE)                           \// Since string types are not consecutive, this macro is used to// iterate over them.#define STRING_TYPE_LIST(V)                                                    \  V(SHORT_SYMBOL_TYPE, TwoByteString::kHeaderSize, short_symbol)               \  V(MEDIUM_SYMBOL_TYPE, TwoByteString::kHeaderSize, medium_symbol)             \  V(LONG_SYMBOL_TYPE, TwoByteString::kHeaderSize, long_symbol)                 \  V(SHORT_ASCII_SYMBOL_TYPE, AsciiString::kHeaderSize, short_ascii_symbol)     \  V(MEDIUM_ASCII_SYMBOL_TYPE, AsciiString::kHeaderSize, medium_ascii_symbol)   \  V(LONG_ASCII_SYMBOL_TYPE, AsciiString::kHeaderSize, long_ascii_symbol)       \  V(SHORT_CONS_SYMBOL_TYPE, ConsString::kSize, short_cons_symbol)              \  V(MEDIUM_CONS_SYMBOL_TYPE, ConsString::kSize, medium_cons_symbol)            \  V(LONG_CONS_SYMBOL_TYPE, ConsString::kSize, long_cons_symbol)                \  V(SHORT_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, short_cons_ascii_symbol)  \  V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, medium_cons_ascii_symbol)\  V(LONG_CONS_ASCII_SYMBOL_TYPE, ConsString::kSize, long_cons_ascii_symbol)    \  V(SHORT_SLICED_SYMBOL_TYPE, SlicedString::kSize, short_sliced_symbol)        \  V(MEDIUM_SLICED_SYMBOL_TYPE, SlicedString::kSize, medium_sliced_symbol)      \  V(LONG_SLICED_SYMBOL_TYPE, SlicedString::kSize, long_sliced_symbol)          \  V(SHORT_SLICED_ASCII_SYMBOL_TYPE,                                            \    SlicedString::kSize,                                                       \    short_sliced_ascii_symbol)                                                 \  V(MEDIUM_SLICED_ASCII_SYMBOL_TYPE,                                           \    SlicedString::kSize,                                                       \    medium_sliced_ascii_symbol)                                                \  V(LONG_SLICED_ASCII_SYMBOL_TYPE,                                             \    SlicedString::kSize,                                                       \    long_sliced_ascii_symbol)                                                  \  V(SHORT_EXTERNAL_SYMBOL_TYPE,                                                \    ExternalTwoByteString::kSize,                                              \    short_external_symbol)                                                     \  V(MEDIUM_EXTERNAL_SYMBOL_TYPE,                                               \    ExternalTwoByteString::kSize,                                              \    medium_external_symbol)                                                    \  V(LONG_EXTERNAL_SYMBOL_TYPE,                                                 \    ExternalTwoByteString::kSize,                                              \    long_external_symbol)                                                      \  V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE,                                          \    ExternalAsciiString::kSize,                                                \    short_external_ascii_symbol)                                               \  V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE,                                         \    ExternalAsciiString::kSize,                                                \    medium_external_ascii_symbol)                                              \  V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE,                                           \    ExternalAsciiString::kSize,                                                \    long_external_ascii_symbol)                                                \  V(SHORT_STRING_TYPE, TwoByteString::kHeaderSize, short_string)               \  V(MEDIUM_STRING_TYPE, TwoByteString::kHeaderSize, medium_string)             \  V(LONG_STRING_TYPE, TwoByteString::kHeaderSize, long_string)                 \  V(SHORT_ASCII_STRING_TYPE, AsciiString::kHeaderSize, short_ascii_string)     \  V(MEDIUM_ASCII_STRING_TYPE, AsciiString::kHeaderSize, medium_ascii_string)   \  V(LONG_ASCII_STRING_TYPE, AsciiString::kHeaderSize, long_ascii_string)       \  V(SHORT_CONS_STRING_TYPE, ConsString::kSize, short_cons_string)              \  V(MEDIUM_CONS_STRING_TYPE, ConsString::kSize, medium_cons_string)            \  V(LONG_CONS_STRING_TYPE, ConsString::kSize, long_cons_string)                \  V(SHORT_CONS_ASCII_STRING_TYPE, ConsString::kSize, short_cons_ascii_string)  \  V(MEDIUM_CONS_ASCII_STRING_TYPE, ConsString::kSize, medium_cons_ascii_string)\  V(LONG_CONS_ASCII_STRING_TYPE, ConsString::kSize, long_cons_ascii_string)    \  V(SHORT_SLICED_STRING_TYPE, SlicedString::kSize, short_sliced_string)        \  V(MEDIUM_SLICED_STRING_TYPE, SlicedString::kSize, medium_sliced_string)      \  V(LONG_SLICED_STRING_TYPE, SlicedString::kSize, long_sliced_string)          \  V(SHORT_SLICED_ASCII_STRING_TYPE,                                            \    SlicedString::kSize,                                                       \

⌨️ 快捷键说明

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