[iwyu] Make factory.h self-contained.
This finally allows to include the factory.h header without having to also inlcude the object-inl.h inline header. It will in turn enable the removal of the last inline header inclusion violation. R=marja@chromium.org Change-Id: Ice2821e1f74cf428d80c8ebf606a218026f37677 Reviewed-on: https://chromium-review.googlesource.com/654862 Reviewed-by: Marja Hölttä <marja@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#47880}
This commit is contained in:
parent
69f8f185e2
commit
bae0ea30c4
1
BUILD.gn
1
BUILD.gn
@ -1559,6 +1559,7 @@ v8_source_set("v8_base") {
|
||||
"src/extensions/trigger-failure-extension.h",
|
||||
"src/external-reference-table.cc",
|
||||
"src/external-reference-table.h",
|
||||
"src/factory-inl.h",
|
||||
"src/factory.cc",
|
||||
"src/factory.h",
|
||||
"src/fast-dtoa.cc",
|
||||
|
134
src/factory-inl.h
Normal file
134
src/factory-inl.h
Normal file
@ -0,0 +1,134 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_FACTORY_INL_H_
|
||||
#define V8_FACTORY_INL_H_
|
||||
|
||||
#include "src/factory.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
#define ROOT_ACCESSOR(type, name, camel_name) \
|
||||
Handle<type> Factory::name() { \
|
||||
return Handle<type>(bit_cast<type**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \
|
||||
}
|
||||
ROOT_LIST(ROOT_ACCESSOR)
|
||||
#undef ROOT_ACCESSOR
|
||||
|
||||
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
|
||||
Handle<Map> Factory::name##_map() { \
|
||||
return Handle<Map>(bit_cast<Map**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##Name##MapRootIndex])); \
|
||||
}
|
||||
STRUCT_LIST(STRUCT_MAP_ACCESSOR)
|
||||
#undef STRUCT_MAP_ACCESSOR
|
||||
|
||||
#define STRING_ACCESSOR(name, str) \
|
||||
Handle<String> Factory::name() { \
|
||||
return Handle<String>(bit_cast<String**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
||||
}
|
||||
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
|
||||
#undef STRING_ACCESSOR
|
||||
|
||||
#define SYMBOL_ACCESSOR(name) \
|
||||
Handle<Symbol> Factory::name() { \
|
||||
return Handle<Symbol>(bit_cast<Symbol**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
||||
}
|
||||
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
||||
#undef SYMBOL_ACCESSOR
|
||||
|
||||
#define SYMBOL_ACCESSOR(name, description) \
|
||||
Handle<Symbol> Factory::name() { \
|
||||
return Handle<Symbol>(bit_cast<Symbol**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
||||
}
|
||||
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
||||
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
||||
#undef SYMBOL_ACCESSOR
|
||||
|
||||
Handle<String> Factory::InternalizeString(Handle<String> string) {
|
||||
if (string->IsInternalizedString()) return string;
|
||||
return StringTable::LookupString(isolate(), string);
|
||||
}
|
||||
|
||||
Handle<Name> Factory::InternalizeName(Handle<Name> name) {
|
||||
if (name->IsUniqueName()) return name;
|
||||
return StringTable::LookupString(isolate(), Handle<String>::cast(name));
|
||||
}
|
||||
|
||||
Handle<String> Factory::NewSubString(Handle<String> str, int begin, int end) {
|
||||
if (begin == 0 && end == str->length()) return str;
|
||||
return NewProperSubString(str, begin, end);
|
||||
}
|
||||
|
||||
Handle<Object> Factory::NewNumberFromSize(size_t value,
|
||||
PretenureFlag pretenure) {
|
||||
// We can't use Smi::IsValid() here because that operates on a signed
|
||||
// intptr_t, and casting from size_t could create a bogus sign bit.
|
||||
if (value <= static_cast<size_t>(Smi::kMaxValue)) {
|
||||
return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
|
||||
isolate());
|
||||
}
|
||||
return NewNumber(static_cast<double>(value), pretenure);
|
||||
}
|
||||
|
||||
Handle<Object> Factory::NewNumberFromInt64(int64_t value,
|
||||
PretenureFlag pretenure) {
|
||||
if (value <= std::numeric_limits<int32_t>::max() &&
|
||||
value >= std::numeric_limits<int32_t>::min() &&
|
||||
Smi::IsValid(static_cast<int32_t>(value))) {
|
||||
return Handle<Object>(Smi::FromInt(static_cast<int32_t>(value)), isolate());
|
||||
}
|
||||
return NewNumber(static_cast<double>(value), pretenure);
|
||||
}
|
||||
|
||||
Handle<HeapNumber> Factory::NewHeapNumber(double value, MutableMode mode,
|
||||
PretenureFlag pretenure) {
|
||||
Handle<HeapNumber> heap_number = NewHeapNumber(mode, pretenure);
|
||||
heap_number->set_value(value);
|
||||
return heap_number;
|
||||
}
|
||||
|
||||
Handle<HeapNumber> Factory::NewHeapNumberFromBits(uint64_t bits,
|
||||
MutableMode mode,
|
||||
PretenureFlag pretenure) {
|
||||
Handle<HeapNumber> heap_number = NewHeapNumber(mode, pretenure);
|
||||
heap_number->set_value_as_bits(bits);
|
||||
return heap_number;
|
||||
}
|
||||
|
||||
Handle<HeapNumber> Factory::NewMutableHeapNumber(PretenureFlag pretenure) {
|
||||
return NewHeapNumberFromBits(kHoleNanInt64, MUTABLE, pretenure);
|
||||
}
|
||||
|
||||
Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
|
||||
ElementsKind elements_kind,
|
||||
PretenureFlag pretenure) {
|
||||
return NewJSArrayWithElements(elements, elements_kind, elements->length(),
|
||||
pretenure);
|
||||
}
|
||||
|
||||
Handle<Object> Factory::NewURIError() {
|
||||
return NewError(isolate()->uri_error_function(),
|
||||
MessageTemplate::kURIMalformed);
|
||||
}
|
||||
|
||||
Handle<String> Factory::Uint32ToString(uint32_t value) {
|
||||
Handle<String> result = NumberToString(NewNumberFromUint(value));
|
||||
|
||||
if (result->length() <= String::kMaxArrayIndexSize) {
|
||||
uint32_t field = StringHasher::MakeArrayIndexHash(value, result->length());
|
||||
result->set_hash_field(field);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_FACTORY_INL_H_
|
115
src/factory.h
115
src/factory.h
@ -169,15 +169,9 @@ class V8_EXPORT_PRIVATE Factory final {
|
||||
Handle<String> InternalizeStringWithKey(StringTableKey* key);
|
||||
|
||||
// Internalized strings are created in the old generation (data space).
|
||||
Handle<String> InternalizeString(Handle<String> string) {
|
||||
if (string->IsInternalizedString()) return string;
|
||||
return StringTable::LookupString(isolate(), string);
|
||||
}
|
||||
inline Handle<String> InternalizeString(Handle<String> string);
|
||||
|
||||
Handle<Name> InternalizeName(Handle<Name> name) {
|
||||
if (name->IsUniqueName()) return name;
|
||||
return StringTable::LookupString(isolate(), Handle<String>::cast(name));
|
||||
}
|
||||
inline Handle<Name> InternalizeName(Handle<Name> name);
|
||||
|
||||
// String creation functions. Most of the string creation functions take
|
||||
// a Heap::PretenureFlag argument to optionally request that they be
|
||||
@ -294,10 +288,7 @@ class V8_EXPORT_PRIVATE Factory final {
|
||||
int end);
|
||||
|
||||
// Create a new string object which holds a substring of a string.
|
||||
Handle<String> NewSubString(Handle<String> str, int begin, int end) {
|
||||
if (begin == 0 && end == str->length()) return str;
|
||||
return NewProperSubString(str, begin, end);
|
||||
}
|
||||
inline Handle<String> NewSubString(Handle<String> str, int begin, int end);
|
||||
|
||||
// Creates a new external String object. There are two String encodings
|
||||
// in the system: one-byte and two-byte. Unlike other String types, it does
|
||||
@ -464,44 +455,19 @@ class V8_EXPORT_PRIVATE Factory final {
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
Handle<Object> NewNumberFromUint(uint32_t value,
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
Handle<Object> NewNumberFromSize(size_t value,
|
||||
PretenureFlag pretenure = NOT_TENURED) {
|
||||
// We can't use Smi::IsValid() here because that operates on a signed
|
||||
// intptr_t, and casting from size_t could create a bogus sign bit.
|
||||
if (value <= static_cast<size_t>(Smi::kMaxValue)) {
|
||||
return Handle<Object>(Smi::FromIntptr(static_cast<intptr_t>(value)),
|
||||
isolate());
|
||||
}
|
||||
return NewNumber(static_cast<double>(value), pretenure);
|
||||
}
|
||||
Handle<Object> NewNumberFromInt64(int64_t value,
|
||||
PretenureFlag pretenure = NOT_TENURED) {
|
||||
if (value <= std::numeric_limits<int32_t>::max() &&
|
||||
value >= std::numeric_limits<int32_t>::min() &&
|
||||
Smi::IsValid(static_cast<int32_t>(value))) {
|
||||
return Handle<Object>(Smi::FromInt(static_cast<int32_t>(value)),
|
||||
isolate());
|
||||
}
|
||||
return NewNumber(static_cast<double>(value), pretenure);
|
||||
}
|
||||
Handle<HeapNumber> NewHeapNumber(double value, MutableMode mode = IMMUTABLE,
|
||||
PretenureFlag pretenure = NOT_TENURED) {
|
||||
Handle<HeapNumber> heap_number = NewHeapNumber(mode, pretenure);
|
||||
heap_number->set_value(value);
|
||||
return heap_number;
|
||||
}
|
||||
Handle<HeapNumber> NewHeapNumberFromBits(
|
||||
inline Handle<Object> NewNumberFromSize(
|
||||
size_t value, PretenureFlag pretenure = NOT_TENURED);
|
||||
inline Handle<Object> NewNumberFromInt64(
|
||||
int64_t value, PretenureFlag pretenure = NOT_TENURED);
|
||||
inline Handle<HeapNumber> NewHeapNumber(
|
||||
double value, MutableMode mode = IMMUTABLE,
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
inline Handle<HeapNumber> NewHeapNumberFromBits(
|
||||
uint64_t bits, MutableMode mode = IMMUTABLE,
|
||||
PretenureFlag pretenure = NOT_TENURED) {
|
||||
Handle<HeapNumber> heap_number = NewHeapNumber(mode, pretenure);
|
||||
heap_number->set_value_as_bits(bits);
|
||||
return heap_number;
|
||||
}
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
// Creates mutable heap number object with value field set to hole NaN.
|
||||
Handle<HeapNumber> NewMutableHeapNumber(
|
||||
PretenureFlag pretenure = NOT_TENURED) {
|
||||
return NewHeapNumberFromBits(kHoleNanInt64, MUTABLE, pretenure);
|
||||
}
|
||||
inline Handle<HeapNumber> NewMutableHeapNumber(
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
|
||||
// Creates heap number object with not yet set value field.
|
||||
Handle<HeapNumber> NewHeapNumber(MutableMode mode,
|
||||
@ -557,13 +523,10 @@ class V8_EXPORT_PRIVATE Factory final {
|
||||
ElementsKind elements_kind, int length,
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
|
||||
Handle<JSArray> NewJSArrayWithElements(
|
||||
inline Handle<JSArray> NewJSArrayWithElements(
|
||||
Handle<FixedArrayBase> elements,
|
||||
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
|
||||
PretenureFlag pretenure = NOT_TENURED) {
|
||||
return NewJSArrayWithElements(elements, elements_kind, elements->length(),
|
||||
pretenure);
|
||||
}
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
|
||||
void NewJSArrayStorage(
|
||||
Handle<JSArray> array,
|
||||
@ -707,10 +670,7 @@ class V8_EXPORT_PRIVATE Factory final {
|
||||
|
||||
Handle<Object> NewInvalidStringLengthError();
|
||||
|
||||
Handle<Object> NewURIError() {
|
||||
return NewError(isolate()->uri_error_function(),
|
||||
MessageTemplate::kURIMalformed);
|
||||
}
|
||||
inline Handle<Object> NewURIError();
|
||||
|
||||
Handle<Object> NewError(Handle<JSFunction> constructor,
|
||||
MessageTemplate::Template template_index,
|
||||
@ -737,56 +697,27 @@ class V8_EXPORT_PRIVATE Factory final {
|
||||
Handle<String> NumberToString(Handle<Object> number,
|
||||
bool check_number_string_cache = true);
|
||||
|
||||
Handle<String> Uint32ToString(uint32_t value) {
|
||||
Handle<String> result = NumberToString(NewNumberFromUint(value));
|
||||
|
||||
if (result->length() <= String::kMaxArrayIndexSize) {
|
||||
uint32_t field =
|
||||
StringHasher::MakeArrayIndexHash(value, result->length());
|
||||
result->set_hash_field(field);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
inline Handle<String> Uint32ToString(uint32_t value);
|
||||
|
||||
Handle<JSFunction> InstallMembers(Handle<JSFunction> function);
|
||||
|
||||
#define ROOT_ACCESSOR(type, name, camel_name) \
|
||||
inline Handle<type> name() { \
|
||||
return Handle<type>(bit_cast<type**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##camel_name##RootIndex])); \
|
||||
}
|
||||
#define ROOT_ACCESSOR(type, name, camel_name) inline Handle<type> name();
|
||||
ROOT_LIST(ROOT_ACCESSOR)
|
||||
#undef ROOT_ACCESSOR
|
||||
|
||||
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
|
||||
inline Handle<Map> name##_map() { \
|
||||
return Handle<Map>(bit_cast<Map**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##Name##MapRootIndex])); \
|
||||
}
|
||||
#define STRUCT_MAP_ACCESSOR(NAME, Name, name) inline Handle<Map> name##_map();
|
||||
STRUCT_LIST(STRUCT_MAP_ACCESSOR)
|
||||
#undef STRUCT_MAP_ACCESSOR
|
||||
|
||||
#define STRING_ACCESSOR(name, str) \
|
||||
inline Handle<String> name() { \
|
||||
return Handle<String>(bit_cast<String**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
||||
}
|
||||
#define STRING_ACCESSOR(name, str) inline Handle<String> name();
|
||||
INTERNALIZED_STRING_LIST(STRING_ACCESSOR)
|
||||
#undef STRING_ACCESSOR
|
||||
|
||||
#define SYMBOL_ACCESSOR(name) \
|
||||
inline Handle<Symbol> name() { \
|
||||
return Handle<Symbol>(bit_cast<Symbol**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
||||
}
|
||||
#define SYMBOL_ACCESSOR(name) inline Handle<Symbol> name();
|
||||
PRIVATE_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
||||
#undef SYMBOL_ACCESSOR
|
||||
|
||||
#define SYMBOL_ACCESSOR(name, description) \
|
||||
inline Handle<Symbol> name() { \
|
||||
return Handle<Symbol>(bit_cast<Symbol**>( \
|
||||
&isolate()->heap()->roots_[Heap::k##name##RootIndex])); \
|
||||
}
|
||||
#define SYMBOL_ACCESSOR(name, description) inline Handle<Symbol> name();
|
||||
PUBLIC_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
||||
WELL_KNOWN_SYMBOL_LIST(SYMBOL_ACCESSOR)
|
||||
#undef SYMBOL_ACCESSOR
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef V8_FEEDBACK_VECTOR_INL_H_
|
||||
#define V8_FEEDBACK_VECTOR_INL_H_
|
||||
|
||||
#include "src/factory.h"
|
||||
#include "src/factory-inl.h"
|
||||
#include "src/feedback-vector.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
|
@ -5779,6 +5779,10 @@ void GlobalDictionary::SetEntry(int entry, Object* key, Object* value,
|
||||
DetailsAtPut(entry, details);
|
||||
}
|
||||
|
||||
void GlobalDictionary::ValueAtPut(int entry, Object* value) {
|
||||
set(EntryToIndex(entry), value);
|
||||
}
|
||||
|
||||
bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
|
||||
DCHECK(other->IsNumber());
|
||||
return key == static_cast<uint32_t>(other->Number());
|
||||
@ -6149,6 +6153,24 @@ ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, JSReceiver,
|
||||
ACCESSORS(JSStringIterator, string, String, kStringOffset)
|
||||
SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
|
||||
|
||||
bool ScopeInfo::IsAsmModule() { return AsmModuleField::decode(Flags()); }
|
||||
|
||||
bool ScopeInfo::HasSimpleParameters() {
|
||||
return HasSimpleParametersField::decode(Flags());
|
||||
}
|
||||
|
||||
#define FIELD_ACCESSORS(name) \
|
||||
void ScopeInfo::Set##name(int value) { set(k##name, Smi::FromInt(value)); } \
|
||||
int ScopeInfo::name() { \
|
||||
if (length() > 0) { \
|
||||
return Smi::ToInt(get(k##name)); \
|
||||
} else { \
|
||||
return 0; \
|
||||
} \
|
||||
}
|
||||
FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS)
|
||||
#undef FIELD_ACCESSORS
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
@ -217,7 +217,7 @@ class GlobalDictionary
|
||||
inline void SetEntry(int entry, Object* key, Object* value,
|
||||
PropertyDetails details);
|
||||
inline Name* NameAt(int entry);
|
||||
void ValueAtPut(int entry, Object* value) { set(EntryToIndex(entry), value); }
|
||||
inline void ValueAtPut(int entry, Object* value);
|
||||
};
|
||||
|
||||
class NumberDictionaryShape : public BaseDictionaryShape<uint32_t> {
|
||||
|
@ -83,11 +83,9 @@ class ScopeInfo : public FixedArray {
|
||||
bool HasContext();
|
||||
|
||||
// Return if this is a function scope with "use asm".
|
||||
inline bool IsAsmModule() { return AsmModuleField::decode(Flags()); }
|
||||
inline bool IsAsmModule();
|
||||
|
||||
inline bool HasSimpleParameters() {
|
||||
return HasSimpleParametersField::decode(Flags());
|
||||
}
|
||||
inline bool HasSimpleParameters();
|
||||
|
||||
// Return the function_name if present.
|
||||
String* FunctionName();
|
||||
@ -205,16 +203,9 @@ class ScopeInfo : public FixedArray {
|
||||
V(StackLocalCount) \
|
||||
V(ContextLocalCount)
|
||||
|
||||
#define FIELD_ACCESSORS(name) \
|
||||
inline void Set##name(int value) { set(k##name, Smi::FromInt(value)); } \
|
||||
inline int name() { \
|
||||
if (length() > 0) { \
|
||||
return Smi::ToInt(get(k##name)); \
|
||||
} else { \
|
||||
return 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FIELD_ACCESSORS(name) \
|
||||
inline void Set##name(int value); \
|
||||
inline int name();
|
||||
FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS)
|
||||
#undef FIELD_ACCESSORS
|
||||
|
||||
|
@ -956,6 +956,7 @@
|
||||
'extensions/trigger-failure-extension.h',
|
||||
'external-reference-table.cc',
|
||||
'external-reference-table.h',
|
||||
'factory-inl.h',
|
||||
'factory.cc',
|
||||
'factory.h',
|
||||
'fast-dtoa.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user