📄 objects-inl.h.svn-base
字号:
int argc) { // Compute the bit mask. int bits = kind << kFlagsKindShift; bits |= ic_state << kFlagsICStateShift; bits |= type << kFlagsTypeShift; bits |= argc << kFlagsArgumentsCountShift; // Cast to flags and validate result before returning it. Flags result = static_cast<Flags>(bits); ASSERT(ExtractKindFromFlags(result) == kind); ASSERT(ExtractICStateFromFlags(result) == ic_state); ASSERT(ExtractTypeFromFlags(result) == type); ASSERT(ExtractArgumentsCountFromFlags(result) == argc); return result;}Code::Flags Code::ComputeMonomorphicFlags(Kind kind, PropertyType type, int argc) { return ComputeFlags(kind, MONOMORPHIC, type, argc);}Code::Kind Code::ExtractKindFromFlags(Flags flags) { int bits = (flags & kFlagsKindMask) >> kFlagsKindShift; return static_cast<Kind>(bits);}InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { int bits = (flags & kFlagsICStateMask) >> kFlagsICStateShift; return static_cast<InlineCacheState>(bits);}PropertyType Code::ExtractTypeFromFlags(Flags flags) { int bits = (flags & kFlagsTypeMask) >> kFlagsTypeShift; return static_cast<PropertyType>(bits);}int Code::ExtractArgumentsCountFromFlags(Flags flags) { return (flags & kFlagsArgumentsCountMask) >> kFlagsArgumentsCountShift;}Code::Flags Code::RemoveTypeFromFlags(Flags flags) { int bits = flags & ~kFlagsTypeMask; return static_cast<Flags>(bits);}Object* Map::prototype() { return READ_FIELD(this, kPrototypeOffset);}void Map::set_prototype(Object* value) { ASSERT(value->IsNull() || value->IsJSObject()); WRITE_FIELD(this, kPrototypeOffset, value); WRITE_BARRIER(this, kPrototypeOffset);}ACCESSORS(Map, instance_descriptors, DescriptorArray, kInstanceDescriptorsOffset)ACCESSORS(Map, code_cache, FixedArray, kCodeCacheOffset)ACCESSORS(Map, constructor, Object, kConstructorOffset)ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset)ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset)ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset)ACCESSORS(JSGlobalObject, security_token, Object, kSecurityTokenOffset)ACCESSORS(AccessorInfo, getter, Object, kGetterOffset)ACCESSORS(AccessorInfo, setter, Object, kSetterOffset)ACCESSORS(AccessorInfo, data, Object, kDataOffset)ACCESSORS(AccessorInfo, name, Object, kNameOffset)ACCESSORS(AccessorInfo, flag, Smi, kFlagOffset)ACCESSORS(AccessCheckInfo, named_callback, Object, kNamedCallbackOffset)ACCESSORS(AccessCheckInfo, indexed_callback, Object, kIndexedCallbackOffset)ACCESSORS(AccessCheckInfo, data, Object, kDataOffset)ACCESSORS(InterceptorInfo, getter, Object, kGetterOffset)ACCESSORS(InterceptorInfo, setter, Object, kSetterOffset)ACCESSORS(InterceptorInfo, query, Object, kQueryOffset)ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset)ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset)ACCESSORS(InterceptorInfo, data, Object, kDataOffset)ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset)ACCESSORS(CallHandlerInfo, data, Object, kDataOffset)ACCESSORS(TemplateInfo, tag, Object, kTagOffset)ACCESSORS(TemplateInfo, property_list, Object, kPropertyListOffset)ACCESSORS(FunctionTemplateInfo, serial_number, Object, kSerialNumberOffset)ACCESSORS(FunctionTemplateInfo, call_code, Object, kCallCodeOffset)ACCESSORS(FunctionTemplateInfo, property_accessors, Object, kPropertyAccessorsOffset)ACCESSORS(FunctionTemplateInfo, prototype_template, Object, kPrototypeTemplateOffset)ACCESSORS(FunctionTemplateInfo, parent_template, Object, kParentTemplateOffset)ACCESSORS(FunctionTemplateInfo, named_property_handler, Object, kNamedPropertyHandlerOffset)ACCESSORS(FunctionTemplateInfo, indexed_property_handler, Object, kIndexedPropertyHandlerOffset)ACCESSORS(FunctionTemplateInfo, instance_template, Object, kInstanceTemplateOffset)ACCESSORS(FunctionTemplateInfo, class_name, Object, kClassNameOffset)ACCESSORS(FunctionTemplateInfo, signature, Object, kSignatureOffset)ACCESSORS(FunctionTemplateInfo, instance_call_handler, Object, kInstanceCallHandlerOffset)ACCESSORS(FunctionTemplateInfo, access_check_info, Object, kAccessCheckInfoOffset)ACCESSORS(FunctionTemplateInfo, flag, Smi, kFlagOffset)ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset)ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, kInternalFieldCountOffset)ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset)ACCESSORS(SignatureInfo, args, Object, kArgsOffset)ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset)ACCESSORS(Script, source, Object, kSourceOffset)ACCESSORS(Script, name, Object, kNameOffset)ACCESSORS(Script, line_offset, Smi, kLineOffsetOffset)ACCESSORS(Script, column_offset, Smi, kColumnOffsetOffset)ACCESSORS(Script, wrapper, Proxy, kWrapperOffset)ACCESSORS(Script, type, Smi, kTypeOffset)ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoIndex)ACCESSORS(DebugInfo, original_code, Code, kOriginalCodeIndex)ACCESSORS(DebugInfo, code, Code, kPatchedCodeIndex)ACCESSORS(DebugInfo, break_points, FixedArray, kBreakPointsStateIndex)ACCESSORS(BreakPointInfo, code_position, Smi, kCodePositionIndex)ACCESSORS(BreakPointInfo, source_position, Smi, kSourcePositionIndex)ACCESSORS(BreakPointInfo, statement_position, Smi, kStatementPositionIndex)ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex)ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset)ACCESSORS(SharedFunctionInfo, instance_class_name, Object, kInstanceClassNameOffset)ACCESSORS(SharedFunctionInfo, function_data, Object, kExternalReferenceDataOffset)ACCESSORS(SharedFunctionInfo, lazy_load_data, Object, kLazyLoadDataOffset)ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset)ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset)BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype, kHiddenPrototypeBit)BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit)BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check, kNeedsAccessCheckBit)BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, kIsExpressionBit)BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel, kIsTopLevelBit)INT_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)INT_ACCESSORS(SharedFunctionInfo, formal_parameter_count, kFormalParameterCountOffset)INT_ACCESSORS(SharedFunctionInfo, expected_nof_properties, kExpectedNofPropertiesOffset)INT_ACCESSORS(SharedFunctionInfo, start_position_and_type, kStartPositionAndTypeOffset)INT_ACCESSORS(SharedFunctionInfo, end_position, kEndPositionOffset)INT_ACCESSORS(SharedFunctionInfo, function_token_position, kFunctionTokenPositionOffset)void SharedFunctionInfo::DontAdaptArguments() { ASSERT(code()->kind() == Code::BUILTIN); set_formal_parameter_count(kDontAdaptArgumentsSentinel);}int SharedFunctionInfo::start_position() { return start_position_and_type() >> kStartPositionShift;}void SharedFunctionInfo::set_start_position(int start_position) { set_start_position_and_type((start_position << kStartPositionShift) | (start_position_and_type() & ~kStartPositionMask));}Code* SharedFunctionInfo::code() { return Code::cast(READ_FIELD(this, kCodeOffset));}void SharedFunctionInfo::set_code(Code* value) { WRITE_FIELD(this, kCodeOffset, value); WRITE_BARRIER(this, kCodeOffset);}bool SharedFunctionInfo::is_compiled() { // TODO(1242782): Create a code kind for uncompiled code. return code()->kind() != Code::STUB;}bool JSFunction::IsBoilerplate() { return map() == Heap::boilerplate_function_map();}bool JSFunction::IsLoaded() { return shared()->lazy_load_data() == Heap::undefined_value();}Code* JSFunction::code() { return shared()->code();}void JSFunction::set_code(Code* value) { shared()->set_code(value);}Context* JSFunction::context() { return Context::cast(READ_FIELD(this, kContextOffset));}Object* JSFunction::unchecked_context() { return READ_FIELD(this, kContextOffset);}void JSFunction::set_context(Object* value) { ASSERT(value == Heap::undefined_value() || value->IsContext()); WRITE_FIELD(this, kContextOffset, value); WRITE_BARRIER(this, kContextOffset);}ACCESSORS(JSFunction, prototype_or_initial_map, Object, kPrototypeOrInitialMapOffset)Map* JSFunction::initial_map() { return Map::cast(prototype_or_initial_map());}void JSFunction::set_initial_map(Map* value) { set_prototype_or_initial_map(value);}bool JSFunction::has_initial_map() { return prototype_or_initial_map()->IsMap();}bool JSFunction::has_instance_prototype() { return has_initial_map() || !prototype_or_initial_map()->IsTheHole();}bool JSFunction::has_prototype() { return map()->has_non_instance_prototype() || has_instance_prototype();}Object* JSFunction::instance_prototype() { ASSERT(has_instance_prototype()); if (has_initial_map()) return initial_map()->prototype(); // When there is no initial map and the prototype is a JSObject, the // initial map field is used for the prototype field. return prototype_or_initial_map();}Object* JSFunction::prototype() { ASSERT(has_prototype()); // If the function's prototype property has been set to a non-JSObject // value, that value is stored in the constructor field of the map. if (map()->has_non_instance_prototype()) return map()->constructor(); return instance_prototype();}bool JSFunction::is_compiled() { return shared()->is_compiled();}Object* JSBuiltinsObject::javascript_builtin(Builtins::JavaScript id) { ASSERT(0 <= id && id < kJSBuiltinsCount); return READ_FIELD(this, kJSBuiltinsOffset + (id * kPointerSize));}void JSBuiltinsObject::set_javascript_builtin(Builtins::JavaScript id, Object* value) { ASSERT(0 <= id && id < kJSBuiltinsCount); WRITE_FIELD(this, kJSBuiltinsOffset + (id * kPointerSize), value); WRITE_BARRIER(this, kJSBuiltinsOffset + (id * kPointerSize));}Address Proxy::proxy() { return AddressFrom<Address>(READ_INT_FIELD(this, kProxyOffset));}void Proxy::set_proxy(Address value) { WRITE_INT_FIELD(this, kProxyOffset, OffsetFrom(value));}void Proxy::ProxyIterateBody(ObjectVisitor* visitor) { visitor->VisitExternalReference( reinterpret_cast<Address *>(FIELD_ADDR(this, kProxyOffset)));}ACCESSORS(JSValue, value, Object, kValueOffset)JSValue* JSValue::cast(Object* obj) { ASSERT(obj->IsJSValue()); ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); return reinterpret_cast<JSValue*>(obj);}INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset)INT_ACCESSORS(Code, relocation_size, kRelocationSizeOffset)INT_ACCESSORS(Code, sinfo_size, kSInfoSizeOffset)Code::ICTargetState Code::ic_flag() { return static_cast<ICTargetState>(READ_BYTE_FIELD(this, kICFlagOffset));}void Code::set_ic_flag(ICTargetState value) { WRITE_BYTE_FIELD(this, kICFlagOffset, value);}byte* Code::instruction_start() { return FIELD_ADDR(this, kHeaderSize);}int Code::body_size() { return RoundUp(instruction_size() + relocation_size(), kObjectAlignment);}byte* Code::relocation_start() { return FIELD_ADDR(this, CodeSize() - sinfo_size() - relocation_size());}byte* Code::entry() { return instruction_start();}bool Code::contains(byte* pc) { return (instruction_start() <= pc) && (pc < instruction_start() + instruction_size());}byte* Code::sinfo_start() { return FIELD_ADDR(this, CodeSize() - sinfo_size());}ACCESSORS(JSArray, length, Object, kLengthOffset)ACCESSORS(JSRegExp, data, Object, kDataOffset)ACCESSORS(JSRegExp, type, Object, kTypeOffset)JSRegExp::Type JSRegExp::type_tag() { return static_cast<JSRegExp::Type>(Smi::cast(type())->value());}void JSRegExp::set_type_tag(JSRegExp::Type value) { set_type(Smi::FromInt(value));}bool JSObject::HasFastElements() { return !elements()->IsDictionary();}bool JSObject::HasNamedInterceptor() { return map()->has_named_interceptor();}bool JSObject::HasIndexedInterceptor() { return map()->has_indexed_interceptor();}Dictionary* JSObject::property_dictionary() { ASSERT(!HasFastProperties()); return Dictionary::cast(properties());}Dictionary* JSObject::element_dictionary() { ASSERT(!HasFastElements()); return Dictionary::cast(elements());}bool String::HasHashCode() { return (length_field() & kHashComputedMask) != 0;}uint32_t String::Hash() { // Fast case: has hash code already been computed? int hash = length_field(); if (hash & kHashComputedMask) return hash; // Slow case: compute hash code and set it.. return ComputeAndSetHash();}bool String::AsArrayIndex(uint32_t* index) { int hash = length_field(); if ((hash & kHashComputedMask) && !(hash & kIsArrayIndexMask)) return false; return SlowAsArrayIndex(index);}Object* JSObject::GetPrototype() { return JSObject::cast(this)->map()->prototype();}PropertyAttributes JSObject::GetPropertyAttribute(String* key) { return GetPropertyAttributeWithReceiver(this, key);}bool JSObject::HasElement(uint32_t index) { return HasElementWithReceiver(this, index);}bool AccessorInfo::all_can_read() { return BooleanBit::get(flag(), kAllCanReadBit);}void AccessorInfo::set_all_can_read(bool value) { set_flag(BooleanBit::set(flag(), kAllCanReadBit, value));}bool AccessorInfo::all_can_write() { return BooleanBit::get(flag(), kAllCanWriteBit);}void AccessorInfo::set_all_can_write(bool value) { set_flag(BooleanBit::set(flag(), kAllCanWriteBit, value));}PropertyAttributes AccessorInfo::property_attributes() { return AttributesField::decode(static_cast<uint32_t>(flag()->value()));}void AccessorInfo::set_property_attributes(PropertyAttributes attributes) { ASSERT(AttributesField::is_valid(attributes)); int rest_value = flag()->value() & ~AttributesField::mask(); set_flag(Smi::FromInt(rest_value | AttributesField::encode(attributes)));}void Dictionary::SetEntry(int entry, Object* key, Object* value, PropertyDetails details) { ASSERT(!key->IsString() || details.index() > 0); int index = EntryToIndex(entry); WriteBarrierMode mode = GetWriteBarrierMode(); set(index, key, mode); set(index+1, value, mode); fast_set(this, index+2, details.AsSmi());}void Map::ClearCodeCache() { // No write barrier is needed since empty_fixed_array is not in new space. // Please note this function is used during marking: // - MarkCompactCollector::MarkUnmarkedObject ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); WRITE_FIELD(this, kCodeCacheOffset, Heap::empty_fixed_array());}#undef CAST_ACCESSOR#undef INT_ACCESSORS#undef SMI_ACCESSORS#undef ACCESSORS#undef FIELD_ADDR#undef READ_FIELD#undef WRITE_FIELD#undef WRITE_BARRIER#undef READ_MEMADDR_FIELD#undef WRITE_MEMADDR_FIELD#undef READ_DOUBLE_FIELD#undef WRITE_DOUBLE_FIELD#undef READ_INT_FIELD#undef WRITE_INT_FIELD#undef READ_SHORT_FIELD#undef WRITE_SHORT_FIELD#undef READ_BYTE_FIELD#undef WRITE_BYTE_FIELD} } // namespace v8::internal#endif // V8_OBJECTS_INL_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -