[ubsan] Port Name/String/Symbol to the new design

Bug: v8:3770
Change-Id: I4da6404aa968adca1fbb49029fc304622101d6c3
Reviewed-on: https://chromium-review.googlesource.com/c/1349112
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57853}
This commit is contained in:
Jakob Kummerow 2018-11-26 16:48:42 -08:00 committed by Commit Bot
parent fe0d26534c
commit 0f581e4b99
158 changed files with 1042 additions and 1000 deletions

View File

@ -2411,9 +2411,9 @@ class IsIdentifierHelper {
public:
IsIdentifierHelper() : is_identifier_(false), first_char_(true) {}
bool Check(i::String* string) {
i::ConsString* cons_string = i::String::VisitFlat(this, string, 0);
if (cons_string == nullptr) return is_identifier_;
bool Check(i::String string) {
i::ConsString cons_string = i::String::VisitFlat(this, string, 0);
if (cons_string.is_null()) return is_identifier_;
// We don't support cons strings here.
return false;
}
@ -5203,9 +5203,9 @@ static inline const uint16_t* Align(const uint16_t* chars) {
class ContainsOnlyOneByteHelper {
public:
ContainsOnlyOneByteHelper() : is_one_byte_(true) {}
bool Check(i::String* string) {
i::ConsString* cons_string = i::String::VisitFlat(this, string, 0);
if (cons_string == nullptr) return is_one_byte_;
bool Check(i::String string) {
i::ConsString cons_string = i::String::VisitFlat(this, string, 0);
if (cons_string.is_null()) return is_one_byte_;
return CheckCons(cons_string);
}
void VisitOneByteString(const uint8_t* chars, int length) {
@ -5244,20 +5244,18 @@ class ContainsOnlyOneByteHelper {
}
private:
bool CheckCons(i::ConsString* cons_string) {
bool CheckCons(i::ConsString cons_string) {
while (true) {
// Check left side if flat.
i::String* left = cons_string->first();
i::ConsString* left_as_cons =
i::String::VisitFlat(this, left, 0);
i::String left = cons_string->first();
i::ConsString left_as_cons = i::String::VisitFlat(this, left, 0);
if (!is_one_byte_) return false;
// Check right side if flat.
i::String* right = cons_string->second();
i::ConsString* right_as_cons =
i::String::VisitFlat(this, right, 0);
i::String right = cons_string->second();
i::ConsString right_as_cons = i::String::VisitFlat(this, right, 0);
if (!is_one_byte_) return false;
// Standard recurse/iterate trick.
if (left_as_cons != nullptr && right_as_cons != nullptr) {
if (!left_as_cons.is_null() && !right_as_cons.is_null()) {
if (left->length() < right->length()) {
CheckCons(left_as_cons);
cons_string = right_as_cons;
@ -5270,12 +5268,12 @@ class ContainsOnlyOneByteHelper {
continue;
}
// Descend left in place.
if (left_as_cons != nullptr) {
if (!left_as_cons.is_null()) {
cons_string = left_as_cons;
continue;
}
// Descend right in place.
if (right_as_cons != nullptr) {
if (!right_as_cons.is_null()) {
cons_string = right_as_cons;
continue;
}
@ -5499,16 +5497,16 @@ class Utf8WriterVisitor {
DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor);
};
static bool RecursivelySerializeToUtf8(i::String* current,
// TODO(yangguo): Simplify this. We can now expect the string to be flat.
static bool RecursivelySerializeToUtf8(i::String current,
Utf8WriterVisitor* writer,
int recursion_budget) {
while (!writer->IsDone()) {
i::ConsString* cons_string = i::String::VisitFlat(writer, current);
if (cons_string == nullptr) return true; // Leaf node.
i::ConsString cons_string = i::String::VisitFlat(writer, current);
if (cons_string.is_null()) return true; // Leaf node.
if (recursion_budget <= 0) return false;
// Must write the left branch first.
i::String* first = cons_string->first();
i::String first = cons_string->first();
bool success = RecursivelySerializeToUtf8(first,
writer,
recursion_budget - 1);
@ -5615,7 +5613,7 @@ bool v8::String::IsExternalOneByte() const {
void v8::String::VerifyExternalStringResource(
v8::String::ExternalStringResource* value) const {
i::DisallowHeapAllocation no_allocation;
i::String* str = *Utils::OpenHandle(this);
i::String str = *Utils::OpenHandle(this);
const v8::String::ExternalStringResource* expected;
if (str->IsThinString()) {
@ -5634,7 +5632,7 @@ void v8::String::VerifyExternalStringResource(
void v8::String::VerifyExternalStringResourceBase(
v8::String::ExternalStringResourceBase* value, Encoding encoding) const {
i::DisallowHeapAllocation no_allocation;
i::String* str = *Utils::OpenHandle(this);
i::String str = *Utils::OpenHandle(this);
const v8::String::ExternalStringResourceBase* expected;
Encoding expectedEncoding;
@ -5662,15 +5660,14 @@ void v8::String::VerifyExternalStringResourceBase(
String::ExternalStringResource* String::GetExternalStringResourceSlow() const {
i::DisallowHeapAllocation no_allocation;
typedef internal::Internals I;
i::String* str = *Utils::OpenHandle(this);
i::String str = *Utils::OpenHandle(this);
if (str->IsThinString()) {
str = i::ThinString::cast(str)->actual();
}
if (i::StringShape(str).IsExternalTwoByte()) {
void* value = I::ReadField<void*>(reinterpret_cast<i::Address>(str),
I::kStringResourceOffset);
void* value = I::ReadField<void*>(str.ptr(), I::kStringResourceOffset);
return reinterpret_cast<String::ExternalStringResource*>(value);
}
return nullptr;
@ -5681,13 +5678,13 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBaseSlow(
i::DisallowHeapAllocation no_allocation;
typedef internal::Internals I;
ExternalStringResourceBase* resource = nullptr;
i::String* str = *Utils::OpenHandle(this);
i::String str = *Utils::OpenHandle(this);
if (str->IsThinString()) {
str = i::ThinString::cast(str)->actual();
}
internal::Address string = reinterpret_cast<internal::Address>(str);
internal::Address string = str.ptr();
int type = I::GetInstanceType(string) & I::kFullStringRepresentationMask;
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
if (i::StringShape(str).IsExternalOneByte() ||
@ -5701,7 +5698,7 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBaseSlow(
const v8::String::ExternalOneByteStringResource*
v8::String::GetExternalOneByteStringResource() const {
i::DisallowHeapAllocation no_allocation;
i::String* str = *Utils::OpenHandle(this);
i::String str = *Utils::OpenHandle(this);
if (i::StringShape(str).IsExternalOneByte()) {
return i::ExternalOneByteString::cast(str)->resource();
} else if (str->IsThinString()) {
@ -6620,7 +6617,7 @@ Local<String> v8::String::NewExternal(
bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
i::DisallowHeapAllocation no_allocation;
i::String* obj = *Utils::OpenHandle(this);
i::String obj = *Utils::OpenHandle(this);
if (obj->IsThinString()) {
obj = i::ThinString::cast(obj)->actual();
@ -6649,7 +6646,7 @@ bool v8::String::MakeExternal(
v8::String::ExternalOneByteStringResource* resource) {
i::DisallowHeapAllocation no_allocation;
i::String* obj = *Utils::OpenHandle(this);
i::String obj = *Utils::OpenHandle(this);
if (obj->IsThinString()) {
obj = i::ThinString::cast(obj)->actual();
@ -6676,7 +6673,7 @@ bool v8::String::MakeExternal(
bool v8::String::CanMakeExternal() {
i::DisallowHeapAllocation no_allocation;
i::String* obj = *Utils::OpenHandle(this);
i::String obj = *Utils::OpenHandle(this);
if (obj->IsThinString()) {
obj = i::ThinString::cast(obj)->actual();
@ -9762,7 +9759,7 @@ void debug::GlobalLexicalScopeNames(
i::Handle<i::ScopeInfo> scope_info(context->scope_info(), isolate);
int local_count = scope_info->ContextLocalCount();
for (int j = 0; j < local_count; ++j) {
i::String* name = scope_info->ContextLocalName(j);
i::String name = scope_info->ContextLocalName(j);
if (i::ScopeInfo::VariableIsSynthetic(name)) continue;
names->Append(Utils::ToLocal(handle(name, isolate)));
}

View File

@ -430,7 +430,7 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
DCHECK_EQ(scope_info->ContextLocalCount(), 1);
DCHECK_EQ(scope_info->ContextLocalMode(0), VariableMode::kVar);
DCHECK_EQ(scope_info->ContextLocalInitFlag(0), kCreatedInitialized);
String* name = scope_info->ContextLocalName(0);
String name = scope_info->ContextLocalName(0);
MaybeAssignedFlag maybe_assigned =
scope_info->ContextLocalMaybeAssignedFlag(0);
outer_scope = new (zone)

View File

@ -68,7 +68,7 @@ void SourceCodeCache::Iterate(RootVisitor* v) {
bool SourceCodeCache::Lookup(Isolate* isolate, Vector<const char> name,
Handle<SharedFunctionInfo>* handle) {
for (int i = 0; i < cache_->length(); i += 2) {
SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i));
SeqOneByteString str = SeqOneByteString::cast(cache_->get(i));
if (str->IsUtf8EqualTo(name)) {
*handle = Handle<SharedFunctionInfo>(
SharedFunctionInfo::cast(cache_->get(i + 1)), isolate);

View File

@ -16,7 +16,7 @@ namespace v8 {
namespace internal {
// A SourceCodeCache uses a FixedArray to store pairs of
// (OneByteString*, JSFunction*), mapping names of native code files
// (OneByteString, JSFunction*), mapping names of native code files
// (array.js, etc.) to precompiled functions. Instead of mapping
// names to functions it might make sense to let the JS2C tool
// generate an index for each native JS file.

View File

@ -80,12 +80,12 @@ class ArrayBuiltinsAssembler : public CodeStubAssembler {
TNode<ExternalReference> isolate_ptr =
ExternalConstant(ExternalReference::isolate_address(isolate()));
return UncheckedCast<String>(
CallCFunction5(MachineType::AnyTagged(), // <return> String*
CallCFunction5(MachineType::AnyTagged(), // <return> String
MachineType::Pointer(), // Isolate*
MachineType::AnyTagged(), // FixedArray fixed_array
MachineType::IntPtr(), // intptr_t length
MachineType::AnyTagged(), // String* sep
MachineType::AnyTagged(), // String* dest
MachineType::AnyTagged(), // String sep
MachineType::AnyTagged(), // String dest
func, isolate_ptr, fixed_array, length, sep, dest));
}

View File

@ -103,22 +103,18 @@ TF_BUILTIN(StringToLowerCaseIntl, IntlBuiltinsAssembler) {
}
// Call into C for case conversion. The signature is:
// Object* ConvertOneByteToLower(String* src, String* dst, Isolate* isolate);
// String ConvertOneByteToLower(String src, String dst);
BIND(&call_c);
{
Node* const src = to_direct.string();
Node* const function_addr =
ExternalConstant(ExternalReference::intl_convert_one_byte_to_lower());
Node* const isolate_ptr =
ExternalConstant(ExternalReference::isolate_address(isolate()));
MachineType type_ptr = MachineType::Pointer();
MachineType type_tagged = MachineType::AnyTagged();
Node* const result =
CallCFunction3(type_tagged, type_tagged, type_tagged, type_ptr,
function_addr, src, dst, isolate_ptr);
Node* const result = CallCFunction2(type_tagged, type_tagged, type_tagged,
function_addr, src, dst);
Return(result);
}

View File

@ -350,7 +350,7 @@ inline bool ToUpperOverflows(uc32 character) {
template <class Converter>
V8_WARN_UNUSED_RESULT static Object* ConvertCaseHelper(
Isolate* isolate, String* string, SeqString* result, int result_length,
Isolate* isolate, String string, SeqString result, int result_length,
unibrow::Mapping<Converter, 128>* mapping) {
DisallowHeapAllocation no_gc;
// We try this twice, once with the assumption that the result is no longer

View File

@ -10,6 +10,8 @@
#include "src/base/platform/mutex.h"
#include "src/globals.h"
#include "src/objects/code.h"
#include "src/objects/name.h"
#include "src/objects/string.h"
#include "src/vector.h"
namespace v8 {
@ -72,18 +74,18 @@ class CodeEventListener {
virtual void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
const char* comment) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
Name* name) = 0;
Name name) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* source) = 0;
SharedFunctionInfo* shared, Name source) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* source,
SharedFunctionInfo* shared, Name source,
int line, int column) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name) = 0;
virtual void CallbackEvent(Name* name, Address entry_point) = 0;
virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0;
virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0;
virtual void RegExpCodeCreateEvent(AbstractCode code, String* source) = 0;
virtual void CallbackEvent(Name name, Address entry_point) = 0;
virtual void GetterCallbackEvent(Name name, Address entry_point) = 0;
virtual void SetterCallbackEvent(Name name, Address entry_point) = 0;
virtual void RegExpCodeCreateEvent(AbstractCode code, String source) = 0;
virtual void CodeMoveEvent(AbstractCode from, AbstractCode to) = 0;
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0;
virtual void CodeMovingGCEvent() = 0;
@ -126,15 +128,15 @@ class CodeEventDispatcher {
const char* comment) {
CODE_EVENT_DISPATCH(CodeCreateEvent(tag, code, comment));
}
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code, Name* name) {
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code, Name name) {
CODE_EVENT_DISPATCH(CodeCreateEvent(tag, code, name));
}
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* name) {
SharedFunctionInfo* shared, Name name) {
CODE_EVENT_DISPATCH(CodeCreateEvent(tag, code, shared, name));
}
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* source, int line,
SharedFunctionInfo* shared, Name source, int line,
int column) {
CODE_EVENT_DISPATCH(
CodeCreateEvent(tag, code, shared, source, line, column));
@ -143,16 +145,16 @@ class CodeEventDispatcher {
wasm::WasmName name) {
CODE_EVENT_DISPATCH(CodeCreateEvent(tag, code, name));
}
void CallbackEvent(Name* name, Address entry_point) {
void CallbackEvent(Name name, Address entry_point) {
CODE_EVENT_DISPATCH(CallbackEvent(name, entry_point));
}
void GetterCallbackEvent(Name* name, Address entry_point) {
void GetterCallbackEvent(Name name, Address entry_point) {
CODE_EVENT_DISPATCH(GetterCallbackEvent(name, entry_point));
}
void SetterCallbackEvent(Name* name, Address entry_point) {
void SetterCallbackEvent(Name name, Address entry_point) {
CODE_EVENT_DISPATCH(SetterCallbackEvent(name, entry_point));
}
void RegExpCodeCreateEvent(AbstractCode code, String* source) {
void RegExpCodeCreateEvent(AbstractCode code, String source) {
CODE_EVENT_DISPATCH(RegExpCodeCreateEvent(code, source));
}
void CodeMoveEvent(AbstractCode from, AbstractCode to) {

View File

@ -91,9 +91,9 @@ void LogFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
int column_num = Script::GetColumnNumber(script, shared->StartPosition()) + 1;
String* script_name = script->name()->IsString()
? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string();
String script_name = script->name()->IsString()
? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string();
CodeEventListener::LogEventsAndTags log_tag =
Logger::ToNativeByScript(tag, *script);
PROFILE(isolate, CodeCreateEvent(log_tag, *abstract_code, *shared,
@ -331,9 +331,9 @@ void InstallBytecodeArray(Handle<BytecodeArray> bytecode_array,
Script::GetLineNumber(script, shared_info->StartPosition()) + 1;
int column_num =
Script::GetColumnNumber(script, shared_info->StartPosition()) + 1;
String* script_name = script->name()->IsString()
? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string();
String script_name = script->name()->IsString()
? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string();
CodeEventListener::LogEventsAndTags log_tag = Logger::ToNativeByScript(
CodeEventListener::INTERPRETED_FUNCTION_TAG, *script);
PROFILE(isolate, CodeCreateEvent(log_tag, *abstract_code, *shared_info,

View File

@ -1930,9 +1930,10 @@ CodeAssemblerScopedExceptionHandler::~CodeAssemblerScopedExceptionHandler() {
} // namespace compiler
Address CheckObjectType(Object* value, Address raw_type, String* location) {
Address CheckObjectType(Object* value, Address raw_type, Address raw_location) {
#ifdef DEBUG
Smi type(raw_type);
String location = String::cast(ObjectPtr(raw_location));
const char* expected;
switch (static_cast<ObjectType>(type->value())) {
#define TYPE_CASE(Name) \

View File

@ -31,6 +31,7 @@ namespace internal {
// Forward declarations.
class AsmWasmData;
class AsyncGeneratorRequest;
class BigInt;
class CallInterfaceDescriptor;
class Callable;
class Factory;
@ -331,8 +332,10 @@ HEAP_OBJECT_TEMPLATE_TYPE_LIST(OBJECT_TYPE_TEMPLATE_CASE)
#undef OBJECT_TYPE_STRUCT_CASE
#undef OBJECT_TYPE_TEMPLATE_CASE
// {raw_type} must be a tagged Smi. The return value is also a tagged Smi.
Address CheckObjectType(Object* value, Address raw_type, String* location);
// {raw_type} must be a tagged Smi.
// {raw_location} must be a tagged String.
// Returns a tagged Smi.
Address CheckObjectType(Object* value, Address raw_type, Address raw_location);
namespace compiler {

View File

@ -88,7 +88,7 @@ void JsonPrintFunctionSource(std::ostream& os, int source_id,
end = shared->EndPosition();
os << ", \"sourceText\": \"";
int len = shared->EndPosition() - start;
String::SubStringRange source(String::cast(script->source()), start, len);
SubStringRange source(String::cast(script->source()), start, len);
for (const auto& c : source) {
os << AsEscapedUC16ForJSON(c);
}
@ -191,7 +191,7 @@ std::unique_ptr<char[]> GetVisualizerLogFileName(OptimizedCompilationInfo* info,
info->shared_info()->script()->IsScript()) {
Object* source_name = Script::cast(info->shared_info()->script())->name();
if (source_name->IsString()) {
String* str = String::cast(source_name);
String str = String::cast(source_name);
if (str->length() > 0) {
SNPrintF(source_file, "%s", str->ToCString().get());
std::replace(source_file.start(),

View File

@ -1757,7 +1757,8 @@ Reduction JSNativeContextSpecialization::ReduceKeyedAccess(
}
// Check if we have feedback for a named access.
if (Name* name = nexus.FindFirstName()) {
Name name = nexus.FindFirstName();
if (!name.is_null()) {
return ReduceNamedAccess(node, value, receiver_maps,
handle(name, isolate()), access_mode, index);
} else if (nexus.GetKeyType() != ELEMENT) {

View File

@ -565,8 +565,7 @@ void PrintFunctionSource(OptimizedCompilationInfo* info, Isolate* isolate,
DisallowHeapAllocation no_allocation;
int start = shared->StartPosition();
int len = shared->EndPosition() - start;
String::SubStringRange source(String::cast(script->source()), start,
len);
SubStringRange source(String::cast(script->source()), start, len);
for (const auto& c : source) {
os << AsReversiblyEscapedUC16(c);
}

View File

@ -1321,7 +1321,7 @@ double StringToDouble(Isolate* isolate, Handle<String> string, int flags,
}
}
bool IsSpecialIndex(String* string) {
bool IsSpecialIndex(String string) {
// Max length of canonical double: -X.XXXXXXXXXXXXXXXXX-eXXX
const int kBufferSize = 24;
const int length = string->length();

View File

@ -171,7 +171,7 @@ inline bool TryNumberToSize(Object* number, size_t* result);
inline size_t NumberToSize(Object* number);
// returns DoubleToString(StringToDouble(string)) == string
bool IsSpecialIndex(String* string);
bool IsSpecialIndex(String string);
} // namespace internal
} // namespace v8

View File

@ -574,7 +574,7 @@ void ScopeIterator::VisitModuleScope(const Visitor& visitor) const {
int index;
Handle<String> name;
{
String* raw_name;
String raw_name;
scope_info->ModuleVariable(i, &raw_name, &index);
CHECK(!ScopeInfo::VariableIsSynthetic(raw_name));
name = handle(raw_name, isolate_);

View File

@ -4267,7 +4267,7 @@ class StringWrapperElementsAccessor
}
private:
static String* GetString(JSObject* holder) {
static String GetString(JSObject* holder) {
DCHECK(holder->IsJSValue());
JSValue* js_value = JSValue::cast(holder);
DCHECK(js_value->value()->IsString());

View File

@ -668,7 +668,13 @@ FUNCTION_REFERENCE(smi_lexicographic_compare_function,
FUNCTION_REFERENCE(check_object_type, CheckObjectType)
#ifdef V8_INTL_SUPPORT
FUNCTION_REFERENCE(intl_convert_one_byte_to_lower, Intl::ConvertOneByteToLower)
static Address ConvertOneByteToLower(Address raw_src, Address raw_dst) {
String src = String::cast(ObjectPtr(raw_src));
String dst = String::cast(ObjectPtr(raw_dst));
return Intl::ConvertOneByteToLower(src, dst).ptr();
}
FUNCTION_REFERENCE(intl_convert_one_byte_to_lower, ConvertOneByteToLower)
ExternalReference ExternalReference::intl_to_latin1_lower_table() {
uint8_t* ptr = const_cast<uint8_t*>(Intl::ToLatin1LowerTable());

View File

@ -370,7 +370,7 @@ Handle<Symbol> FeedbackVector::PremonomorphicSentinel(Isolate* isolate) {
return isolate->factory()->premonomorphic_symbol();
}
Symbol* FeedbackVector::RawUninitializedSentinel(Isolate* isolate) {
Symbol FeedbackVector::RawUninitializedSentinel(Isolate* isolate) {
return ReadOnlyRoots(isolate).uninitialized_symbol();
}

View File

@ -46,7 +46,7 @@ static bool IsPropertyNameFeedback(MaybeObject feedback) {
if (!feedback->GetHeapObjectIfStrong(&heap_object)) return false;
if (heap_object->IsString()) return true;
if (!heap_object->IsSymbol()) return false;
Symbol* symbol = Symbol::cast(heap_object);
Symbol symbol = Symbol::cast(heap_object);
ReadOnlyRoots roots = symbol->GetReadOnlyRoots();
return symbol != roots.uninitialized_symbol() &&
symbol != roots.premonomorphic_symbol() &&
@ -1048,14 +1048,14 @@ bool FeedbackNexus::FindHandlers(MaybeObjectHandles* code_list,
return count == length;
}
Name* FeedbackNexus::FindFirstName() const {
Name FeedbackNexus::FindFirstName() const {
if (IsKeyedStoreICKind(kind()) || IsKeyedLoadICKind(kind())) {
MaybeObject feedback = GetFeedback();
if (IsPropertyNameFeedback(feedback)) {
return Name::cast(feedback->GetHeapObjectAssumeStrong());
}
}
return nullptr;
return Name();
}
KeyedAccessLoadMode FeedbackNexus::GetKeyedAccessLoadMode() const {

View File

@ -272,7 +272,7 @@ class FeedbackVector : public HeapObject, public NeverReadOnlySpaceObject {
// A raw version of the uninitialized sentinel that's safe to read during
// garbage collection (e.g., for patching the cache).
static inline Symbol* RawUninitializedSentinel(Isolate* isolate);
static inline Symbol RawUninitializedSentinel(Isolate* isolate);
// Layout description.
#define FEEDBACK_VECTOR_FIELDS(V) \
@ -643,7 +643,7 @@ class FeedbackNexus final {
// For KeyedLoad and KeyedStore ICs.
IcCheckType GetKeyType() const;
Name* FindFirstName() const;
Name FindFirstName() const;
// For Call ICs.
int GetCallCount();

View File

@ -1118,7 +1118,7 @@ void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function,
int line = script->GetLineNumber(source_pos) + 1;
Object* script_name_raw = script->name();
if (script_name_raw->IsString()) {
String* script_name = String::cast(script->name());
String script_name = String::cast(script->name());
std::unique_ptr<char[]> c_script_name =
script_name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
PrintF(file, " at %s:%d", c_script_name.get(), line);

View File

@ -152,14 +152,16 @@ class Handle final : public HandleBase {
std::is_same<S, FixedArray>::value ||
std::is_same<S, FixedArrayBase>::value ||
std::is_same<S, FixedDoubleArray>::value ||
std::is_same<S, Map>::value ||
std::is_same<S, Map>::value || std::is_same<S, Name>::value ||
std::is_same<S, NumberDictionary>::value ||
std::is_same<S, ObjectBoilerplateDescription>::value ||
std::is_same<S, OrderedHashMap>::value ||
std::is_same<S, OrderedHashSet>::value ||
std::is_same<S, OrderedNameDictionary>::value ||
std::is_same<S, ScriptContextTable>::value ||
std::is_same<S, ScopeInfo>::value))>::type>
std::is_same<S, ScopeInfo>::value ||
std::is_same<S, String>::value ||
std::is_same<S, Symbol>::value))>::type>
V8_INLINE Handle(Handle<S> handle) : HandleBase(handle) {}
// The NeverReadOnlySpaceObject special-case is needed for the

View File

@ -18,7 +18,7 @@ void CodeStatistics::RecordCodeAndMetadataStatistics(HeapObject* object,
// Log the size of external source code.
Object* source = script->source();
if (source->IsExternalString()) {
ExternalString* external_source_string = ExternalString::cast(source);
ExternalString external_source_string = ExternalString::cast(source);
int size = isolate->external_script_source_size();
size += external_source_string->ExternalPayloadSize();
isolate->set_external_script_source_size(size);

View File

@ -244,17 +244,17 @@ class ConcurrentMarkingVisitor final
// Strings with pointers =====================================================
// ===========================================================================
int VisitConsString(Map map, ConsString* object) {
int VisitConsString(Map map, ConsString object) {
int size = ConsString::BodyDescriptor::SizeOf(map, object);
return VisitWithSnapshot(map, object, size, size);
}
int VisitSlicedString(Map map, SlicedString* object) {
int VisitSlicedString(Map map, SlicedString object) {
int size = SlicedString::BodyDescriptor::SizeOf(map, object);
return VisitWithSnapshot(map, object, size, size);
}
int VisitThinString(Map map, ThinString* object) {
int VisitThinString(Map map, ThinString object) {
int size = ThinString::BodyDescriptor::SizeOf(map, object);
return VisitWithSnapshot(map, object, size, size);
}
@ -263,14 +263,14 @@ class ConcurrentMarkingVisitor final
// Strings without pointers ==================================================
// ===========================================================================
int VisitSeqOneByteString(Map map, SeqOneByteString* object) {
int VisitSeqOneByteString(Map map, SeqOneByteString object) {
int size = SeqOneByteString::SizeFor(object->synchronized_length());
if (!ShouldVisit(object)) return 0;
VisitMapPointer(object, object->map_slot());
return size;
}
int VisitSeqTwoByteString(Map map, SeqTwoByteString* object) {
int VisitSeqTwoByteString(Map map, SeqTwoByteString object) {
int size = SeqTwoByteString::SizeFor(object->synchronized_length());
if (!ShouldVisit(object)) return 0;
VisitMapPointer(object, object->map_slot());
@ -476,7 +476,7 @@ class ConcurrentMarkingVisitor final
}
template <typename T>
int VisitWithSnapshot(Map map, T* object, int used_size, int size) {
int VisitWithSnapshot(Map map, T object, int used_size, int size) {
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, used_size);
if (!ShouldVisit(object)) return 0;
VisitPointersInSnapshot(object, snapshot);
@ -484,10 +484,12 @@ class ConcurrentMarkingVisitor final
}
template <typename T>
const SlotSnapshot& MakeSlotSnapshot(Map map, T* object, int size) {
const SlotSnapshot& MakeSlotSnapshot(Map map, T object, int size) {
SlotSnapshottingVisitor visitor(&slot_snapshot_);
visitor.VisitPointer(object, ObjectSlot(object->map_slot().address()));
T::BodyDescriptor::IterateBody(map, object, size, &visitor);
// TODO(3770): Drop std::remove_pointer after the migration.
std::remove_pointer<T>::type::BodyDescriptor::IterateBody(map, object, size,
&visitor);
return slot_snapshot_;
}
@ -502,30 +504,30 @@ class ConcurrentMarkingVisitor final
};
// Strings can change maps due to conversion to thin string or external strings.
// Use reinterpret cast to avoid data race in slow dchecks.
// Use unchecked cast to avoid data race in slow dchecks.
template <>
ConsString* ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return reinterpret_cast<ConsString*>(object);
ConsString ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return ConsString::unchecked_cast(object);
}
template <>
SlicedString* ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return reinterpret_cast<SlicedString*>(object);
SlicedString ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return SlicedString::unchecked_cast(object);
}
template <>
ThinString* ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return reinterpret_cast<ThinString*>(object);
ThinString ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return ThinString::unchecked_cast(object);
}
template <>
SeqOneByteString* ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return reinterpret_cast<SeqOneByteString*>(object);
SeqOneByteString ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return SeqOneByteString::unchecked_cast(object);
}
template <>
SeqTwoByteString* ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return reinterpret_cast<SeqTwoByteString*>(object);
SeqTwoByteString ConcurrentMarkingVisitor::Cast(HeapObject* object) {
return SeqTwoByteString::unchecked_cast(object);
}
// Fixed array can become a free space during left trimming.

View File

@ -330,14 +330,13 @@ void Heap::UpdateAllocationsHash(uint32_t value) {
StringHasher::AddCharacterCore(raw_allocations_hash_, c2);
}
void Heap::RegisterExternalString(String* string) {
void Heap::RegisterExternalString(String string) {
DCHECK(string->IsExternalString());
DCHECK(!string->IsThinString());
external_string_table_.AddString(string);
}
void Heap::UpdateExternalString(String* string, size_t old_payload,
void Heap::UpdateExternalString(String string, size_t old_payload,
size_t new_payload) {
DCHECK(string->IsExternalString());
Page* page = Page::FromHeapObject(string);
@ -350,10 +349,10 @@ void Heap::UpdateExternalString(String* string, size_t old_payload,
ExternalBackingStoreType::kExternalString, new_payload - old_payload);
}
void Heap::FinalizeExternalString(String* string) {
void Heap::FinalizeExternalString(String string) {
DCHECK(string->IsExternalString());
Page* page = Page::FromHeapObject(string);
ExternalString* ext_string = ExternalString::cast(string);
ExternalString ext_string = ExternalString::cast(string);
page->DecrementExternalBackingStoreBytes(
ExternalBackingStoreType::kExternalString,
@ -582,7 +581,7 @@ void Heap::UpdateAllocationSite(Map map, HeapObject* object,
(*pretenuring_feedback)[reinterpret_cast<AllocationSite*>(key)]++;
}
void Heap::ExternalStringTable::AddString(String* string) {
void Heap::ExternalStringTable::AddString(String string) {
DCHECK(string->IsExternalString());
DCHECK(!Contains(string));

View File

@ -2039,37 +2039,37 @@ void Heap::ProtectUnprotectedMemoryChunks() {
unprotected_memory_chunks_.clear();
}
bool Heap::ExternalStringTable::Contains(HeapObject* obj) {
bool Heap::ExternalStringTable::Contains(String string) {
for (size_t i = 0; i < new_space_strings_.size(); ++i) {
if (new_space_strings_[i] == obj) return true;
if (new_space_strings_[i] == string) return true;
}
for (size_t i = 0; i < old_space_strings_.size(); ++i) {
if (old_space_strings_[i] == obj) return true;
if (old_space_strings_[i] == string) return true;
}
return false;
}
String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
ObjectSlot p) {
String Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
ObjectSlot p) {
MapWord first_word = HeapObject::cast(*p)->map_word();
if (!first_word.IsForwardingAddress()) {
// Unreachable external string can be finalized.
String* string = String::cast(*p);
String string = String::cast(*p);
if (!string->IsExternalString()) {
// Original external string has been internalized.
DCHECK(string->IsThinString());
return nullptr;
return String();
}
heap->FinalizeExternalString(string);
return nullptr;
return String();
}
// String is still reachable.
String* new_string = String::cast(first_word.ToForwardingAddress());
String new_string = String::cast(first_word.ToForwardingAddress());
if (new_string->IsThinString()) {
// Filtering Thin strings out of the external string table.
return nullptr;
return String();
} else if (new_string->IsExternalString()) {
MemoryChunk::MoveExternalBackingStoreBytes(
ExternalBackingStoreType::kExternalString,
@ -2080,16 +2080,16 @@ String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
}
// Internalization can replace external strings with non-external strings.
return new_string->IsExternalString() ? new_string : nullptr;
return new_string->IsExternalString() ? new_string : String();
}
void Heap::ExternalStringTable::VerifyNewSpace() {
#ifdef DEBUG
std::set<String*> visited_map;
std::set<String> visited_map;
std::map<MemoryChunk*, size_t> size_map;
ExternalBackingStoreType type = ExternalBackingStoreType::kExternalString;
for (size_t i = 0; i < new_space_strings_.size(); ++i) {
String* obj = String::cast(new_space_strings_[i]);
String obj = String::cast(new_space_strings_[i]);
MemoryChunk* mc = MemoryChunk::FromHeapObject(obj);
DCHECK(mc->InNewSpace());
DCHECK(heap_->InNewSpace(obj));
@ -2108,12 +2108,12 @@ void Heap::ExternalStringTable::VerifyNewSpace() {
void Heap::ExternalStringTable::Verify() {
#ifdef DEBUG
std::set<String*> visited_map;
std::set<String> visited_map;
std::map<MemoryChunk*, size_t> size_map;
ExternalBackingStoreType type = ExternalBackingStoreType::kExternalString;
VerifyNewSpace();
for (size_t i = 0; i < old_space_strings_.size(); ++i) {
String* obj = String::cast(old_space_strings_[i]);
String obj = String::cast(old_space_strings_[i]);
MemoryChunk* mc = MemoryChunk::FromHeapObject(obj);
DCHECK(!mc->InNewSpace());
DCHECK(!heap_->InNewSpace(obj));
@ -2139,9 +2139,9 @@ void Heap::ExternalStringTable::UpdateNewSpaceReferences(
ObjectSlot last = start;
for (ObjectSlot p = start; p < end; ++p) {
String* target = updater_func(heap_, p);
String target = updater_func(heap_, p);
if (target == nullptr) continue;
if (target.is_null()) continue;
DCHECK(target->IsExternalString());

View File

@ -902,18 +902,18 @@ class Heap {
// ===========================================================================
// Registers an external string.
inline void RegisterExternalString(String* string);
inline void RegisterExternalString(String string);
// Called when a string's resource is changed. The size of the payload is sent
// as argument of the method.
inline void UpdateExternalString(String* string, size_t old_payload,
inline void UpdateExternalString(String string, size_t old_payload,
size_t new_payload);
// Finalizes an external string by deleting the associated external
// data and clearing the resource pointer.
inline void FinalizeExternalString(String* string);
inline void FinalizeExternalString(String string);
static String* UpdateNewSpaceReferenceInExternalStringTableEntry(
static String UpdateNewSpaceReferenceInExternalStringTableEntry(
Heap* heap, ObjectSlot pointer);
// ===========================================================================
@ -1297,8 +1297,8 @@ class Heap {
private:
class SkipStoreBufferScope;
typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap,
ObjectSlot pointer);
typedef String (*ExternalStringTableUpdaterCallback)(Heap* heap,
ObjectSlot pointer);
// External strings table is a place where all external strings are
// registered. We need to keep track of such strings to properly
@ -1308,8 +1308,8 @@ class Heap {
explicit ExternalStringTable(Heap* heap) : heap_(heap) {}
// Registers an external string.
inline void AddString(String* string);
bool Contains(HeapObject* obj);
inline void AddString(String string);
bool Contains(String string);
void IterateAll(RootVisitor* v);
void IterateNewSpaceStrings(RootVisitor* v);

View File

@ -1981,7 +1981,7 @@ bool MarkCompactCollector::CompactTransitionArray(
}
} else {
if (i != transition_index) {
Name* key = transitions->GetKey(i);
Name key = transitions->GetKey(i);
transitions->SetKey(transition_index, key);
HeapObjectSlot key_slot = transitions->GetKeySlot(transition_index);
RecordSlot(transitions, key_slot, key);
@ -2329,12 +2329,12 @@ class PointersUpdatingVisitor : public ObjectVisitor, public RootVisitor {
Heap* heap_;
};
static String* UpdateReferenceInExternalStringTableEntry(Heap* heap,
ObjectSlot p) {
static String UpdateReferenceInExternalStringTableEntry(Heap* heap,
ObjectSlot p) {
MapWord map_word = HeapObject::cast(*p)->map_word();
if (map_word.IsForwardingAddress()) {
String* new_string = String::cast(map_word.ToForwardingAddress());
String new_string = String::cast(map_word.ToForwardingAddress());
if (new_string->IsExternalString()) {
MemoryChunk::MoveExternalBackingStoreBytes(

View File

@ -386,7 +386,7 @@ class ObjectStatsCollectorImpl {
void RecordVirtualJSObjectDetails(JSObject* object);
void RecordVirtualMapDetails(Map map);
void RecordVirtualScriptDetails(Script* script);
void RecordVirtualExternalStringDetails(ExternalString* script);
void RecordVirtualExternalStringDetails(ExternalString script);
void RecordVirtualSharedFunctionInfoDetails(SharedFunctionInfo* info);
void RecordVirtualJSFunctionDetails(JSFunction* function);
@ -803,7 +803,7 @@ void ObjectStatsCollectorImpl::RecordVirtualScriptDetails(Script* script) {
// The contents of external strings aren't on the heap, so we have to record
// them manually. The on-heap String object is recorded indepentendely in
// the normal pass.
ExternalString* string = ExternalString::cast(raw_source);
ExternalString string = ExternalString::cast(raw_source);
Address resource = string->resource_as_address();
size_t off_heap_size = string->ExternalPayloadSize();
RecordExternalResourceStats(
@ -813,7 +813,7 @@ void ObjectStatsCollectorImpl::RecordVirtualScriptDetails(Script* script) {
: ObjectStats::SCRIPT_SOURCE_EXTERNAL_TWO_BYTE_TYPE,
off_heap_size);
} else if (raw_source->IsString()) {
String* source = String::cast(raw_source);
String source = String::cast(raw_source);
RecordSimpleVirtualObjectStats(
script, source,
source->IsOneByteRepresentation()
@ -823,7 +823,7 @@ void ObjectStatsCollectorImpl::RecordVirtualScriptDetails(Script* script) {
}
void ObjectStatsCollectorImpl::RecordVirtualExternalStringDetails(
ExternalString* string) {
ExternalString string) {
// Track the external string resource size in a separate category.
Address resource = string->resource_as_address();

View File

@ -102,7 +102,7 @@ TYPED_VISITOR_ID_LIST(VISIT)
template <typename ResultType, typename ConcreteVisitor>
ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitShortcutCandidate(
Map map, ConsString* object) {
Map map, ConsString object) {
return static_cast<ConcreteVisitor*>(this)->VisitConsString(map, object);
}

View File

@ -40,7 +40,7 @@ class WasmInstanceObject;
V(Cell, Cell*) \
V(Code, Code) \
V(CodeDataContainer, CodeDataContainer*) \
V(ConsString, ConsString*) \
V(ConsString, ConsString) \
V(Context, Context) \
V(DataHandler, DataHandler*) \
V(DescriptorArray, DescriptorArray*) \
@ -64,15 +64,15 @@ class WasmInstanceObject;
V(PropertyArray, PropertyArray) \
V(PropertyCell, PropertyCell*) \
V(PrototypeInfo, PrototypeInfo*) \
V(SeqOneByteString, SeqOneByteString*) \
V(SeqTwoByteString, SeqTwoByteString*) \
V(SeqOneByteString, SeqOneByteString) \
V(SeqTwoByteString, SeqTwoByteString) \
V(SharedFunctionInfo, SharedFunctionInfo*) \
V(SlicedString, SlicedString*) \
V(SlicedString, SlicedString) \
V(SmallOrderedHashMap, SmallOrderedHashMap*) \
V(SmallOrderedHashSet, SmallOrderedHashSet*) \
V(SmallOrderedNameDictionary, SmallOrderedNameDictionary*) \
V(Symbol, Symbol*) \
V(ThinString, ThinString*) \
V(Symbol, Symbol) \
V(ThinString, ThinString) \
V(TransitionArray, TransitionArray*) \
V(UncompiledDataWithoutPreParsedScope, UncompiledDataWithoutPreParsedScope*) \
V(UncompiledDataWithPreParsedScope, UncompiledDataWithPreParsedScope*) \
@ -112,7 +112,7 @@ class HeapVisitor : public ObjectVisitor {
V8_INLINE ResultType Visit##TypeName(Map map, Type object);
TYPED_VISITOR_ID_LIST(VISIT)
#undef VISIT
V8_INLINE ResultType VisitShortcutCandidate(Map map, ConsString* object);
V8_INLINE ResultType VisitShortcutCandidate(Map map, ConsString object);
V8_INLINE ResultType VisitDataObject(Map map, HeapObject* object);
V8_INLINE ResultType VisitJSObjectFast(Map map, JSObject* object);
V8_INLINE ResultType VisitJSApiObject(Map map, JSObject* object);

View File

@ -277,13 +277,13 @@ SlotCallbackResult Scavenger::EvacuateObjectDefault(Map map,
}
SlotCallbackResult Scavenger::EvacuateThinString(Map map, HeapObjectSlot slot,
ThinString* object,
ThinString object,
int object_size) {
if (!is_incremental_marking_) {
// The ThinString should die after Scavenge, so avoid writing the proper
// forwarding pointer and instead just signal the actual object as forwarded
// reference.
String* actual = object->actual();
String actual = object->actual();
// ThinStrings always refer to internalized strings, which are always in old
// space.
DCHECK(!Heap::InNewSpace(actual));
@ -296,7 +296,7 @@ SlotCallbackResult Scavenger::EvacuateThinString(Map map, HeapObjectSlot slot,
SlotCallbackResult Scavenger::EvacuateShortcutCandidate(Map map,
HeapObjectSlot slot,
ConsString* object,
ConsString object,
int object_size) {
DCHECK(IsShortcutCandidate(map->instance_type()));
if (!is_incremental_marking_ &&
@ -342,13 +342,13 @@ SlotCallbackResult Scavenger::EvacuateObject(HeapObjectSlot slot, Map map,
case kVisitThinString:
// At the moment we don't allow weak pointers to thin strings.
DCHECK(!(*slot)->IsWeak());
return EvacuateThinString(map, slot,
reinterpret_cast<ThinString*>(source), size);
return EvacuateThinString(map, slot, ThinString::unchecked_cast(source),
size);
case kVisitShortcutCandidate:
DCHECK(!(*slot)->IsWeak());
// At the moment we don't allow weak pointers to cons strings.
return EvacuateShortcutCandidate(
map, slot, reinterpret_cast<ConsString*>(source), size);
map, slot, ConsString::unchecked_cast(source), size);
default:
return EvacuateObjectDefault(map, slot, source, size);
}

View File

@ -178,12 +178,12 @@ class Scavenger {
int object_size);
inline SlotCallbackResult EvacuateThinString(Map map, HeapObjectSlot slot,
ThinString* object,
ThinString object,
int object_size);
inline SlotCallbackResult EvacuateShortcutCandidate(Map map,
HeapObjectSlot slot,
ConsString* object,
ConsString object,
int object_size);
void IterateAndScavengePromotedObject(HeapObject* target, Map map, int size);

View File

@ -1969,7 +1969,7 @@ void PagedSpace::Verify(Isolate* isolate, ObjectVisitor* visitor) {
end_of_previous_object = object->address() + size;
if (object->IsExternalString()) {
ExternalString* external_string = ExternalString::cast(object);
ExternalString external_string = ExternalString::cast(object);
size_t size = external_string->ExternalPayloadSize();
external_page_bytes[ExternalBackingStoreType::kExternalString] += size;
} else if (object->IsJSArrayBuffer()) {
@ -2462,7 +2462,7 @@ void NewSpace::Verify(Isolate* isolate) {
object->IterateBody(map, size, &visitor);
if (object->IsExternalString()) {
ExternalString* external_string = ExternalString::cast(object);
ExternalString external_string = ExternalString::cast(object);
size_t size = external_string->ExternalPayloadSize();
external_space_bytes[ExternalBackingStoreType::kExternalString] += size;
} else if (object->IsJSArrayBuffer()) {

View File

@ -60,7 +60,7 @@ const char* ICStats::GetOrCacheScriptName(Script* script) {
}
Object* script_name_raw = script->name();
if (script_name_raw->IsString()) {
String* script_name = String::cast(script_name_raw);
String script_name = String::cast(script_name_raw);
char* c_script_name =
script_name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL)
.release();

View File

@ -273,7 +273,7 @@ bool IC::RecomputeHandlerForName(Handle<Object> name) {
if (is_keyed()) {
// Determine whether the failure is due to a name failure.
if (!name->IsName()) return false;
Name* stub_name = nexus()->FindFirstName();
Name stub_name = nexus()->FindFirstName();
if (*name != stub_name) return false;
}
@ -2469,7 +2469,7 @@ static bool CanFastCloneObject(Handle<Map> map) {
DescriptorArray* descriptors = map->instance_descriptors();
for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
PropertyDetails details = descriptors->GetDetails(i);
Name* key = descriptors->GetKey(i);
Name key = descriptors->GetKey(i);
if (details.kind() != kData || !details.IsEnumerable() ||
key->IsPrivateName()) {
return false;

View File

@ -28,7 +28,7 @@ void StubCache::Initialize() {
// Hash algorithm for the primary table. This algorithm is replicated in
// assembler for every architecture. Returns an index into the table that
// is scaled by 1 << kCacheIndexShift.
int StubCache::PrimaryOffset(Name* name, Map map) {
int StubCache::PrimaryOffset(Name name, Map map) {
STATIC_ASSERT(kCacheIndexShift == Name::kHashShift);
// Compute the hash of the name (use entire hash field).
DCHECK(name->HasHashCode());
@ -45,26 +45,25 @@ int StubCache::PrimaryOffset(Name* name, Map map) {
// Hash algorithm for the secondary table. This algorithm is replicated in
// assembler for every architecture. Returns an index into the table that
// is scaled by 1 << kCacheIndexShift.
int StubCache::SecondaryOffset(Name* name, int seed) {
int StubCache::SecondaryOffset(Name name, int seed) {
// Use the seed from the primary cache in the secondary cache.
uint32_t name_low32bits =
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name));
uint32_t name_low32bits = static_cast<uint32_t>(name.ptr());
uint32_t key = (seed - name_low32bits) + kSecondaryMagic;
return key & ((kSecondaryTableSize - 1) << kCacheIndexShift);
}
int StubCache::PrimaryOffsetForTesting(Name* name, Map map) {
int StubCache::PrimaryOffsetForTesting(Name name, Map map) {
return PrimaryOffset(name, map);
}
int StubCache::SecondaryOffsetForTesting(Name* name, int seed) {
int StubCache::SecondaryOffsetForTesting(Name name, int seed) {
return SecondaryOffset(name, seed);
}
#ifdef DEBUG
namespace {
bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map map,
bool CommonStubCacheChecks(StubCache* stub_cache, Name name, Map map,
MaybeObject handler) {
// Validate that the name and handler do not move on scavenge, and that we
// can use identity checks instead of structural equality checks.
@ -79,7 +78,7 @@ bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map map,
} // namespace
#endif
void StubCache::Set(Name* name, Map map, MaybeObject handler) {
void StubCache::Set(Name name, Map map, MaybeObject handler) {
DCHECK(CommonStubCacheChecks(this, name, map, handler));
// Compute the primary entry.
@ -93,46 +92,46 @@ void StubCache::Set(Name* name, Map map, MaybeObject handler) {
isolate_->builtins()->builtin(Builtins::kIllegal)) &&
primary->map != kNullAddress) {
Map old_map = Map::cast(ObjectPtr(primary->map));
int seed = PrimaryOffset(primary->key, old_map);
int secondary_offset = SecondaryOffset(primary->key, seed);
int seed = PrimaryOffset(Name::cast(ObjectPtr(primary->key)), old_map);
int secondary_offset =
SecondaryOffset(Name::cast(ObjectPtr(primary->key)), seed);
Entry* secondary = entry(secondary_, secondary_offset);
*secondary = *primary;
}
// Update primary cache.
primary->key = name;
primary->key = name.ptr();
primary->value = handler.ptr();
primary->map = map.ptr();
isolate()->counters()->megamorphic_stub_cache_updates()->Increment();
}
MaybeObject StubCache::Get(Name* name, Map map) {
MaybeObject StubCache::Get(Name name, Map map) {
DCHECK(CommonStubCacheChecks(this, name, map, MaybeObject()));
int primary_offset = PrimaryOffset(name, map);
Entry* primary = entry(primary_, primary_offset);
if (primary->key == name && primary->map == map.ptr()) {
if (primary->key == name.ptr() && primary->map == map.ptr()) {
return MaybeObject(primary->value);
}
int secondary_offset = SecondaryOffset(name, primary_offset);
Entry* secondary = entry(secondary_, secondary_offset);
if (secondary->key == name && secondary->map == map.ptr()) {
if (secondary->key == name.ptr() && secondary->map == map.ptr()) {
return MaybeObject(secondary->value);
}
return MaybeObject();
}
void StubCache::Clear() {
MaybeObject empty = MaybeObject::FromObject(
isolate_->builtins()->builtin(Builtins::kIllegal));
Name* empty_string = ReadOnlyRoots(isolate()).empty_string();
Name empty_string = ReadOnlyRoots(isolate()).empty_string();
for (int i = 0; i < kPrimaryTableSize; i++) {
primary_[i].key = empty_string;
primary_[i].key = empty_string.ptr();
primary_[i].map = kNullAddress;
primary_[i].value = empty.ptr();
}
for (int j = 0; j < kSecondaryTableSize; j++) {
secondary_[j].key = empty_string;
secondary_[j].key = empty_string.ptr();
secondary_[j].map = kNullAddress;
secondary_[j].value = empty.ptr();
}

View File

@ -35,8 +35,7 @@ class StubCache {
// The values here have plain Address types because they are read
// directly from generated code. As a nice side effect, this keeps
// #includes lightweight.
// TODO(3770): That statement will be true for {key} as well.
Name* key;
Address key;
// {value} is a tagged heap object reference (weak or strong), equivalent
// to a MaybeObject's payload.
Address value;
@ -46,8 +45,8 @@ class StubCache {
void Initialize();
// Access cache for entry hash(name, map).
void Set(Name* name, Map map, MaybeObject handler);
MaybeObject Get(Name* name, Map map);
void Set(Name name, Map map, MaybeObject handler);
MaybeObject Get(Name name, Map map);
// Clear the lookup table (@ mark compact collection).
void Clear();
@ -93,8 +92,8 @@ class StubCache {
// Some magic number used in the secondary hash computation.
static const int kSecondaryMagic = 0xb16ca6e5;
static int PrimaryOffsetForTesting(Name* name, Map map);
static int SecondaryOffsetForTesting(Name* name, int seed);
static int PrimaryOffsetForTesting(Name name, Map map);
static int SecondaryOffsetForTesting(Name name, int seed);
// The constructor is made public only for the purposes of testing.
explicit StubCache(Isolate* isolate);
@ -110,12 +109,12 @@ class StubCache {
// Hash algorithm for the primary table. This algorithm is replicated in
// assembler for every architecture. Returns an index into the table that
// is scaled by 1 << kCacheIndexShift.
static int PrimaryOffset(Name* name, Map map);
static int PrimaryOffset(Name name, Map map);
// Hash algorithm for the secondary table. This algorithm is replicated in
// assembler for every architecture. Returns an index into the table that
// is scaled by 1 << kCacheIndexShift.
static int SecondaryOffset(Name* name, int seed);
static int SecondaryOffset(Name name, int seed);
// Compute the entry for a given offset in exactly the same way as
// we do in generated code. We generate an hash code that already

View File

@ -46,8 +46,7 @@ void IdentityMapBase::DisableIteration() {
int IdentityMapBase::ScanKeysFor(Address address) const {
int start = Hash(address) & mask_;
Address not_mapped =
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol());
Address not_mapped = ReadOnlyRoots(heap_).not_mapped_symbol().ptr();
for (int index = start; index < capacity_; index++) {
if (keys_[index] == address) return index; // Found.
if (keys_[index] == not_mapped) return -1; // Not found.
@ -60,8 +59,7 @@ int IdentityMapBase::ScanKeysFor(Address address) const {
}
int IdentityMapBase::InsertKey(Address address) {
Address not_mapped =
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol());
Address not_mapped = ReadOnlyRoots(heap_).not_mapped_symbol().ptr();
while (true) {
int start = Hash(address) & mask_;
int limit = capacity_ / 2;
@ -83,8 +81,7 @@ int IdentityMapBase::InsertKey(Address address) {
bool IdentityMapBase::DeleteIndex(int index, void** deleted_value) {
if (deleted_value != nullptr) *deleted_value = values_[index];
Address not_mapped =
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol());
Address not_mapped = ReadOnlyRoots(heap_).not_mapped_symbol().ptr();
DCHECK_NE(keys_[index], not_mapped);
keys_[index] = not_mapped;
values_[index] = nullptr;
@ -145,8 +142,7 @@ int IdentityMapBase::LookupOrInsert(Address key) {
}
int IdentityMapBase::Hash(Address address) const {
CHECK_NE(address,
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol()));
CHECK_NE(address, ReadOnlyRoots(heap_).not_mapped_symbol().ptr());
return static_cast<int>(hasher_(address));
}
@ -163,8 +159,7 @@ IdentityMapBase::RawEntry IdentityMapBase::GetEntry(Address key) {
gc_counter_ = heap_->gc_count();
keys_ = reinterpret_cast<Address*>(NewPointerArray(capacity_));
Address not_mapped =
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol());
Address not_mapped = ReadOnlyRoots(heap_).not_mapped_symbol().ptr();
for (int i = 0; i < capacity_; i++) keys_[i] = not_mapped;
values_ = NewPointerArray(capacity_);
memset(values_, 0, sizeof(void*) * capacity_);
@ -203,8 +198,7 @@ bool IdentityMapBase::DeleteEntry(Address key, void** deleted_value) {
Address IdentityMapBase::KeyAtIndex(int index) const {
DCHECK_LE(0, index);
DCHECK_LT(index, capacity_);
DCHECK_NE(keys_[index], reinterpret_cast<Address>(
ReadOnlyRoots(heap_).not_mapped_symbol()));
DCHECK_NE(keys_[index], ReadOnlyRoots(heap_).not_mapped_symbol().ptr());
CHECK(is_iterable()); // Must be iterable to access by index;
return keys_[index];
}
@ -212,8 +206,7 @@ Address IdentityMapBase::KeyAtIndex(int index) const {
IdentityMapBase::RawEntry IdentityMapBase::EntryAtIndex(int index) const {
DCHECK_LE(0, index);
DCHECK_LT(index, capacity_);
DCHECK_NE(keys_[index], reinterpret_cast<Address>(
ReadOnlyRoots(heap_).not_mapped_symbol()));
DCHECK_NE(keys_[index], ReadOnlyRoots(heap_).not_mapped_symbol().ptr());
CHECK(is_iterable()); // Must be iterable to access by index;
return &values_[index];
}
@ -222,8 +215,7 @@ int IdentityMapBase::NextIndex(int index) const {
DCHECK_LE(-1, index);
DCHECK_LE(index, capacity_);
CHECK(is_iterable()); // Must be iterable to access by index;
Address not_mapped =
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol());
Address not_mapped = ReadOnlyRoots(heap_).not_mapped_symbol().ptr();
for (++index; index < capacity_; ++index) {
if (keys_[index] != not_mapped) {
return index;
@ -241,8 +233,7 @@ void IdentityMapBase::Rehash() {
// Search the table looking for keys that wouldn't be found with their
// current hashcode and evacuate them.
int last_empty = -1;
Address not_mapped =
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol());
Address not_mapped = ReadOnlyRoots(heap_).not_mapped_symbol().ptr();
for (int i = 0; i < capacity_; i++) {
if (keys_[i] == not_mapped) {
last_empty = i;
@ -280,8 +271,7 @@ void IdentityMapBase::Resize(int new_capacity) {
size_ = 0;
keys_ = reinterpret_cast<Address*>(NewPointerArray(capacity_));
Address not_mapped =
reinterpret_cast<Address>(ReadOnlyRoots(heap_).not_mapped_symbol());
Address not_mapped = ReadOnlyRoots(heap_).not_mapped_symbol().ptr();
for (int i = 0; i < capacity_; i++) keys_[i] = not_mapped;
values_ = NewPointerArray(capacity_);
memset(values_, 0, sizeof(void*) * capacity_);

View File

@ -612,7 +612,7 @@ int CollectOwnPropertyNamesInternal(Handle<JSObject> object,
if (!AccessorInfo::cast(accessors)->all_can_read()) continue;
}
Name* key = descs->GetKey(i);
Name key = descs->GetKey(i);
if (skip_symbols == key->IsSymbol()) {
if (first_skipped == -1) first_skipped = i;
continue;

View File

@ -88,9 +88,9 @@ Log::MessageBuilder::MessageBuilder(Log* log)
DCHECK_NOT_NULL(log_->format_buffer_);
}
void Log::MessageBuilder::AppendString(String* str,
void Log::MessageBuilder::AppendString(String str,
base::Optional<int> length_limit) {
if (str == nullptr) return;
if (str.is_null()) return;
DisallowHeapAllocation no_gc; // Ensure string stays valid.
int length = str->length();
@ -155,8 +155,8 @@ void Log::MessageBuilder::AppendCharacter(char c) {
}
}
void Log::MessageBuilder::AppendSymbolName(Symbol* symbol) {
DCHECK(symbol);
void Log::MessageBuilder::AppendSymbolName(Symbol symbol) {
DCHECK(!symbol.is_null());
OFStream& os = log_->os_;
os << "symbol(";
if (!symbol->name()->IsUndefined()) {
@ -167,9 +167,9 @@ void Log::MessageBuilder::AppendSymbolName(Symbol* symbol) {
os << "hash " << std::hex << symbol->Hash() << std::dec << ")";
}
void Log::MessageBuilder::AppendSymbolNameDetails(String* str,
void Log::MessageBuilder::AppendSymbolNameDetails(String str,
bool show_impl_info) {
if (str == nullptr) return;
if (str.is_null()) return;
DisallowHeapAllocation no_gc; // Ensure string stays valid.
OFStream& os = log_->os_;
@ -233,19 +233,19 @@ Log::MessageBuilder& Log::MessageBuilder::operator<<<char>(char c) {
}
template <>
Log::MessageBuilder& Log::MessageBuilder::operator<<<String*>(String* string) {
Log::MessageBuilder& Log::MessageBuilder::operator<<<String>(String string) {
this->AppendString(string);
return *this;
}
template <>
Log::MessageBuilder& Log::MessageBuilder::operator<<<Symbol*>(Symbol* symbol) {
Log::MessageBuilder& Log::MessageBuilder::operator<<<Symbol>(Symbol symbol) {
this->AppendSymbolName(symbol);
return *this;
}
template <>
Log::MessageBuilder& Log::MessageBuilder::operator<<<Name*>(Name* name) {
Log::MessageBuilder& Log::MessageBuilder::operator<<<Name>(Name name) {
if (name->IsString()) {
this->AppendString(String::cast(name));
} else {

View File

@ -65,14 +65,14 @@ class Log {
explicit MessageBuilder(Log* log);
~MessageBuilder() = default;
void AppendString(String* str,
void AppendString(String str,
base::Optional<int> length_limit = base::nullopt);
void AppendString(Vector<const char> str);
void AppendString(const char* str);
void AppendString(const char* str, size_t length);
void PRINTF_FORMAT(2, 3) AppendFormatString(const char* format, ...);
void AppendCharacter(char c);
void AppendSymbolName(Symbol* symbol);
void AppendSymbolName(Symbol symbol);
// Delegate insertion to the underlying {log_}.
// All appended strings are escaped to maintain one-line log entries.
@ -91,7 +91,7 @@ class Log {
int PRINTF_FORMAT(2, 0)
FormatStringIntoBuffer(const char* format, va_list args);
void AppendSymbolNameDetails(String* str, bool show_impl_info);
void AppendSymbolNameDetails(String str, bool show_impl_info);
void PRINTF_FORMAT(2, 3) AppendRawFormatString(const char* format, ...);
void AppendRawCharacter(const char character);
@ -143,11 +143,11 @@ Log::MessageBuilder& Log::MessageBuilder::operator<<<const char*>(
template <>
Log::MessageBuilder& Log::MessageBuilder::operator<<<char>(char c);
template <>
Log::MessageBuilder& Log::MessageBuilder::operator<<<String*>(String* string);
Log::MessageBuilder& Log::MessageBuilder::operator<<<String>(String string);
template <>
Log::MessageBuilder& Log::MessageBuilder::operator<<<Symbol*>(Symbol* symbol);
Log::MessageBuilder& Log::MessageBuilder::operator<<<Symbol>(Symbol symbol);
template <>
Log::MessageBuilder& Log::MessageBuilder::operator<<<Name*>(Name* name);
Log::MessageBuilder& Log::MessageBuilder::operator<<<Name>(Name name);
} // namespace internal
} // namespace v8

View File

@ -108,11 +108,11 @@ class CodeEventLogger::NameBuffer {
AppendByte(':');
}
void AppendName(Name* name) {
void AppendName(Name name) {
if (name->IsString()) {
AppendString(String::cast(name));
} else {
Symbol* symbol = Symbol::cast(name);
Symbol symbol = Symbol::cast(name);
AppendBytes("symbol(");
if (!symbol->name()->IsUndefined()) {
AppendBytes("\"");
@ -125,8 +125,8 @@ class CodeEventLogger::NameBuffer {
}
}
void AppendString(String* str) {
if (str == nullptr) return;
void AppendString(String str) {
if (str.is_null()) return;
int length = 0;
std::unique_ptr<char[]> c_str =
str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, &length);
@ -192,7 +192,7 @@ void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
}
void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, Name* name) {
AbstractCode code, Name name) {
name_buffer_->Init(tag);
name_buffer_->AppendName(name);
LogRecordedBuffer(code, nullptr, name_buffer_->get(), name_buffer_->size());
@ -200,7 +200,7 @@ void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code,
SharedFunctionInfo* shared, Name* name) {
SharedFunctionInfo* shared, Name name) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(ComputeMarker(shared, code));
name_buffer_->AppendName(name);
@ -209,7 +209,7 @@ void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code,
SharedFunctionInfo* shared, Name* source,
SharedFunctionInfo* shared, Name source,
int line, int column) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(ComputeMarker(shared, code));
@ -245,7 +245,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
LogRecordedBuffer(code, name_buffer_->get(), name_buffer_->size());
}
void CodeEventLogger::RegExpCodeCreateEvent(AbstractCode code, String* source) {
void CodeEventLogger::RegExpCodeCreateEvent(AbstractCode code, String source) {
name_buffer_->Init(CodeEventListener::REG_EXP_TAG);
name_buffer_->AppendString(source);
LogRecordedBuffer(code, nullptr, name_buffer_->get(), name_buffer_->size());
@ -390,7 +390,7 @@ void ExternalCodeEventListener::CodeCreateEvent(
}
void ExternalCodeEventListener::CodeCreateEvent(
CodeEventListener::LogEventsAndTags tag, AbstractCode code, Name* name) {
CodeEventListener::LogEventsAndTags tag, AbstractCode code, Name name) {
Handle<String> name_string =
Name::ToFunctionName(isolate_, Handle<Name>(name, isolate_))
.ToHandleChecked();
@ -411,7 +411,7 @@ void ExternalCodeEventListener::CodeCreateEvent(
void ExternalCodeEventListener::CodeCreateEvent(
CodeEventListener::LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* name) {
SharedFunctionInfo* shared, Name name) {
Handle<String> name_string =
Name::ToFunctionName(isolate_, Handle<Name>(name, isolate_))
.ToHandleChecked();
@ -432,7 +432,7 @@ void ExternalCodeEventListener::CodeCreateEvent(
void ExternalCodeEventListener::CodeCreateEvent(
CodeEventListener::LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* source, int line, int column) {
SharedFunctionInfo* shared, Name source, int line, int column) {
Handle<String> name_string =
Name::ToFunctionName(isolate_, Handle<Name>(shared->Name(), isolate_))
.ToHandleChecked();
@ -461,7 +461,7 @@ void ExternalCodeEventListener::CodeCreateEvent(LogEventsAndTags tag,
}
void ExternalCodeEventListener::RegExpCodeCreateEvent(AbstractCode code,
String* source) {
String source) {
CodeEvent code_event;
code_event.code_start_address =
static_cast<uintptr_t>(code->InstructionStart());
@ -1167,8 +1167,7 @@ void Logger::DeleteEvent(const char* name, void* object) {
msg.WriteToLogFile();
}
void Logger::CallbackEventInternal(const char* prefix, Name* name,
void Logger::CallbackEventInternal(const char* prefix, Name name,
Address entry_point) {
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@ -1180,18 +1179,15 @@ void Logger::CallbackEventInternal(const char* prefix, Name* name,
msg.WriteToLogFile();
}
void Logger::CallbackEvent(Name* name, Address entry_point) {
void Logger::CallbackEvent(Name name, Address entry_point) {
CallbackEventInternal("", name, entry_point);
}
void Logger::GetterCallbackEvent(Name* name, Address entry_point) {
void Logger::GetterCallbackEvent(Name name, Address entry_point) {
CallbackEventInternal("get ", name, entry_point);
}
void Logger::SetterCallbackEvent(Name* name, Address entry_point) {
void Logger::SetterCallbackEvent(Name name, Address entry_point) {
CallbackEventInternal("set ", name, entry_point);
}
@ -1229,7 +1225,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
}
void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, Name* name) {
AbstractCode code, Name name) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@ -1240,7 +1236,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
Name* name) {
Name name) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
if (code == AbstractCode::cast(
@ -1284,7 +1280,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
// to leave logging functions free from heap allocations.
void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
Name* source, int line, int column) {
Name source, int line, int column) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
{
@ -1394,7 +1390,7 @@ void Logger::CodeMovingGCEvent() {
base::OS::SignalCodeMovingGC();
}
void Logger::RegExpCodeCreateEvent(AbstractCode code, String* source) {
void Logger::RegExpCodeCreateEvent(AbstractCode code, String source) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@ -1482,13 +1478,12 @@ void Logger::ResourceEvent(const char* name, const char* tag) {
msg.WriteToLogFile();
}
void Logger::SuspectReadEvent(Name* name, Object* obj) {
void Logger::SuspectReadEvent(Name name, Object* obj) {
if (!log_->IsEnabled() || !FLAG_log_suspect) return;
Log::MessageBuilder msg(log_);
String* class_name = obj->IsJSObject()
? JSObject::cast(obj)->class_name()
: ReadOnlyRoots(isolate_).empty_string();
String class_name = obj->IsJSObject()
? JSObject::cast(obj)->class_name()
: ReadOnlyRoots(isolate_).empty_string();
msg << "suspect-read" << kNext << class_name << kNext << name;
msg.WriteToLogFile();
}
@ -1506,12 +1501,12 @@ void AppendFunctionMessage(Log::MessageBuilder& msg, const char* reason,
void Logger::FunctionEvent(const char* reason, int script_id, double time_delta,
int start_position, int end_position,
String* function_name) {
String function_name) {
if (!log_->IsEnabled() || !FLAG_log_function_events) return;
Log::MessageBuilder msg(log_);
AppendFunctionMessage(msg, reason, script_id, time_delta, start_position,
end_position, &timer_);
if (function_name) msg << function_name;
if (!function_name.is_null()) msg << function_name;
msg.WriteToLogFile();
}
@ -1600,7 +1595,7 @@ bool Logger::EnsureLogScriptSource(Script* script) {
logged_source_code_.insert(script_id);
Object* source_object = script->source();
if (!source_object->IsString()) return false;
String* source_code = String::cast(source_object);
String source_code = String::cast(source_object);
msg << "script-source" << kNext << script_id << kNext;
// Log the script name.
@ -1848,7 +1843,7 @@ void Logger::LogAccessorCallbacks() {
AccessorInfo* ai = AccessorInfo::cast(obj);
if (!ai->name()->IsName()) continue;
Address getter_entry = v8::ToCData<Address>(ai->getter());
Name* name = Name::cast(ai->name());
Name name = Name::cast(ai->name());
if (getter_entry != 0) {
#if USES_FUNCTION_DESCRIPTORS
getter_entry = *FUNCTION_ENTRYPOINT_ADDRESS(getter_entry);

View File

@ -17,6 +17,7 @@
#include "src/isolate.h"
#include "src/log-utils.h"
#include "src/objects.h"
#include "src/objects/string.h"
namespace v8 {
@ -160,12 +161,12 @@ class Logger : public CodeEventListener {
// Emits an event that an undefined property was read from an
// object.
void SuspectReadEvent(Name* name, Object* obj);
void SuspectReadEvent(Name name, Object* obj);
// ==== Events logged by --log-function-events ====
void FunctionEvent(const char* reason, int script_id, double time_delta_ms,
int start_position = -1, int end_position = -1,
String* function_name = nullptr);
String function_name = String());
void FunctionEvent(const char* reason, int script_id, double time_delta_ms,
int start_position, int end_position,
const char* function_name = nullptr,
@ -190,20 +191,20 @@ class Logger : public CodeEventListener {
void RemoveCodeEventListener(CodeEventListener* listener);
// Emits a code event for a callback function.
void CallbackEvent(Name* name, Address entry_point) override;
void GetterCallbackEvent(Name* name, Address entry_point) override;
void SetterCallbackEvent(Name* name, Address entry_point) override;
void CallbackEvent(Name name, Address entry_point) override;
void GetterCallbackEvent(Name name, Address entry_point) override;
void SetterCallbackEvent(Name name, Address entry_point) override;
// Emits a code create event.
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, const char* source) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, Name* name) override;
AbstractCode code, Name name) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
Name* name) override;
Name name) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
Name* source, int line, int column) override;
Name source, int line, int column) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
const wasm::WasmCode* code,
wasm::WasmName name) override;
@ -212,7 +213,7 @@ class Logger : public CodeEventListener {
SharedFunctionInfo* shared) override;
void CodeMovingGCEvent() override;
// Emits a code create event for a RegExp.
void RegExpCodeCreateEvent(AbstractCode code, String* source) override;
void RegExpCodeCreateEvent(AbstractCode code, String source) override;
// Emits a code move event.
void CodeMoveEvent(AbstractCode from, AbstractCode to) override;
// Emits a code line info record event.
@ -294,8 +295,7 @@ class Logger : public CodeEventListener {
void ProfilerBeginEvent();
// Emits callback event messages.
void CallbackEventInternal(const char* prefix,
Name* name,
void CallbackEventInternal(const char* prefix, Name name,
Address entry_point);
// Internal configurable move event.
@ -407,19 +407,19 @@ class CodeEventLogger : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
const char* comment) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
Name* name) override;
Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* name) override;
SharedFunctionInfo* shared, Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* source, int line,
SharedFunctionInfo* shared, Name source, int line,
int column) override;
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name) override;
void RegExpCodeCreateEvent(AbstractCode code, String* source) override;
void CallbackEvent(Name* name, Address entry_point) override {}
void GetterCallbackEvent(Name* name, Address entry_point) override {}
void SetterCallbackEvent(Name* name, Address entry_point) override {}
void RegExpCodeCreateEvent(AbstractCode code, String source) override;
void CallbackEvent(Name name, Address entry_point) override {}
void GetterCallbackEvent(Name name, Address entry_point) override {}
void SetterCallbackEvent(Name name, Address entry_point) override {}
void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
void CodeMovingGCEvent() override {}
void CodeDeoptEvent(Code code, DeoptimizeKind kind, Address pc,
@ -459,19 +459,19 @@ class ExternalCodeEventListener : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
const char* comment) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
Name* name) override;
Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* name) override;
SharedFunctionInfo* shared, Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name* source, int line,
SharedFunctionInfo* shared, Name source, int line,
int column) override;
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name) override;
void RegExpCodeCreateEvent(AbstractCode code, String* source) override;
void CallbackEvent(Name* name, Address entry_point) override {}
void GetterCallbackEvent(Name* name, Address entry_point) override {}
void SetterCallbackEvent(Name* name, Address entry_point) override {}
void RegExpCodeCreateEvent(AbstractCode code, String source) override;
void CallbackEvent(Name name, Address entry_point) override {}
void GetterCallbackEvent(Name name, Address entry_point) override {}
void SetterCallbackEvent(Name name, Address entry_point) override {}
void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
void CodeMoveEvent(AbstractCode from, AbstractCode to) override {}
void CodeDisableOptEvent(AbstractCode code,

View File

@ -13,7 +13,7 @@ namespace v8 {
namespace internal {
// static
int DescriptorLookupCache::Hash(Map source, Name* name) {
int DescriptorLookupCache::Hash(Map source, Name name) {
DCHECK(name->IsUniqueName());
// Uses only lower 32 bits if pointers are larger.
uint32_t source_hash =
@ -22,14 +22,14 @@ int DescriptorLookupCache::Hash(Map source, Name* name) {
return (source_hash ^ name_hash) % kLength;
}
int DescriptorLookupCache::Lookup(Map source, Name* name) {
int DescriptorLookupCache::Lookup(Map source, Name name) {
int index = Hash(source, name);
Key& key = keys_[index];
if ((key.source == source) && (key.name == name)) return results_[index];
return kAbsent;
}
void DescriptorLookupCache::Update(Map source, Name* name, int result) {
void DescriptorLookupCache::Update(Map source, Name name, int result) {
DCHECK_NE(result, kAbsent);
int index = Hash(source, name);
Key& key = keys_[index];

View File

@ -7,6 +7,7 @@
#include "src/objects.h"
#include "src/objects/map.h"
#include "src/objects/name.h"
namespace v8 {
namespace internal {
@ -19,10 +20,10 @@ class DescriptorLookupCache {
public:
// Lookup descriptor index for (map, name).
// If absent, kAbsent is returned.
inline int Lookup(Map source, Name* name);
inline int Lookup(Map source, Name name);
// Update an element in the cache.
inline void Update(Map source, Name* name, int result);
inline void Update(Map source, Name name, int result);
// Clear the cache.
void Clear();
@ -33,17 +34,17 @@ class DescriptorLookupCache {
DescriptorLookupCache() {
for (int i = 0; i < kLength; ++i) {
keys_[i].source = Map();
keys_[i].name = nullptr;
keys_[i].name = Name();
results_[i] = kAbsent;
}
}
static inline int Hash(Map source, Name* name);
static inline int Hash(Map source, Name name);
static const int kLength = 64;
struct Key {
Map source;
Name* name;
Name name;
};
Key keys_[kLength];

View File

@ -38,7 +38,7 @@ MapUpdater::MapUpdater(Isolate* isolate, Handle<Map> old_map)
->IsFunctionTemplateInfo());
}
Name* MapUpdater::GetKey(int descriptor) const {
Name MapUpdater::GetKey(int descriptor) const {
return old_descriptors_->GetKey(descriptor);
}
@ -617,7 +617,7 @@ Handle<Map> MapUpdater::FindSplitMap(Handle<DescriptorArray> descriptors) {
int root_nof = root_map_->NumberOfOwnDescriptors();
Map current = *root_map_;
for (int i = root_nof; i < old_nof_; i++) {
Name* name = descriptors->GetKey(i);
Name name = descriptors->GetKey(i);
PropertyDetails details = descriptors->GetDetails(i);
Map next =
TransitionsAccessor(isolate_, current, &no_allocation)

View File

@ -108,7 +108,7 @@ class MapUpdater {
State CopyGeneralizeAllFields(const char* reason);
// Returns name of a |descriptor| property.
inline Name* GetKey(int descriptor) const;
inline Name GetKey(int descriptor) const;
// Returns property details of a |descriptor| in "updated" |old_descrtiptors_|
// array.

View File

@ -577,7 +577,7 @@ class SeqOneByteString::BodyDescriptor final : public BodyDescriptorBase {
ObjectVisitor* v) {}
static inline int SizeOf(Map map, HeapObject* obj) {
SeqOneByteString* string = SeqOneByteString::cast(obj);
SeqOneByteString string = SeqOneByteString::cast(obj);
return string->SizeFor(string->synchronized_length());
}
};
@ -593,7 +593,7 @@ class SeqTwoByteString::BodyDescriptor final : public BodyDescriptorBase {
ObjectVisitor* v) {}
static inline int SizeOf(Map map, HeapObject* obj) {
SeqTwoByteString* string = SeqTwoByteString::cast(obj);
SeqTwoByteString string = SeqTwoByteString::cast(obj);
return string->SizeFor(string->synchronized_length());
}
};

View File

@ -989,16 +989,16 @@ void JSMessageObject::JSMessageObjectVerify(Isolate* isolate) {
void String::StringVerify(Isolate* isolate) {
CHECK(IsString());
CHECK(length() >= 0 && length() <= Smi::kMaxValue);
CHECK_IMPLIES(length() == 0, this == ReadOnlyRoots(isolate).empty_string());
CHECK_IMPLIES(length() == 0, *this == ReadOnlyRoots(isolate).empty_string());
if (IsInternalizedString()) {
CHECK(!Heap::InNewSpace(this));
CHECK(!Heap::InNewSpace(*this));
}
if (IsConsString()) {
ConsString::cast(this)->ConsStringVerify(isolate);
ConsString::cast(*this)->ConsStringVerify(isolate);
} else if (IsSlicedString()) {
SlicedString::cast(this)->SlicedStringVerify(isolate);
SlicedString::cast(*this)->SlicedStringVerify(isolate);
} else if (IsThinString()) {
ThinString::cast(this)->ThinStringVerify(isolate);
ThinString::cast(*this)->ThinStringVerify(isolate);
}
}
@ -2233,10 +2233,10 @@ void JSObject::SpillInformation::Print() {
bool DescriptorArray::IsSortedNoDuplicates(int valid_entries) {
if (valid_entries == -1) valid_entries = number_of_descriptors();
Name* current_key = nullptr;
Name current_key;
uint32_t current = 0;
for (int i = 0; i < number_of_descriptors(); i++) {
Name* key = GetSortedKey(i);
Name key = GetSortedKey(i);
if (key == current_key) {
Print();
return false;
@ -2254,13 +2254,13 @@ bool DescriptorArray::IsSortedNoDuplicates(int valid_entries) {
bool TransitionArray::IsSortedNoDuplicates(int valid_entries) {
DCHECK_EQ(valid_entries, -1);
Name* prev_key = nullptr;
Name prev_key;
PropertyKind prev_kind = kData;
PropertyAttributes prev_attributes = NONE;
uint32_t prev_hash = 0;
for (int i = 0; i < number_of_transitions(); i++) {
Name* key = GetSortedKey(i);
Name key = GetSortedKey(i);
uint32_t hash = key->Hash();
PropertyKind kind = kData;
PropertyAttributes attributes = NONE;

View File

@ -950,9 +950,9 @@ void Oddball::set_to_number_raw_as_bits(uint64_t bits) {
WRITE_UINT64_FIELD(this, kToNumberRawOffset, bits);
}
ACCESSORS(Oddball, to_string, String, kToStringOffset)
ACCESSORS2(Oddball, to_string, String, kToStringOffset)
ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
ACCESSORS(Oddball, type_of, String, kTypeOfOffset)
ACCESSORS2(Oddball, type_of, String, kTypeOfOffset)
byte Oddball::kind() const { return Smi::ToInt(READ_FIELD(this, kKindOffset)); }
@ -970,7 +970,7 @@ Handle<Object> Oddball::ToNumber(Isolate* isolate, Handle<Oddball> input) {
ACCESSORS(Cell, value, Object, kValueOffset)
ACCESSORS(FeedbackCell, value, HeapObject, kValueOffset)
ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
ACCESSORS(PropertyCell, name, Name, kNameOffset)
ACCESSORS2(PropertyCell, name, Name, kNameOffset)
ACCESSORS(PropertyCell, value, Object, kValueOffset)
ACCESSORS(PropertyCell, property_details_raw, Object, kDetailsOffset)
@ -1044,13 +1044,12 @@ void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) {
set(kNumberOfCapturesIndex, Smi::FromInt(value));
}
String* RegExpMatchInfo::LastSubject() {
String RegExpMatchInfo::LastSubject() {
DCHECK_GE(length(), kLastMatchOverhead);
Object* obj = get(kLastSubjectIndex);
return String::cast(obj);
return String::cast(get(kLastSubjectIndex));
}
void RegExpMatchInfo::SetLastSubject(String* value) {
void RegExpMatchInfo::SetLastSubject(String value) {
DCHECK_GE(length(), kLastMatchOverhead);
set(kLastSubjectIndex, value);
}
@ -1151,7 +1150,7 @@ void DescriptorArray::CopyEnumCacheFrom(DescriptorArray* array) {
// Perform a binary search in a fixed array.
template <SearchMode search_mode, typename T>
int BinarySearch(T* array, Name* name, int valid_entries,
int BinarySearch(T* array, Name name, int valid_entries,
int* out_insertion_index) {
DCHECK(search_mode == ALL_ENTRIES || out_insertion_index == nullptr);
int low = 0;
@ -1163,7 +1162,7 @@ int BinarySearch(T* array, Name* name, int valid_entries,
while (low != high) {
int mid = low + (high - low) / 2;
Name* mid_name = array->GetSortedKey(mid);
Name mid_name = array->GetSortedKey(mid);
uint32_t mid_hash = mid_name->hash_field();
if (mid_hash >= hash) {
@ -1175,7 +1174,7 @@ int BinarySearch(T* array, Name* name, int valid_entries,
for (; low <= limit; ++low) {
int sort_index = array->GetSortedKeyIndex(low);
Name* entry = array->GetKey(sort_index);
Name entry = array->GetKey(sort_index);
uint32_t current_hash = entry->hash_field();
if (current_hash != hash) {
if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
@ -1200,14 +1199,14 @@ int BinarySearch(T* array, Name* name, int valid_entries,
// Perform a linear search in this fixed array. len is the number of entry
// indices that are valid.
template <SearchMode search_mode, typename T>
int LinearSearch(T* array, Name* name, int valid_entries,
int LinearSearch(T* array, Name name, int valid_entries,
int* out_insertion_index) {
if (search_mode == ALL_ENTRIES && out_insertion_index != nullptr) {
uint32_t hash = name->hash_field();
int len = array->number_of_entries();
for (int number = 0; number < len; number++) {
int sorted_index = array->GetSortedKeyIndex(number);
Name* entry = array->GetKey(sorted_index);
Name entry = array->GetKey(sorted_index);
uint32_t current_hash = entry->hash_field();
if (current_hash > hash) {
*out_insertion_index = sorted_index;
@ -1228,7 +1227,7 @@ int LinearSearch(T* array, Name* name, int valid_entries,
}
template <SearchMode search_mode, typename T>
int Search(T* array, Name* name, int valid_entries, int* out_insertion_index) {
int Search(T* array, Name name, int valid_entries, int* out_insertion_index) {
SLOW_DCHECK(array->IsSortedNoDuplicates());
if (valid_entries == 0) {
@ -1250,20 +1249,20 @@ int Search(T* array, Name* name, int valid_entries, int* out_insertion_index) {
out_insertion_index);
}
int DescriptorArray::Search(Name* name, int valid_descriptors) {
int DescriptorArray::Search(Name name, int valid_descriptors) {
DCHECK(name->IsUniqueName());
return internal::Search<VALID_ENTRIES>(this, name, valid_descriptors,
nullptr);
}
int DescriptorArray::Search(Name* name, Map map) {
int DescriptorArray::Search(Name name, Map map) {
DCHECK(name->IsUniqueName());
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
if (number_of_own_descriptors == 0) return kNotFound;
return Search(name, number_of_own_descriptors);
}
int DescriptorArray::SearchWithCache(Isolate* isolate, Name* name, Map map) {
int DescriptorArray::SearchWithCache(Isolate* isolate, Name name, Map map) {
DCHECK(name->IsUniqueName());
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
if (number_of_own_descriptors == 0) return kNotFound;
@ -1298,7 +1297,7 @@ ObjectSlot DescriptorArray::GetKeySlot(int descriptor) {
return slot;
}
Name* DescriptorArray::GetKey(int descriptor_number) {
Name DescriptorArray::GetKey(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
return Name::cast(
get(ToKeyIndex(descriptor_number))->GetHeapObjectAssumeStrong());
@ -1308,7 +1307,7 @@ int DescriptorArray::GetSortedKeyIndex(int descriptor_number) {
return GetDetails(descriptor_number).pointer();
}
Name* DescriptorArray::GetSortedKey(int descriptor_number) {
Name DescriptorArray::GetSortedKey(int descriptor_number) {
return GetKey(GetSortedKeyIndex(descriptor_number));
}
@ -1354,7 +1353,7 @@ FieldType DescriptorArray::GetFieldType(int descriptor_number) {
return Map::UnwrapFieldType(wrapped_type);
}
void DescriptorArray::Set(int descriptor_number, Name* key, MaybeObject value,
void DescriptorArray::Set(int descriptor_number, Name key, MaybeObject value,
PropertyDetails details) {
// Range check.
DCHECK(descriptor_number < number_of_descriptors());
@ -1365,7 +1364,7 @@ void DescriptorArray::Set(int descriptor_number, Name* key, MaybeObject value,
}
void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
Name* key = *desc->GetKey();
Name key = *desc->GetKey();
MaybeObject value = *desc->GetValue();
Set(descriptor_number, key, value, desc->GetDetails());
}
@ -1383,7 +1382,7 @@ void DescriptorArray::Append(Descriptor* desc) {
int insertion;
for (insertion = descriptor_number; insertion > 0; --insertion) {
Name* key = GetSortedKey(insertion - 1);
Name key = GetSortedKey(insertion - 1);
if (key->Hash() <= hash) break;
SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1));
}
@ -1413,12 +1412,12 @@ void DescriptorArray::set(int index, MaybeObject value) {
WEAK_WRITE_BARRIER(this, offset(index), value);
}
bool StringSetShape::IsMatch(String* key, Object* value) {
bool StringSetShape::IsMatch(String key, Object* value) {
DCHECK(value->IsString());
return key->Equals(String::cast(value));
}
uint32_t StringSetShape::Hash(Isolate* isolate, String* key) {
uint32_t StringSetShape::Hash(Isolate* isolate, String key) {
return key->Hash();
}
@ -1533,7 +1532,7 @@ int HeapObject::SizeFromMap(Map map) const {
// Strings may get concurrently truncated, hence we have to access its
// length synchronized.
return SeqOneByteString::SizeFor(
reinterpret_cast<const SeqOneByteString*>(this)->synchronized_length());
SeqOneByteString::unchecked_cast(this)->synchronized_length());
}
if (instance_type == BYTE_ARRAY_TYPE) {
return ByteArray::SizeFor(
@ -1551,7 +1550,7 @@ int HeapObject::SizeFromMap(Map map) const {
// Strings may get concurrently truncated, hence we have to access its
// length synchronized.
return SeqTwoByteString::SizeFor(
reinterpret_cast<const SeqTwoByteString*>(this)->synchronized_length());
SeqTwoByteString::unchecked_cast(this)->synchronized_length());
}
if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
return FixedDoubleArray::SizeFor(
@ -1817,7 +1816,7 @@ RootIndex GlobalDictionaryShape::GetMapRootIndex() {
return RootIndex::kGlobalDictionaryMap;
}
Name* NameDictionary::NameAt(int entry) { return Name::cast(KeyAt(entry)); }
Name NameDictionary::NameAt(int entry) { return Name::cast(KeyAt(entry)); }
RootIndex NameDictionaryShape::GetMapRootIndex() {
return RootIndex::kNameDictionaryMap;
@ -1837,7 +1836,7 @@ bool GlobalDictionaryShape::IsKey(ReadOnlyRoots roots, Object* k) {
return IsLive(roots, k) && !PropertyCell::cast(k)->value()->IsTheHole(roots);
}
Name* GlobalDictionary::NameAt(int entry) { return CellAt(entry)->name(); }
Name GlobalDictionary::NameAt(int entry) { return CellAt(entry)->name(); }
Object* GlobalDictionary::ValueAt(int entry) { return CellAt(entry)->value(); }
void GlobalDictionary::SetEntry(Isolate* isolate, int entry, Object* key,

View File

@ -780,9 +780,9 @@ void JSGeneratorObject::JSGeneratorObjectPrint(std::ostream& os) { // NOLINT
Script* script = Script::cast(fun_info->script());
int lin = script->GetLineNumber(source_position()) + 1;
int col = script->GetColumnNumber(source_position()) + 1;
String* script_name = script->name()->IsString()
? String::cast(script->name())
: GetReadOnlyRoots().empty_string();
String script_name = script->name()->IsString()
? String::cast(script->name())
: GetReadOnlyRoots().empty_string();
os << "\n - source position: " << source_position();
os << " (";
script_name->PrintUC16(os);
@ -832,7 +832,7 @@ void JSRegExpStringIterator::JSRegExpStringIteratorPrint(
}
void Symbol::SymbolPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Symbol");
PrintHeader(os, "Symbol");
os << "\n - hash: " << Hash();
os << "\n - name: " << Brief(name());
if (name()->IsUndefined()) {
@ -1249,11 +1249,11 @@ void String::StringPrint(std::ostream& os) { // NOLINT
if (!HasOnlyOneByteChars()) {
os << "u";
}
if (StringShape(this).IsInternalized()) {
if (StringShape(*this).IsInternalized()) {
os << "#";
} else if (StringShape(this).IsCons()) {
} else if (StringShape(*this).IsCons()) {
os << "c\"";
} else if (StringShape(this).IsThin()) {
} else if (StringShape(*this).IsThin()) {
os << ">\"";
} else {
os << "\"";
@ -1273,15 +1273,15 @@ void String::StringPrint(std::ostream& os) { // NOLINT
os << truncated_epilogue;
}
if (!StringShape(this).IsInternalized()) os << "\"";
if (!StringShape(*this).IsInternalized()) os << "\"";
}
void Name::NamePrint(std::ostream& os) { // NOLINT
if (IsString()) {
String::cast(this)->StringPrint(os);
String::cast(*this)->StringPrint(os);
} else {
os << Brief(this);
os << Brief(*this);
}
}
@ -1498,7 +1498,7 @@ void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
void SharedFunctionInfo::PrintSourceCode(std::ostream& os) {
if (HasSourceCode()) {
os << "\n - source code: ";
String* source = String::cast(Script::cast(script())->source());
String source = String::cast(Script::cast(script())->source());
int start = StartPosition();
int length = EndPosition() - start;
std::unique_ptr<char[]> source_string = source->ToCString(
@ -2395,10 +2395,10 @@ void MutableHeapNumber::MutableHeapNumberPrint(std::ostream& os) {
// TODO(cbruni): remove once the new maptracer is in place.
void Name::NameShortPrint() {
if (this->IsString()) {
PrintF("%s", String::cast(this)->ToCString().get());
PrintF("%s", String::cast(*this)->ToCString().get());
} else {
DCHECK(this->IsSymbol());
Symbol* s = Symbol::cast(this);
Symbol s = Symbol::cast(*this);
if (s->name()->IsUndefined()) {
PrintF("#<%s>", s->PrivateSymbolToName());
} else {
@ -2410,10 +2410,10 @@ void Name::NameShortPrint() {
// TODO(cbruni): remove once the new maptracer is in place.
int Name::NameShortPrint(Vector<char> str) {
if (this->IsString()) {
return SNPrintF(str, "%s", String::cast(this)->ToCString().get());
return SNPrintF(str, "%s", String::cast(*this)->ToCString().get());
} else {
DCHECK(this->IsSymbol());
Symbol* s = Symbol::cast(this);
Symbol s = Symbol::cast(*this);
if (s->name()->IsUndefined()) {
return SNPrintF(str, "#<%s>", s->PrivateSymbolToName());
} else {
@ -2435,7 +2435,7 @@ void Map::PrintMapDetails(std::ostream& os) {
void DescriptorArray::PrintDescriptors(std::ostream& os) {
for (int i = 0; i < number_of_descriptors(); i++) {
Name* key = GetKey(i);
Name key = GetKey(i);
os << "\n [" << i << "]: ";
#ifdef OBJECT_PRINT
key->NamePrint(os);
@ -2481,13 +2481,13 @@ char* String::ToAsciiArray() {
static char* buffer = nullptr;
if (buffer != nullptr) delete[] buffer;
buffer = new char[length() + 1];
WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
WriteToFlat(*this, reinterpret_cast<uint8_t*>(buffer), 0, length());
buffer[length()] = 0;
return buffer;
}
// static
void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name* key,
void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name key,
Map target) {
os << "\n ";
#ifdef OBJECT_PRINT
@ -2524,7 +2524,7 @@ void TransitionArray::PrintInternal(std::ostream& os) {
int num_transitions = number_of_transitions();
os << "Transition array #" << num_transitions << ":";
for (int i = 0; i < num_transitions; i++) {
Name* key = GetKey(i);
Name key = GetKey(i);
Map target = GetTarget(i);
TransitionsAccessor::PrintOneTransition(os, key, target);
}
@ -2539,7 +2539,7 @@ void TransitionsAccessor::PrintTransitions(std::ostream& os) { // NOLINT
return;
case kWeakRef: {
Map target = Map::cast(raw_transitions_->GetHeapObjectAssumeWeak());
Name* key = GetSimpleTransitionKey(target);
Name key = GetSimpleTransitionKey(target);
PrintOneTransition(os, key, target);
break;
}
@ -2562,7 +2562,7 @@ void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level,
int num_transitions = NumberOfTransitions();
if (num_transitions == 0) return;
for (int i = 0; i < num_transitions; i++) {
Name* key = GetKey(i);
Name key = GetKey(i);
Map target = GetTarget(i);
os << std::endl
<< " " << level << "/" << i << ":" << std::setw(level * 2 + 2) << " ";

View File

@ -533,6 +533,9 @@ bool Object::BooleanValue(Isolate* isolate) {
return true;
}
bool ObjectPtr::BooleanValue(Isolate* isolate) {
return reinterpret_cast<Object*>(ptr())->BooleanValue(isolate);
}
namespace {
@ -2383,6 +2386,9 @@ Smi Object::GetOrCreateHash(Isolate* isolate) {
return JSReceiver::cast(this)->GetOrCreateIdentityHash(isolate);
}
Smi ObjectPtr::GetOrCreateHash(Isolate* isolate) {
return reinterpret_cast<Object*>(ptr())->GetOrCreateHash(isolate);
}
bool Object::SameValue(Object* other) {
if (other == this) return true;
@ -2406,6 +2412,9 @@ bool Object::SameValue(Object* other) {
return false;
}
bool ObjectPtr::SameValue(Object* other) {
return reinterpret_cast<Object*>(ptr())->SameValue(other);
}
bool Object::SameValueZero(Object* other) {
if (other == this) return true;
@ -2563,9 +2572,10 @@ void Object::ShortPrint(StringStream* accumulator) {
accumulator->Add(os.str().c_str());
}
void Object::ShortPrint(std::ostream& os) { os << Brief(this); }
void ObjectPtr::ShortPrint(std::ostream& os) { os << Brief(*this); }
void MaybeObject::ShortPrint(FILE* out) {
OFStream os(out);
os << Brief(*this);
@ -2657,7 +2667,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
// Assert that the resource and the string are equivalent.
DCHECK(static_cast<size_t>(this->length()) == resource->length());
ScopedVector<uc16> smart_chars(this->length());
String::WriteToFlat(this, smart_chars.start(), 0, this->length());
String::WriteToFlat(*this, smart_chars.start(), 0, this->length());
DCHECK_EQ(0, memcmp(smart_chars.start(), resource->data(),
resource->length() * sizeof(smart_chars[0])));
}
@ -2668,13 +2678,13 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
Isolate* isolate;
// Read-only strings cannot be made external, since that would mutate the
// string.
if (!Isolate::FromWritableHeapObject(this, &isolate)) return false;
if (!Isolate::FromWritableHeapObject(*this, &isolate)) return false;
Heap* heap = isolate->heap();
bool is_one_byte = this->IsOneByteRepresentation();
bool is_internalized = this->IsInternalizedString();
bool has_pointers = StringShape(this).IsIndirect();
bool has_pointers = StringShape(*this).IsIndirect();
if (has_pointers) {
heap->NotifyObjectLayoutChange(this, size, no_allocation);
heap->NotifyObjectLayoutChange(*this, size, no_allocation);
}
// Morph the string to an external string by replacing the map and
// reinitializing the fields. This won't work if the space the existing
@ -2720,9 +2730,9 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
// the left-over space to avoid races with the sweeper thread.
this->synchronized_set_map(new_map);
ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
ExternalTwoByteString self = ExternalTwoByteString::cast(*this);
self->SetResource(isolate, resource);
heap->RegisterExternalString(this);
heap->RegisterExternalString(*this);
if (is_internalized) self->Hash(); // Force regeneration of the hash value.
return true;
}
@ -2740,11 +2750,11 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
DCHECK(static_cast<size_t>(this->length()) == resource->length());
if (this->IsTwoByteRepresentation()) {
ScopedVector<uint16_t> smart_chars(this->length());
String::WriteToFlat(this, smart_chars.start(), 0, this->length());
String::WriteToFlat(*this, smart_chars.start(), 0, this->length());
DCHECK(String::IsOneByte(smart_chars.start(), this->length()));
}
ScopedVector<char> smart_chars(this->length());
String::WriteToFlat(this, smart_chars.start(), 0, this->length());
String::WriteToFlat(*this, smart_chars.start(), 0, this->length());
DCHECK_EQ(0, memcmp(smart_chars.start(), resource->data(),
resource->length() * sizeof(smart_chars[0])));
}
@ -2755,13 +2765,13 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
Isolate* isolate;
// Read-only strings cannot be made external, since that would mutate the
// string.
if (!Isolate::FromWritableHeapObject(this, &isolate)) return false;
if (!Isolate::FromWritableHeapObject(*this, &isolate)) return false;
Heap* heap = isolate->heap();
bool is_internalized = this->IsInternalizedString();
bool has_pointers = StringShape(this).IsIndirect();
bool has_pointers = StringShape(*this).IsIndirect();
if (has_pointers) {
heap->NotifyObjectLayoutChange(this, size, no_allocation);
heap->NotifyObjectLayoutChange(*this, size, no_allocation);
}
// Morph the string to an external string by replacing the map and
@ -2794,26 +2804,26 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
// the left-over space to avoid races with the sweeper thread.
this->synchronized_set_map(new_map);
ExternalOneByteString* self = ExternalOneByteString::cast(this);
ExternalOneByteString self = ExternalOneByteString::cast(*this);
self->SetResource(isolate, resource);
heap->RegisterExternalString(this);
heap->RegisterExternalString(*this);
if (is_internalized) self->Hash(); // Force regeneration of the hash value.
return true;
}
bool String::SupportsExternalization() {
if (this->IsThinString()) {
return i::ThinString::cast(this)->actual()->SupportsExternalization();
return i::ThinString::cast(*this)->actual()->SupportsExternalization();
}
Isolate* isolate;
// RO_SPACE strings cannot be externalized.
if (!Isolate::FromWritableHeapObject(this, &isolate)) {
if (!Isolate::FromWritableHeapObject(*this, &isolate)) {
return false;
}
// Already an external string.
if (StringShape(this).IsExternal()) {
if (StringShape(*this).IsExternal()) {
return false;
}
@ -2832,7 +2842,7 @@ void String::StringShortPrint(StringStream* accumulator, bool show_details) {
return;
}
StringCharacterStream stream(this);
StringCharacterStream stream(*this);
bool truncated = false;
if (len > kMaxShortPrintLength) {
@ -2847,7 +2857,7 @@ void String::StringShortPrint(StringStream* accumulator, bool show_details) {
one_byte = false;
}
}
stream.Reset(this);
stream.Reset(*this);
if (one_byte) {
if (show_details) accumulator->Add("<String[%u]: ", length());
for (int i = 0; i < len; i++) {
@ -2885,7 +2895,7 @@ void String::StringShortPrint(StringStream* accumulator, bool show_details) {
void String::PrintUC16(std::ostream& os, int start, int end) { // NOLINT
if (end < 0) end = length();
StringCharacterStream stream(this, start);
StringCharacterStream stream(*this, start);
for (int i = start; i < end && stream.HasMore(); i++) {
os << AsUC16(stream.GetNext());
}
@ -2933,7 +2943,7 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
Object* fun_name = function->shared()->DebugName();
bool printed = false;
if (fun_name->IsString()) {
String* str = String::cast(fun_name);
String str = String::cast(fun_name);
if (str->length() > 0) {
accumulator->Add("<JSFunction ");
accumulator->Put(str);
@ -2947,7 +2957,7 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
Object* source_name =
Script::cast(function->shared()->script())->name();
if (source_name->IsString()) {
String* str = String::cast(source_name);
String str = String::cast(source_name);
if (str->length() > 0) {
accumulator->Add(" <");
accumulator->Put(str);
@ -2989,7 +2999,7 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
if (!heap->Contains(JSFunction::cast(constructor)->shared())) {
accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!");
} else {
String* constructor_name =
String constructor_name =
JSFunction::cast(constructor)->shared()->Name();
if (constructor_name->length() > 0) {
accumulator->Add(global_object ? "<GlobalObject " : "<");
@ -3059,11 +3069,11 @@ void Map::PrintReconfiguration(Isolate* isolate, FILE* file, int modify_index,
PropertyAttributes attributes) {
OFStream os(file);
os << "[reconfiguring]";
Name* name = instance_descriptors()->GetKey(modify_index);
Name name = instance_descriptors()->GetKey(modify_index);
if (name->IsString()) {
String::cast(name)->PrintOn(file);
} else {
os << "{symbol " << static_cast<void*>(name) << "}";
os << "{symbol " << reinterpret_cast<void*>(name.ptr()) << "}";
}
os << ": " << (kind == kData ? "kData" : "ACCESSORS") << ", attrs: ";
os << attributes << " [";
@ -3346,11 +3356,11 @@ void Map::PrintGeneralization(
MaybeHandle<FieldType> new_field_type, MaybeHandle<Object> new_value) {
OFStream os(file);
os << "[generalizing]";
Name* name = instance_descriptors()->GetKey(modify_index);
Name name = instance_descriptors()->GetKey(modify_index);
if (name->IsString()) {
String::cast(name)->PrintOn(file);
} else {
os << "{symbol " << static_cast<void*>(name) << "}";
os << "{symbol " << reinterpret_cast<void*>(name.ptr()) << "}";
}
os << ":";
if (descriptor_to_field) {
@ -3398,11 +3408,11 @@ void JSObject::PrintInstanceMigration(FILE* file, Map original_map,
PrintF(file, ":%s->%s ", o_r.Mnemonic(), n_r.Mnemonic());
} else if (o->GetDetails(i).location() == kDescriptor &&
n->GetDetails(i).location() == kField) {
Name* name = o->GetKey(i);
Name name = o->GetKey(i);
if (name->IsString()) {
String::cast(name)->PrintOn(file);
} else {
PrintF(file, "{symbol %p}", static_cast<void*>(name));
PrintF(file, "{symbol %p}", reinterpret_cast<void*>(name.ptr()));
}
PrintF(file, " ");
}
@ -3674,7 +3684,7 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
break;
}
case SYMBOL_TYPE: {
Symbol* symbol = Symbol::cast(this);
Symbol symbol = Symbol::cast(this);
symbol->SymbolShortPrint(os);
break;
}
@ -3787,7 +3797,7 @@ bool HeapObject::IsValidSlot(Map map, int offset) {
this, offset, 0);
}
String* JSReceiver::class_name() {
String JSReceiver::class_name() {
ReadOnlyRoots roots = GetReadOnlyRoots();
if (IsFunction()) return roots.Function_string();
if (IsJSArgumentsObject()) return roots.Arguments_string();
@ -3934,7 +3944,7 @@ std::pair<MaybeHandle<JSFunction>, Handle<String>> GetConstructorHelper(
Object* maybe_constructor = receiver->map()->GetConstructor();
if (maybe_constructor->IsJSFunction()) {
JSFunction* constructor = JSFunction::cast(maybe_constructor);
String* name = constructor->shared()->DebugName();
String name = constructor->shared()->DebugName();
if (name->length() != 0 &&
!name->Equals(ReadOnlyRoots(isolate).Object_string())) {
return std::make_pair(handle(constructor, isolate),
@ -3969,7 +3979,7 @@ std::pair<MaybeHandle<JSFunction>, Handle<String>> GetConstructorHelper(
Handle<Object> maybe_constructor = JSReceiver::GetDataProperty(&it);
if (maybe_constructor->IsJSFunction()) {
JSFunction* constructor = JSFunction::cast(*maybe_constructor);
String* name = constructor->shared()->DebugName();
String name = constructor->shared()->DebugName();
if (name->length() != 0 &&
!name->Equals(ReadOnlyRoots(isolate).Object_string())) {
@ -6707,7 +6717,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
int current_offset = 0;
for (int i = 0; i < instance_descriptor_length; i++) {
int index = Smi::ToInt(iteration_order->get(i));
Name* k = dictionary->NameAt(index);
Name k = dictionary->NameAt(index);
// Dictionary keys are internalized upon insertion.
// TODO(jkummerow): Turn this into a DCHECK if it's not hit in the wild.
CHECK(k->IsUniqueName());
@ -9643,7 +9653,7 @@ Handle<Map> Map::CopyReplaceDescriptors(
!(flag == INSERT_TRANSITION &&
TransitionsAccessor(isolate, map).CanHaveMoreTransitions()))) {
LOG(isolate, MapEvent("ReplaceDescriptors", *map, *result, reason,
maybe_name.is_null() ? nullptr : *name));
maybe_name.is_null() ? Name() : *name));
}
return result;
}
@ -10262,7 +10272,7 @@ Handle<DescriptorArray> DescriptorArray::CopyUpToAddAttributes(
if (attributes != NONE) {
for (int i = 0; i < size; ++i) {
MaybeObject value_or_field_type = desc->GetValue(i);
Name* key = desc->GetKey(i);
Name key = desc->GetKey(i);
PropertyDetails details = desc->GetDetails(i);
// Bulk attribute changes never affect private properties.
if (!key->IsPrivate()) {
@ -10304,7 +10314,7 @@ Handle<DescriptorArray> DescriptorArray::CopyForFastObjectClone(
DescriptorArray::Allocate(isolate, size, slack);
for (int i = 0; i < size; ++i) {
Name* key = src->GetKey(i);
Name key = src->GetKey(i);
PropertyDetails details = src->GetDetails(i);
DCHECK(!key->IsPrivateName());
@ -10912,11 +10922,11 @@ Handle<String> String::Trim(Isolate* isolate, Handle<String> string,
bool String::LooksValid() {
// TODO(leszeks): Maybe remove this check entirely, Heap::Contains uses
// basically the same logic as the way we access the heap in the first place.
MemoryChunk* chunk = MemoryChunk::FromHeapObject(this);
MemoryChunk* chunk = MemoryChunk::FromHeapObject(*this);
// RO_SPACE objects should always be valid.
if (chunk->owner()->identity() == RO_SPACE) return true;
if (chunk->heap() == nullptr) return false;
return chunk->heap()->Contains(this);
return chunk->heap()->Contains(*this);
}
// static
@ -11035,18 +11045,18 @@ Handle<Object> String::ToNumber(Isolate* isolate, Handle<String> subject) {
String::FlatContent String::GetFlatContent() {
DCHECK(!AllowHeapAllocation::IsAllowed());
int length = this->length();
StringShape shape(this);
String* string = this;
StringShape shape(*this);
String string = *this;
int offset = 0;
if (shape.representation_tag() == kConsStringTag) {
ConsString* cons = ConsString::cast(string);
ConsString cons = ConsString::cast(string);
if (cons->second()->length() != 0) {
return FlatContent();
}
string = cons->first();
shape = StringShape(string);
} else if (shape.representation_tag() == kSlicedStringTag) {
SlicedString* slice = SlicedString::cast(string);
SlicedString slice = SlicedString::cast(string);
offset = slice->offset();
string = slice->parent();
shape = StringShape(string);
@ -11054,7 +11064,7 @@ String::FlatContent String::GetFlatContent() {
shape.representation_tag() != kSlicedStringTag);
}
if (shape.representation_tag() == kThinStringTag) {
ThinString* thin = ThinString::cast(string);
ThinString thin = ThinString::cast(string);
string = thin->actual();
shape = StringShape(string);
DCHECK(!shape.IsCons());
@ -11091,7 +11101,7 @@ std::unique_ptr<char[]> String::ToCString(AllowNullsFlag allow_nulls,
if (length < 0) length = kMaxInt - offset;
// Compute the size of the UTF-8 string. Start at the specified offset.
StringCharacterStream stream(this, offset);
StringCharacterStream stream(*this, offset);
int character_position = offset;
int utf8_bytes = 0;
int last = unibrow::Utf16::kNoPreviousCharacter;
@ -11108,7 +11118,7 @@ std::unique_ptr<char[]> String::ToCString(AllowNullsFlag allow_nulls,
char* result = NewArray<char>(utf8_bytes + 1);
// Convert the UTF-16 string to a UTF-8 buffer. Start at the specified offset.
stream.Reset(this, offset);
stream.Reset(*this, offset);
character_position = offset;
int utf8_byte_position = 0;
last = unibrow::Utf16::kNoPreviousCharacter;
@ -11210,9 +11220,8 @@ void FlatStringReader::PostGarbageCollection() {
}
}
void ConsStringIterator::Initialize(ConsString* cons_string, int offset) {
DCHECK_NOT_NULL(cons_string);
void ConsStringIterator::Initialize(ConsString cons_string, int offset) {
DCHECK(!cons_string.is_null());
root_ = cons_string;
consumed_ = offset;
// Force stack blown condition to trigger restart.
@ -11221,27 +11230,25 @@ void ConsStringIterator::Initialize(ConsString* cons_string, int offset) {
DCHECK(StackBlown());
}
String* ConsStringIterator::Continue(int* offset_out) {
String ConsStringIterator::Continue(int* offset_out) {
DCHECK_NE(depth_, 0);
DCHECK_EQ(0, *offset_out);
bool blew_stack = StackBlown();
String* string = nullptr;
String string;
// Get the next leaf if there is one.
if (!blew_stack) string = NextLeaf(&blew_stack);
// Restart search from root.
if (blew_stack) {
DCHECK_NULL(string);
DCHECK(string.is_null());
string = Search(offset_out);
}
// Ensure future calls return null immediately.
if (string == nullptr) Reset(nullptr);
if (string.is_null()) Reset(ConsString());
return string;
}
String* ConsStringIterator::Search(int* offset_out) {
ConsString* cons_string = root_;
String ConsStringIterator::Search(int* offset_out) {
ConsString cons_string = root_;
// Reset the stack, pushing the root string.
depth_ = 1;
maximum_depth_ = 1;
@ -11250,7 +11257,7 @@ String* ConsStringIterator::Search(int* offset_out) {
int offset = 0;
while (true) {
// Loop until the string is found which contains the target offset.
String* string = cons_string->first();
String string = cons_string->first();
int length = string->length();
int32_t type;
if (consumed < offset + length) {
@ -11282,8 +11289,8 @@ String* ConsStringIterator::Search(int* offset_out) {
// This happens only if we have asked for an offset outside the string.
if (length == 0) {
// Reset so future operations will return null immediately.
Reset(nullptr);
return nullptr;
Reset(ConsString());
return String();
}
// Tell the stack we're done descending.
AdjustMaximumDepth();
@ -11299,22 +11306,21 @@ String* ConsStringIterator::Search(int* offset_out) {
UNREACHABLE();
}
String* ConsStringIterator::NextLeaf(bool* blew_stack) {
String ConsStringIterator::NextLeaf(bool* blew_stack) {
while (true) {
// Tree traversal complete.
if (depth_ == 0) {
*blew_stack = false;
return nullptr;
return String();
}
// We've lost track of higher nodes.
if (StackBlown()) {
*blew_stack = true;
return nullptr;
return String();
}
// Go right.
ConsString* cons_string = frames_[OffsetForDepth(depth_ - 1)];
String* string = cons_string->second();
ConsString cons_string = frames_[OffsetForDepth(depth_ - 1)];
String string = cons_string->second();
int32_t type = string->map()->instance_type();
if ((type & kStringRepresentationMask) != kConsStringTag) {
// Pop stack so next iteration is in correct place.
@ -11346,22 +11352,21 @@ String* ConsStringIterator::NextLeaf(bool* blew_stack) {
UNREACHABLE();
}
uint16_t ConsString::ConsStringGet(int index) {
DCHECK(index >= 0 && index < this->length());
// Check for a flattened cons string
if (second()->length() == 0) {
String* left = first();
String left = first();
return left->Get(index);
}
String* string = String::cast(this);
String string = String::cast(*this);
while (true) {
if (StringShape(string).IsCons()) {
ConsString* cons_string = ConsString::cast(string);
String* left = cons_string->first();
ConsString cons_string = ConsString::cast(string);
String left = cons_string->first();
if (left->length() > index) {
string = left;
} else {
@ -11382,14 +11387,10 @@ uint16_t SlicedString::SlicedStringGet(int index) {
return parent()->Get(offset() + index);
}
template <typename sinkchar>
void String::WriteToFlat(String* src,
sinkchar* sink,
int f,
int t) {
void String::WriteToFlat(String src, sinkchar* sink, int f, int t) {
DisallowHeapAllocation no_gc;
String* source = src;
String source = src;
int from = f;
int to = t;
while (true) {
@ -11422,8 +11423,8 @@ void String::WriteToFlat(String* src,
}
case kOneByteStringTag | kConsStringTag:
case kTwoByteStringTag | kConsStringTag: {
ConsString* cons_string = ConsString::cast(source);
String* first = cons_string->first();
ConsString cons_string = ConsString::cast(source);
String first = cons_string->first();
int boundary = first->length();
if (to - boundary >= boundary - from) {
// Right hand side is longer. Recurse over left.
@ -11443,7 +11444,7 @@ void String::WriteToFlat(String* src,
} else {
// Left hand side is longer. Recurse over right.
if (to > boundary) {
String* second = cons_string->second();
String second = cons_string->second();
// When repeatedly appending to a string, we get a cons string that
// is unbalanced to the left, a list, essentially. We inline the
// common case of sequential one-byte right child.
@ -11467,7 +11468,7 @@ void String::WriteToFlat(String* src,
}
case kOneByteStringTag | kSlicedStringTag:
case kTwoByteStringTag | kSlicedStringTag: {
SlicedString* slice = SlicedString::cast(source);
SlicedString slice = SlicedString::cast(source);
unsigned offset = slice->offset();
WriteToFlat(slice->parent(), sink, from + offset, to + offset);
return;
@ -11537,8 +11538,8 @@ Handle<FixedArray> String::CalculateLineEnds(Isolate* isolate,
namespace {
template <typename sinkchar>
void WriteFixedArrayToFlat(FixedArray fixed_array, int length,
String* separator, sinkchar* sink, int sink_length) {
void WriteFixedArrayToFlat(FixedArray fixed_array, int length, String separator,
sinkchar* sink, int sink_length) {
DisallowHeapAllocation no_allocation;
CHECK_GT(length, 0);
CHECK_LE(length, fixed_array->length());
@ -11597,7 +11598,7 @@ void WriteFixedArrayToFlat(FixedArray fixed_array, int length,
num_separators = 0;
} else {
DCHECK(element->IsString());
String* string = String::cast(element);
String string = String::cast(element);
const int string_length = string->length();
DCHECK(string_length == 0 || sink < sink_end);
@ -11624,8 +11625,8 @@ Address JSArray::ArrayJoinConcatToSequentialString(Isolate* isolate,
DisallowHeapAllocation no_allocation;
DisallowJavascriptExecution no_js(isolate);
FixedArray fixed_array = FixedArray::cast(ObjectPtr(raw_fixed_array));
String* separator = reinterpret_cast<String*>(raw_separator);
String* dest = reinterpret_cast<String*>(raw_dest);
String separator = String::cast(ObjectPtr(raw_separator));
String dest = String::cast(ObjectPtr(raw_dest));
DCHECK(fixed_array->IsFixedArray());
DCHECK(StringShape(dest).IsSequentialOneByte() ||
StringShape(dest).IsSequentialTwoByte());
@ -11691,10 +11692,10 @@ class StringComparator {
public:
State() : is_one_byte_(true), length_(0), buffer8_(nullptr) {}
void Init(String* string) {
ConsString* cons_string = String::VisitFlat(this, string);
void Init(String string) {
ConsString cons_string = String::VisitFlat(this, string);
iter_.Reset(cons_string);
if (cons_string != nullptr) {
if (!cons_string.is_null()) {
int offset;
string = iter_.Next(&offset);
String::VisitFlat(this, string, offset);
@ -11727,9 +11728,9 @@ class StringComparator {
}
// Advance state.
int offset;
String* next = iter_.Next(&offset);
String next = iter_.Next(&offset);
DCHECK_EQ(0, offset);
DCHECK_NOT_NULL(next);
DCHECK(!next.is_null());
String::VisitFlat(this, next);
}
@ -11755,7 +11756,7 @@ class StringComparator {
return RawStringComparator<Chars1, Chars2>::compare(a, b, to_check);
}
bool Equals(String* string_1, String* string_2) {
bool Equals(String string_1, String string_2) {
int length = string_1->length();
state_1_.Init(string_1);
state_2_.Init(string_2);
@ -11793,8 +11794,7 @@ class StringComparator {
DISALLOW_COPY_AND_ASSIGN(StringComparator);
};
bool String::SlowEquals(String* other) {
bool String::SlowEquals(String other) {
DisallowHeapAllocation no_gc;
// Fast check: negative check with lengths.
int len = length();
@ -11806,7 +11806,7 @@ bool String::SlowEquals(String* other) {
if (this->IsThinString() || other->IsThinString()) {
if (other->IsThinString()) other = ThinString::cast(other)->actual();
if (this->IsThinString()) {
return ThinString::cast(this)->actual()->Equals(other);
return ThinString::cast(*this)->actual()->Equals(other);
} else {
return this->Equals(other);
}
@ -11837,13 +11837,13 @@ bool String::SlowEquals(String* other) {
if (this->Get(0) != other->Get(0)) return false;
if (IsSeqOneByteString() && other->IsSeqOneByteString()) {
const uint8_t* str1 = SeqOneByteString::cast(this)->GetChars();
const uint8_t* str1 = SeqOneByteString::cast(*this)->GetChars();
const uint8_t* str2 = SeqOneByteString::cast(other)->GetChars();
return CompareRawStringContents(str1, str2, len);
}
StringComparator comparator;
return comparator.Equals(this, other);
return comparator.Equals(*this, other);
}
bool String::SlowEquals(Isolate* isolate, Handle<String> one,
@ -12374,7 +12374,7 @@ uint32_t String::ComputeAndSetHash(Isolate* isolate) {
// Store the hash code in the object.
uint32_t field =
IteratingStringHasher::Hash(this, isolate->heap()->HashSeed());
IteratingStringHasher::Hash(*this, isolate->heap()->HashSeed());
set_hash_field(field);
// Check the hash code is there.
@ -12388,7 +12388,7 @@ uint32_t String::ComputeAndSetHash(Isolate* isolate) {
bool String::ComputeArrayIndex(uint32_t* index) {
int length = this->length();
if (length == 0 || length > kMaxArrayIndexSize) return false;
StringCharacterStream stream(this);
StringCharacterStream stream(*this);
return StringToArrayIndex(&stream, index);
}
@ -12530,14 +12530,13 @@ uint32_t StringHasher::ComputeUtf8Hash(Vector<const char> chars, uint64_t seed,
return hasher.GetHashField();
}
void IteratingStringHasher::VisitConsString(ConsString* cons_string) {
void IteratingStringHasher::VisitConsString(ConsString cons_string) {
// Run small ConsStrings through ConsStringIterator.
if (cons_string->length() < 64) {
ConsStringIterator iter(cons_string);
int offset;
String* string;
while (nullptr != (string = iter.Next(&offset))) {
for (String string = iter.Next(&offset); !string.is_null();
string = iter.Next(&offset)) {
DCHECK_EQ(0, offset);
String::VisitFlat(this, string, 0);
}
@ -12559,7 +12558,6 @@ void IteratingStringHasher::VisitConsString(ConsString* cons_string) {
}
}
void String::PrintOn(FILE* file) {
int length = this->length();
for (int i = 0; i < length; i++) {
@ -13702,7 +13700,7 @@ bool GetPositionInfoSlow(const Script* script, int position,
if (!script->source()->IsString()) return false;
if (position < 0) position = 0;
String* source_string = String::cast(script->source());
String source_string = String::cast(script->source());
int line = 0;
int line_start = 0;
int len = source_string->length();
@ -13785,7 +13783,7 @@ bool Script::GetPositionInfo(int position, PositionInfo* info,
info->line_end = SMI_VALUE(ends->get(info->line));
if (info->line_end > 0) {
DCHECK(source()->IsString());
String* src = String::cast(source());
String src = String::cast(source());
if (src->length() >= info->line_end &&
src->Get(info->line_end - 1) == '\r') {
info->line_end--;
@ -14059,9 +14057,9 @@ CoverageInfo SharedFunctionInfo::GetCoverageInfo() const {
return CoverageInfo::cast(GetDebugInfo()->coverage_info());
}
String* SharedFunctionInfo::DebugName() {
String SharedFunctionInfo::DebugName() {
DisallowHeapAllocation no_gc;
String* function_name = Name();
String function_name = Name();
if (function_name->length() > 0) return function_name;
return inferred_name();
}
@ -14230,14 +14228,14 @@ std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v) {
// Get the source for the script which this function came from.
// Don't use String::cast because we don't want more assertion errors while
// we are already creating a stack dump.
String* script_source =
reinterpret_cast<String*>(Script::cast(s->script())->source());
String script_source =
String::unchecked_cast(Script::cast(s->script())->source());
if (!script_source->LooksValid()) return os << "<Invalid Source>";
if (!s->is_toplevel()) {
os << "function ";
String* name = s->Name();
String name = s->Name();
if (name->length() > 0) {
name->PrintUC16(os);
}
@ -16232,7 +16230,7 @@ bool JSObject::IsDroppableApiWrapper() {
const char* Symbol::PrivateSymbolToName() const {
ReadOnlyRoots roots = GetReadOnlyRoots();
#define SYMBOL_CHECK_AND_PRINT(_, name) \
if (this == roots.name()) return #name;
if (*this == roots.name()) return #name;
PRIVATE_SYMBOL_LIST_GENERATOR(SYMBOL_CHECK_AND_PRINT, /* not used */)
#undef SYMBOL_CHECK_AND_PRINT
return "UNKNOWN";
@ -16292,7 +16290,7 @@ class StringSharedKey : public HashTableKey {
if (language_mode != language_mode_) return false;
int position = Smi::ToInt(other_array->get(3));
if (position != position_) return false;
String* source = String::cast(other_array->get(1));
String source = String::cast(other_array->get(1));
return source->Equals(*source_);
}
@ -17096,7 +17094,7 @@ class TwoCharHashTableKey : public StringTableKey {
: StringTableKey(ComputeHashField(c1, c2, seed)), c1_(c1), c2_(c2) {}
bool IsMatch(Object* o) override {
String* other = String::cast(o);
String other = String::cast(o);
if (other->length() != 2) return false;
if (other->Get(0) != c1_) return false;
return other->Get(1) == c2_;
@ -17167,9 +17165,9 @@ void StringTable::EnsureCapacityForDeserialization(Isolate* isolate,
namespace {
template <class StringClass>
void MigrateExternalStringResource(Isolate* isolate, String* from, String* to) {
StringClass* cast_from = StringClass::cast(from);
StringClass* cast_to = StringClass::cast(to);
void MigrateExternalStringResource(Isolate* isolate, String from, String to) {
StringClass cast_from = StringClass::cast(from);
StringClass cast_to = StringClass::cast(to);
const typename StringClass::Resource* to_resource = cast_to->resource();
if (to_resource == nullptr) {
// |to| is a just-created internalized copy of |from|. Migrate the resource.
@ -17185,7 +17183,7 @@ void MigrateExternalStringResource(Isolate* isolate, String* from, String* to) {
}
}
void MakeStringThin(String* string, String* internalized, Isolate* isolate) {
void MakeStringThin(String string, String internalized, Isolate* isolate) {
DCHECK_NE(string, internalized);
DCHECK(internalized->IsInternalizedString());
@ -17212,7 +17210,7 @@ void MakeStringThin(String* string, String* internalized, Isolate* isolate) {
: isolate->factory()->thin_string_map();
DCHECK_GE(old_size, ThinString::kSize);
string->synchronized_set_map(*map);
ThinString* thin = ThinString::cast(string);
ThinString thin = ThinString::cast(string);
thin->set_actual(internalized);
Address thin_end = thin->address() + ThinString::kSize;
int size_delta = old_size - ThinString::kSize;
@ -17313,7 +17311,7 @@ namespace {
class StringTableNoAllocateKey : public StringTableKey {
public:
StringTableNoAllocateKey(String* string, uint64_t seed)
StringTableNoAllocateKey(String string, uint64_t seed)
: StringTableKey(0), string_(string) {
StringShape shape(string);
one_byte_ = shape.HasOnlyOneByteChars();
@ -17364,7 +17362,7 @@ class StringTableNoAllocateKey : public StringTableKey {
}
bool IsMatch(Object* otherstring) override {
String* other = String::cast(otherstring);
String other = String::cast(otherstring);
DCHECK(other->IsInternalizedString());
DCHECK(other->IsFlat());
if (Hash() != other->Hash()) return false;
@ -17426,7 +17424,7 @@ class StringTableNoAllocateKey : public StringTableKey {
}
private:
String* string_;
String string_;
bool one_byte_;
bool special_flattening_;
union {
@ -17442,9 +17440,10 @@ class StringTableNoAllocateKey : public StringTableKey {
} // namespace
// static
Object* StringTable::LookupStringIfExists_NoAllocate(Isolate* isolate,
String* string) {
Address StringTable::LookupStringIfExists_NoAllocate(Isolate* isolate,
Address raw_string) {
DisallowHeapAllocation no_gc;
String string = String::cast(ObjectPtr(raw_string));
Heap* heap = isolate->heap();
StringTable table = heap->string_table();
@ -17461,35 +17460,34 @@ Object* StringTable::LookupStringIfExists_NoAllocate(Isolate* isolate,
!String::ArrayIndexValueBits::is_valid(ResultSentinel::kNotFound));
if (Name::ContainsCachedArrayIndex(hash)) {
return Smi::FromInt(String::ArrayIndexValueBits::decode(hash));
return Smi::FromInt(String::ArrayIndexValueBits::decode(hash)).ptr();
}
if ((hash & Name::kIsNotArrayIndexMask) == 0) {
// It is an indexed, but it's not cached.
return Smi::FromInt(ResultSentinel::kUnsupported);
return Smi::FromInt(ResultSentinel::kUnsupported).ptr();
}
DCHECK(!string->IsInternalizedString());
int entry = table->FindEntry(ReadOnlyRoots(isolate), &key, key.Hash());
if (entry != kNotFound) {
String* internalized = String::cast(table->KeyAt(entry));
String internalized = String::cast(table->KeyAt(entry));
if (FLAG_thin_strings) {
MakeStringThin(string, internalized, isolate);
}
return internalized;
return internalized.ptr();
}
// A string that's not an array index, and not in the string table,
// cannot have been used as a property name before.
return Smi::FromInt(ResultSentinel::kNotFound);
return Smi::FromInt(ResultSentinel::kNotFound).ptr();
}
String* StringTable::ForwardStringIfExists(Isolate* isolate,
StringTableKey* key,
String* string) {
String StringTable::ForwardStringIfExists(Isolate* isolate, StringTableKey* key,
String string) {
Handle<StringTable> table = isolate->factory()->string_table();
int entry = table->FindEntry(isolate, key);
if (entry == kNotFound) return nullptr;
if (entry == kNotFound) return String();
String* canonical = String::cast(table->KeyAt(entry));
String canonical = String::cast(table->KeyAt(entry));
if (canonical != string) MakeStringThin(string, canonical, isolate);
return canonical;
}

View File

@ -549,8 +549,8 @@ typedef ScriptContextTable ScriptContextTableArgType;
typedef SharedFunctionInfo* SharedFunctionInfoArgType;
typedef SimpleNumberDictionary SimpleNumberDictionaryArgType;
typedef Smi SmiArgType;
typedef String* StringArgType;
typedef Symbol* SymbolArgType;
typedef String StringArgType;
typedef Symbol SymbolArgType;
typedef TemplateList TemplateListArgType;
typedef WasmInstanceObject* WasmInstanceObjectArgType;
typedef WasmMemoryObject* WasmMemoryObjectArgType;
@ -1443,13 +1443,13 @@ class Oddball: public HeapObject {
inline void set_to_number_raw_as_bits(uint64_t bits);
// [to_string]: Cached to_string computed at startup.
DECL_ACCESSORS(to_string, String)
DECL_ACCESSORS2(to_string, String)
// [to_number]: Cached to_number computed at startup.
DECL_ACCESSORS(to_number, Object)
// [typeof]: Cached type_of computed at startup.
DECL_ACCESSORS(type_of, String)
DECL_ACCESSORS2(type_of, String)
inline byte kind() const;
inline void set_kind(byte kind);
@ -1564,7 +1564,7 @@ class FeedbackCell : public Struct {
class PropertyCell : public HeapObject {
public:
// [name]: the name of the global property.
DECL_ACCESSORS(name, Name)
DECL_ACCESSORS2(name, Name)
// [property_details]: details of the global property.
DECL_ACCESSORS(property_details_raw, Object)
// [value]: value of the global property.

View File

@ -23,7 +23,7 @@ CAST_ACCESSOR(AccessCheckInfo)
CAST_ACCESSOR(InterceptorInfo)
CAST_ACCESSOR(CallHandlerInfo)
ACCESSORS(AccessorInfo, name, Name, kNameOffset)
ACCESSORS2(AccessorInfo, name, Name, kNameOffset)
SMI_ACCESSORS(AccessorInfo, flags, kFlagsOffset)
ACCESSORS(AccessorInfo, expected_receiver_type, Object,
kExpectedReceiverTypeOffset)

View File

@ -24,7 +24,7 @@ namespace internal {
// This shadows the accessor in the prototype.
class AccessorInfo : public Struct {
public:
DECL_ACCESSORS(name, Name)
DECL_ACCESSORS2(name, Name)
DECL_INT_ACCESSORS(flags)
DECL_ACCESSORS(expected_receiver_type, Object)
// This directly points at a foreign C function to be used from the runtime.

View File

@ -27,11 +27,11 @@ CompilationCacheTable::CompilationCacheTable(Address ptr)
NEVER_READ_ONLY_SPACE_IMPL(CompilationCacheTable)
CAST_ACCESSOR2(CompilationCacheTable)
uint32_t CompilationCacheShape::RegExpHash(String* string, Smi flags) {
uint32_t CompilationCacheShape::RegExpHash(String string, Smi flags) {
return string->Hash() + flags->value();
}
uint32_t CompilationCacheShape::StringSharedHash(String* source,
uint32_t CompilationCacheShape::StringSharedHash(String source,
SharedFunctionInfo* shared,
LanguageMode language_mode,
int position) {
@ -59,7 +59,7 @@ uint32_t CompilationCacheShape::HashForObject(Isolate* isolate,
if (val->map() == val->GetReadOnlyRoots().fixed_cow_array_map()) {
DCHECK_EQ(4, val->length());
SharedFunctionInfo* shared = SharedFunctionInfo::cast(val->get(0));
String* source = String::cast(val->get(1));
String source = String::cast(val->get(1));
int language_unchecked = Smi::ToInt(val->get(2));
DCHECK(is_valid_language_mode(language_unchecked));
LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked);

View File

@ -24,9 +24,9 @@ class CompilationCacheShape : public BaseShape<HashTableKey*> {
return key->Hash();
}
static inline uint32_t RegExpHash(String* string, Smi flags);
static inline uint32_t RegExpHash(String string, Smi flags);
static inline uint32_t StringSharedHash(String* source,
static inline uint32_t StringSharedHash(String source,
SharedFunctionInfo* shared,
LanguageMode language_mode,
int position);

View File

@ -48,7 +48,7 @@ SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionOffset)
ACCESSORS(BreakPointInfo, break_points, Object, kBreakPointsOffset)
SMI_ACCESSORS(BreakPoint, id, kIdOffset)
ACCESSORS(BreakPoint, condition, String, kConditionOffset)
ACCESSORS2(BreakPoint, condition, String, kConditionOffset)
bool DebugInfo::HasInstrumentedBytecodeArray() {
DCHECK_EQ(debug_bytecode_array()->IsBytecodeArray(),

View File

@ -267,7 +267,7 @@ class CoverageInfo : public FixedArray {
class BreakPoint : public Tuple2 {
public:
DECL_INT_ACCESSORS(id)
DECL_ACCESSORS(condition, String)
DECL_ACCESSORS2(condition, String)
DECL_CAST(BreakPoint)

View File

@ -69,7 +69,7 @@ class DescriptorArray : public HeapObject {
Handle<FixedArray> indices);
// Accessors for fetching instance descriptor at descriptor number.
inline Name* GetKey(int descriptor_number);
inline Name GetKey(int descriptor_number);
inline Object* GetStrongValue(int descriptor_number);
inline void SetValue(int descriptor_number, Object* value);
inline MaybeObject GetValue(int descriptor_number);
@ -77,13 +77,13 @@ class DescriptorArray : public HeapObject {
inline int GetFieldIndex(int descriptor_number);
inline FieldType GetFieldType(int descriptor_number);
inline Name* GetSortedKey(int descriptor_number);
inline Name GetSortedKey(int descriptor_number);
inline int GetSortedKeyIndex(int descriptor_number);
inline void SetSortedKey(int pointer, int descriptor_number);
// Accessor for complete descriptor.
inline void Set(int descriptor_number, Descriptor* desc);
inline void Set(int descriptor_number, Name* key, MaybeObject value,
inline void Set(int descriptor_number, Name key, MaybeObject value,
PropertyDetails details);
void Replace(int descriptor_number, Descriptor* descriptor);
@ -112,12 +112,12 @@ class DescriptorArray : public HeapObject {
void Sort();
// Search the instance descriptors for given name.
V8_INLINE int Search(Name* name, int number_of_own_descriptors);
V8_INLINE int Search(Name* name, Map map);
V8_INLINE int Search(Name name, int number_of_own_descriptors);
V8_INLINE int Search(Name name, Map map);
// As the above, but uses DescriptorLookupCache and updates it when
// necessary.
V8_INLINE int SearchWithCache(Isolate* isolate, Name* name, Map map);
V8_INLINE int SearchWithCache(Isolate* isolate, Name name, Map map);
bool IsEqualUpTo(DescriptorArray* desc, int nof_descriptors);

View File

@ -199,7 +199,7 @@ class NameDictionary
static const int kEntryDetailsIndex = 2;
static const int kInitialCapacity = 2;
inline Name* NameAt(int entry);
inline Name NameAt(int entry);
inline void set_hash(int hash);
inline int hash() const;
@ -236,7 +236,7 @@ class GlobalDictionary
inline PropertyCell* CellAt(int entry);
inline void SetEntry(Isolate* isolate, int entry, Object* key, Object* value,
PropertyDetails details);
inline Name* NameAt(int entry);
inline Name NameAt(int entry);
inline void ValueAtPut(int entry, Object* value);
OBJECT_CONSTRUCTORS(

View File

@ -470,7 +470,7 @@ class ArrayList : public FixedArray {
enum SearchMode { ALL_ENTRIES, VALID_ENTRIES };
template <SearchMode search_mode, typename T>
inline int Search(T* array, Name* name, int valid_entries = 0,
inline int Search(T* array, Name name, int valid_entries = 0,
int* out_insertion_index = nullptr);
// ByteArray represents fixed sized byte arrays. Used for the relocation info

View File

@ -60,6 +60,18 @@ bool ObjectPtr::ToUint32(uint32_t* value) const {
return reinterpret_cast<Object*>(ptr())->ToUint32(value);
}
bool ObjectPtr::FilterKey(PropertyFilter filter) {
return reinterpret_cast<Object*>(ptr())->FilterKey(filter);
}
Object* ObjectPtr::GetHash() {
return reinterpret_cast<Object*>(ptr())->GetHash();
}
bool ObjectPtr::ToArrayIndex(uint32_t* index) const {
return reinterpret_cast<Object*>(ptr())->ToArrayIndex(index);
}
void ObjectPtr::ShortPrint(FILE* out) {
return reinterpret_cast<Object*>(ptr())->ShortPrint(out);
}
@ -115,6 +127,25 @@ void HeapObjectPtr::set_map_word(MapWord map_word) {
reinterpret_cast<Object*>(map_word.value_));
}
void HeapObjectPtr::synchronized_set_map(Map value) {
if (!value.is_null()) {
#ifdef VERIFY_HEAP
Heap::FromWritableHeapObject(this)->VerifyObjectLayoutChange(*this, value);
#endif
}
synchronized_set_map_word(MapWord::FromMap(value));
if (!value.is_null()) {
// TODO(1600) We are passing kNullAddress as a slot because maps can never
// be on an evacuation candidate.
MarkingBarrier(this, ObjectSlot(kNullAddress), value);
}
}
void HeapObjectPtr::synchronized_set_map_word(MapWord map_word) {
RELEASE_WRITE_FIELD(this, kMapOffset,
reinterpret_cast<Object*>(map_word.value_));
}
WriteBarrierMode HeapObjectPtr::GetWriteBarrierMode(
const DisallowHeapAllocation& promise) {
Heap* heap = Heap::FromWritableHeapObject(this);
@ -144,6 +175,10 @@ MaybeObjectSlot HeapObjectPtr::RawMaybeWeakField(int byte_offset) const {
return MaybeObjectSlot(FIELD_ADDR(this, byte_offset));
}
Address HeapObjectPtr::GetFieldAddress(int field_offset) const {
return FIELD_ADDR(this, field_offset);
}
Heap* NeverReadOnlySpaceObjectPtr::GetHeap(const HeapObjectPtr object) {
MemoryChunk* chunk = MemoryChunk::FromAddress(object.ptr());
// Make sure we are not accessing an object in RO space.

View File

@ -63,6 +63,30 @@ class ObjectPtr {
inline bool ToInt32(int32_t* value) const;
inline bool ToUint32(uint32_t* value) const;
// ECMA-262 9.2.
bool BooleanValue(Isolate* isolate);
inline bool FilterKey(PropertyFilter filter);
// Returns the permanent hash code associated with this object. May return
// undefined if not yet created.
inline Object* GetHash();
// Returns the permanent hash code associated with this object depending on
// the actual object type. May create and store a hash code if needed and none
// exists.
Smi GetOrCreateHash(Isolate* isolate);
// Checks whether this object has the same value as the given one. This
// function is implemented according to ES5, section 9.12 and can be used
// to implement the Object.is function.
V8_EXPORT_PRIVATE bool SameValue(Object* other);
// Tries to convert an object to an array index. Returns true and sets the
// output parameter if it succeeds. Equivalent to ToArrayLength, but does not
// allow kMaxUInt32.
V8_WARN_UNUSED_RESULT inline bool ToArrayIndex(uint32_t* index) const;
#ifdef VERIFY_HEAP
void ObjectVerify(Isolate* isolate) {
reinterpret_cast<Object*>(ptr())->ObjectVerify(isolate);
@ -72,6 +96,7 @@ class ObjectPtr {
#endif
inline void ShortPrint(FILE* out = stdout);
void ShortPrint(std::ostream& os); // NOLINT
inline void Print();
inline void Print(std::ostream& os);
@ -110,6 +135,10 @@ class HeapObjectPtr : public ObjectPtr {
inline MapWord map_word() const;
inline void set_map_word(MapWord map_word);
// Set the map using release store
inline void synchronized_set_map(Map value);
inline void synchronized_set_map_word(MapWord map_word);
inline WriteBarrierMode GetWriteBarrierMode(
const DisallowHeapAllocation& promise);
@ -154,6 +183,8 @@ class HeapObjectPtr : public ObjectPtr {
static const int kMapOffset = HeapObject::kMapOffset;
inline Address GetFieldAddress(int field_offset) const;
protected:
// Special-purpose constructor for subclasses that have fast paths where
// their ptr() is a Smi.

View File

@ -148,7 +148,7 @@ void ToUpperWithSharpS(const Vector<const Char>& src,
}
}
inline int FindFirstUpperOrNonAscii(String* s, int length) {
inline int FindFirstUpperOrNonAscii(String s, int length) {
for (int index = 0; index < length; ++index) {
uint16_t ch = s->Get(index);
if (V8_UNLIKELY(IsASCIIUpper(ch) || ch & ~0x7F)) {
@ -248,7 +248,7 @@ MaybeHandle<String> LocaleConvertCase(Isolate* isolate, Handle<String> s,
// strings and does not allocate. Note that {src} could still be, e.g., a
// one-byte sliced string with a two-byte parent string.
// Called from TF builtins.
String* Intl::ConvertOneByteToLower(String* src, String* dst) {
String Intl::ConvertOneByteToLower(String src, String dst) {
DCHECK_EQ(src->length(), dst->length());
DCHECK(src->HasOnlyOneByteChars());
DCHECK(src->IsFlat());

View File

@ -261,7 +261,7 @@ class Intl {
static const uint8_t* ToLatin1LowerTable();
static String* ConvertOneByteToLower(String* src, String* dst);
static String ConvertOneByteToLower(String src, String dst);
};
} // namespace internal

View File

@ -28,7 +28,7 @@ inline JSV8BreakIterator::Type JSV8BreakIterator::type() const {
return static_cast<JSV8BreakIterator::Type>(Smi::ToInt(value));
}
ACCESSORS(JSV8BreakIterator, locale, String, kLocaleOffset)
ACCESSORS2(JSV8BreakIterator, locale, String, kLocaleOffset)
ACCESSORS(JSV8BreakIterator, break_iterator, Managed<icu::BreakIterator>,
kBreakIteratorOffset)
ACCESSORS(JSV8BreakIterator, unicode_string, Managed<icu::UnicodeString>,

View File

@ -164,8 +164,8 @@ Handle<Object> JSV8BreakIterator::Next(
break_iterator->break_iterator()->raw()->next());
}
String* JSV8BreakIterator::BreakType(Isolate* isolate,
Handle<JSV8BreakIterator> break_iterator) {
String JSV8BreakIterator::BreakType(Isolate* isolate,
Handle<JSV8BreakIterator> break_iterator) {
int32_t status = break_iterator->break_iterator()->raw()->getRuleStatus();
// Keep return values in sync with JavaScript BreakType enum.
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {

View File

@ -47,8 +47,8 @@ class JSV8BreakIterator : public JSObject {
Handle<JSV8BreakIterator> break_iterator);
static Handle<Object> Next(Isolate* isolate,
Handle<JSV8BreakIterator> break_iterator);
static String* BreakType(Isolate* isolate,
Handle<JSV8BreakIterator> break_iterator);
static String BreakType(Isolate* isolate,
Handle<JSV8BreakIterator> break_iterator);
enum class Type { CHARACTER, WORD, SENTENCE, LINE, COUNT };
inline void set_type(Type type);
@ -60,7 +60,7 @@ class JSV8BreakIterator : public JSObject {
DECL_PRINTER(JSV8BreakIterator)
DECL_VERIFIER(JSV8BreakIterator)
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(break_iterator, Managed<icu::BreakIterator>)
DECL_ACCESSORS(unicode_string, Managed<icu::UnicodeString>)
DECL_ACCESSORS(bound_adopt_text, Object)

View File

@ -19,7 +19,7 @@ namespace v8 {
namespace internal {
// Base list format accessors.
ACCESSORS(JSListFormat, locale, String, kLocaleOffset)
ACCESSORS2(JSListFormat, locale, String, kLocaleOffset)
ACCESSORS(JSListFormat, icu_formatter, Managed<icu::ListFormatter>,
kICUFormatterOffset)
SMI_ACCESSORS(JSListFormat, flags, kFlagsOffset)

View File

@ -57,7 +57,7 @@ class JSListFormat : public JSObject {
DECL_CAST(JSListFormat)
// ListFormat accessors.
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_formatter, Managed<icu::ListFormatter>)
// Style: identifying the relative time format style used.

View File

@ -24,7 +24,7 @@ ACCESSORS(JSLocale, language, Object, kLanguageOffset);
ACCESSORS(JSLocale, script, Object, kScriptOffset);
ACCESSORS(JSLocale, region, Object, kRegionOffset);
ACCESSORS(JSLocale, base_name, Object, kBaseNameOffset);
ACCESSORS(JSLocale, locale, String, kLocaleOffset);
ACCESSORS2(JSLocale, locale, String, kLocaleOffset);
// Unicode extension accessors.
ACCESSORS(JSLocale, calendar, Object, kCalendarOffset);

View File

@ -313,7 +313,7 @@ MaybeHandle<JSLocale> JSLocale::Initialize(Isolate* isolate,
namespace {
Handle<String> MorphLocale(Isolate* isolate, String* language_tag,
Handle<String> MorphLocale(Isolate* isolate, String language_tag,
int32_t (*morph_func)(const char*, char*, int32_t,
UErrorCode*)) {
Factory* factory = isolate->factory();
@ -348,11 +348,11 @@ Handle<String> MorphLocale(Isolate* isolate, String* language_tag,
} // namespace
Handle<String> JSLocale::Maximize(Isolate* isolate, String* locale) {
Handle<String> JSLocale::Maximize(Isolate* isolate, String locale) {
return MorphLocale(isolate, locale, uloc_addLikelySubtags);
}
Handle<String> JSLocale::Minimize(Isolate* isolate, String* locale) {
Handle<String> JSLocale::Minimize(Isolate* isolate, String locale) {
return MorphLocale(isolate, locale, uloc_minimizeSubtags);
}

View File

@ -29,8 +29,8 @@ class JSLocale : public JSObject {
Handle<JSLocale> locale_holder,
Handle<String> locale,
Handle<JSReceiver> options);
static Handle<String> Maximize(Isolate* isolate, String* locale);
static Handle<String> Minimize(Isolate* isolate, String* locale);
static Handle<String> Maximize(Isolate* isolate, String locale);
static Handle<String> Minimize(Isolate* isolate, String locale);
Handle<String> CaseFirstAsString() const;
Handle<String> NumericAsString() const;
@ -43,7 +43,7 @@ class JSLocale : public JSObject {
DECL_ACCESSORS(script, Object)
DECL_ACCESSORS(region, Object)
DECL_ACCESSORS(base_name, Object)
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS2(locale, String)
// Unicode extension accessors.
DECL_ACCESSORS(calendar, Object)

View File

@ -18,7 +18,7 @@
namespace v8 {
namespace internal {
ACCESSORS(JSNumberFormat, locale, String, kLocaleOffset)
ACCESSORS2(JSNumberFormat, locale, String, kLocaleOffset)
ACCESSORS(JSNumberFormat, icu_number_format, Managed<icu::NumberFormat>,
kICUNumberFormatOffset)
ACCESSORS(JSNumberFormat, bound_format, Object, kBoundFormatOffset)

View File

@ -122,7 +122,7 @@ class JSNumberFormat : public JSObject {
STATIC_ASSERT(CurrencyDisplay::SYMBOL <= CurrencyDisplayBits::kMax);
STATIC_ASSERT(CurrencyDisplay::NAME <= CurrencyDisplayBits::kMax);
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_number_format, Managed<icu::NumberFormat>)
DECL_ACCESSORS(bound_format, Object)
DECL_INT_ACCESSORS(flags)

View File

@ -892,7 +892,7 @@ ACCESSORS(JSAsyncFromSyncIterator, sync_iterator, JSReceiver,
kSyncIteratorOffset)
ACCESSORS(JSAsyncFromSyncIterator, next, Object, kNextOffset)
ACCESSORS(JSStringIterator, string, String, kStringOffset)
ACCESSORS2(JSStringIterator, string, String, kStringOffset)
SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
} // namespace internal

View File

@ -188,7 +188,7 @@ class JSReceiver : public HeapObject, public NeverReadOnlySpaceObject {
Handle<JSReceiver> object);
// Returns the class name ([[Class]] property in the specification).
V8_EXPORT_PRIVATE String* class_name();
V8_EXPORT_PRIVATE String class_name();
// Returns the constructor (the function that was used to instantiate the
// object).
@ -1391,7 +1391,7 @@ class JSStringIterator : public JSObject {
DECL_CAST(JSStringIterator)
// [string]: the [[IteratedString]] inobject property.
DECL_ACCESSORS(string, String)
DECL_ACCESSORS2(string, String)
// [index]: The [[StringIteratorNextIndex]] inobject property.
inline int index() const;

View File

@ -19,7 +19,7 @@
namespace v8 {
namespace internal {
ACCESSORS(JSPluralRules, locale, String, kLocaleOffset)
ACCESSORS2(JSPluralRules, locale, String, kLocaleOffset)
SMI_ACCESSORS(JSPluralRules, flags, kFlagsOffset)
ACCESSORS(JSPluralRules, icu_plural_rules, Managed<icu::PluralRules>,
kICUPluralRulesOffset)

View File

@ -80,7 +80,7 @@ class JSPluralRules : public JSObject {
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_PLURAL_RULES_FIELDS)
#undef JS_PLURAL_RULES_FIELDS
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS2(locale, String)
DECL_INT_ACCESSORS(flags)
DECL_ACCESSORS(icu_plural_rules, Managed<icu::PluralRules>)
DECL_ACCESSORS(icu_decimal_format, Managed<icu::DecimalFormat>)

View File

@ -49,10 +49,10 @@ JSRegExp::Flags JSRegExp::GetFlags() {
return Flags(smi->value());
}
String* JSRegExp::Pattern() {
String JSRegExp::Pattern() {
DCHECK(this->data()->IsFixedArray());
Object* data = this->data();
String* pattern = String::cast(FixedArray::cast(data)->get(kSourceIndex));
String pattern = String::cast(FixedArray::cast(data)->get(kSourceIndex));
return pattern;
}

View File

@ -17,8 +17,8 @@ namespace internal {
ACCESSORS(JSRegExpStringIterator, iterating_regexp, Object,
kIteratingRegExpOffset)
ACCESSORS(JSRegExpStringIterator, iterating_string, String,
kIteratedStringOffset)
ACCESSORS2(JSRegExpStringIterator, iterating_string, String,
kIteratedStringOffset)
SMI_ACCESSORS(JSRegExpStringIterator, flags, kFlagsOffset)
BOOL_ACCESSORS(JSRegExpStringIterator, flags, done, kDoneBit)

View File

@ -19,7 +19,7 @@ class JSRegExpStringIterator : public JSObject {
DECL_ACCESSORS(iterating_regexp, Object)
// [string]: The [[IteratedString]] internal property.
DECL_ACCESSORS(iterating_string, String)
DECL_ACCESSORS2(iterating_string, String)
DECL_INT_ACCESSORS(flags)

View File

@ -96,7 +96,7 @@ class JSRegExp : public JSObject {
// Number of captures (without the match itself).
inline int CaptureCount();
inline Flags GetFlags();
inline String* Pattern();
inline String Pattern();
inline Object* CaptureNameMap();
inline Object* DataAt(int index);
// Set implementation data after the object has been prepared.

View File

@ -19,7 +19,7 @@ namespace v8 {
namespace internal {
// Base relative time format accessors.
ACCESSORS(JSRelativeTimeFormat, locale, String, kLocaleOffset)
ACCESSORS2(JSRelativeTimeFormat, locale, String, kLocaleOffset)
ACCESSORS(JSRelativeTimeFormat, icu_formatter,
Managed<icu::RelativeDateTimeFormatter>, kICUFormatterOffset)
SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset)

View File

@ -55,7 +55,7 @@ class JSRelativeTimeFormat : public JSObject {
DECL_CAST(JSRelativeTimeFormat)
// RelativeTimeFormat accessors.
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_formatter, Managed<icu::RelativeDateTimeFormatter>)

View File

@ -19,7 +19,7 @@ namespace v8 {
namespace internal {
// Base segmenter accessors.
ACCESSORS(JSSegmenter, locale, String, kLocaleOffset)
ACCESSORS2(JSSegmenter, locale, String, kLocaleOffset)
ACCESSORS(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>,
kICUBreakIteratorOffset)
SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset)

View File

@ -48,7 +48,7 @@ class JSSegmenter : public JSObject {
DECL_CAST(JSSegmenter)
// Segmenter accessors.
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS2(locale, String)
DECL_ACCESSORS(icu_break_iterator, Managed<icu::BreakIterator>)

View File

@ -269,7 +269,7 @@ class ModuleInfo : public FixedArray {
// Accessors for [regular_exports].
int RegularExportCount() const;
String* RegularExportLocalName(int i) const;
String RegularExportLocalName(int i) const;
int RegularExportCellIndex(int i) const;
FixedArray RegularExportExportNames(int i) const;

View File

@ -17,8 +17,11 @@
namespace v8 {
namespace internal {
CAST_ACCESSOR(Name)
CAST_ACCESSOR(Symbol)
OBJECT_CONSTRUCTORS_IMPL(Name, HeapObjectPtr)
OBJECT_CONSTRUCTORS_IMPL(Symbol, Name)
CAST_ACCESSOR2(Name)
CAST_ACCESSOR2(Symbol)
ACCESSORS(Symbol, name, Object, kNameOffset)
INT_ACCESSORS(Symbol, flags, kFlagsOffset)
@ -56,13 +59,13 @@ void Name::set_hash_field(uint32_t value) {
WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
}
bool Name::Equals(Name* other) {
if (other == this) return true;
bool Name::Equals(Name other) {
if (other == *this) return true;
if ((this->IsInternalizedString() && other->IsInternalizedString()) ||
this->IsSymbol() || other->IsSymbol()) {
return false;
}
return String::cast(this)->SlowEquals(String::cast(other));
return String::cast(*this)->SlowEquals(String::cast(other));
}
bool Name::Equals(Isolate* isolate, Handle<Name> one, Handle<Name> two) {
@ -88,27 +91,27 @@ uint32_t Name::Hash() {
// Slow case: compute hash code and set it. Has to be a string.
// Also the string must be writable, because read-only strings will have their
// hash values precomputed.
return String::cast(this)->ComputeAndSetHash(
return String::cast(*this)->ComputeAndSetHash(
Heap::FromWritableHeapObject(this)->isolate());
}
bool Name::IsInterestingSymbol() const {
return IsSymbol() && Symbol::cast(this)->is_interesting_symbol();
return IsSymbol() && Symbol::cast(*this)->is_interesting_symbol();
}
bool Name::IsPrivate() {
return this->IsSymbol() && Symbol::cast(this)->is_private();
return this->IsSymbol() && Symbol::cast(*this)->is_private();
}
bool Name::IsPrivateName() {
bool is_private_name =
this->IsSymbol() && Symbol::cast(this)->is_private_name();
this->IsSymbol() && Symbol::cast(*this)->is_private_name();
DCHECK_IMPLIES(is_private_name, IsPrivate());
return is_private_name;
}
bool Name::AsArrayIndex(uint32_t* index) {
return IsString() && String::cast(this)->AsArrayIndex(index);
return IsString() && String::cast(*this)->AsArrayIndex(index);
}
// static

View File

@ -6,6 +6,7 @@
#define V8_OBJECTS_NAME_H_
#include "src/objects.h"
#include "src/objects/heap-object.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@ -15,7 +16,7 @@ namespace internal {
// The Name abstract class captures anything that can be used as a property
// name, i.e., strings and symbols. All names store a hash value.
class Name : public HeapObject {
class Name : public HeapObjectPtr {
public:
// Get and set the hash field of the name.
inline uint32_t hash_field();
@ -28,7 +29,7 @@ class Name : public HeapObject {
inline uint32_t Hash();
// Equality operations.
inline bool Equals(Name* other);
inline bool Equals(Name other);
inline static bool Equals(Isolate* isolate, Handle<Name> one,
Handle<Name> two);
@ -60,7 +61,7 @@ class Name : public HeapObject {
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToFunctionName(
Isolate* isolate, Handle<Name> name, Handle<String> prefix);
DECL_CAST(Name)
DECL_CAST2(Name)
DECL_PRINTER(Name)
void NameShortPrint();
@ -130,8 +131,7 @@ class Name : public HeapObject {
protected:
static inline bool IsHashFieldComputed(uint32_t field);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Name);
OBJECT_CONSTRUCTORS(Name, HeapObjectPtr);
};
// ES6 symbols.
@ -169,7 +169,7 @@ class Symbol : public Name {
inline bool is_private_name() const;
inline void set_is_private_name();
DECL_CAST(Symbol)
DECL_CAST2(Symbol)
// Dispatched behavior.
DECL_PRINTER(Symbol)
@ -206,7 +206,7 @@ class Symbol : public Name {
// TODO(cbruni): remove once the new maptracer is in place.
friend class Name; // For PrivateSymbolToName.
DISALLOW_IMPLICIT_CONSTRUCTORS(Symbol);
OBJECT_CONSTRUCTORS(Symbol, Name);
};
} // namespace internal

View File

@ -344,7 +344,7 @@ int OrderedHashTable<OrderedNameDictionary, 3>::FindEntry(Isolate* isolate,
DisallowHeapAllocation no_gc;
DCHECK(key->IsUniqueName());
Name* raw_key = Name::cast(key);
Name raw_key = Name::cast(key);
int entry = HashToEntry(raw_key->Hash());
while (entry != kNotFound) {
@ -711,7 +711,7 @@ int SmallOrderedHashTable<SmallOrderedNameDictionary>::FindEntry(
Isolate* isolate, Object* key) {
DisallowHeapAllocation no_gc;
DCHECK(key->IsUniqueName());
Name* raw_key = Name::cast(key);
Name raw_key = Name::cast(key);
int entry = HashToFirstEntry(raw_key->Hash());

View File

@ -33,8 +33,8 @@ class V8_EXPORT_PRIVATE RegExpMatchInfo : NON_EXPORTED_BASE(public FixedArray) {
inline void SetNumberOfCaptureRegisters(int value);
// Returns the subject string of the last match.
inline String* LastSubject();
inline void SetLastSubject(String* value);
inline String LastSubject();
inline void SetLastSubject(String value);
// Like LastSubject, but modifiable by the user.
inline Object* LastInput();

View File

@ -544,7 +544,7 @@ void ScopeInfo::SetFunctionName(Object* name) {
set(FunctionNameInfoIndex(), name);
}
void ScopeInfo::SetInferredFunctionName(String* name) {
void ScopeInfo::SetInferredFunctionName(String name) {
DCHECK(HasInferredFunctionName());
set(InferredFunctionNameIndex(), name);
}
@ -580,7 +580,7 @@ Object* ScopeInfo::InferredFunctionName() const {
return get(InferredFunctionNameIndex());
}
String* ScopeInfo::FunctionDebugName() const {
String ScopeInfo::FunctionDebugName() const {
Object* name = FunctionName();
if (name->IsString() && String::cast(name)->length() > 0) {
return String::cast(name);
@ -619,7 +619,7 @@ ModuleInfo ScopeInfo::ModuleDescriptorInfo() const {
return ModuleInfo::cast(get(ModuleInfoIndex()));
}
String* ScopeInfo::ContextLocalName(int var) const {
String ScopeInfo::ContextLocalName(int var) const {
DCHECK_LE(0, var);
DCHECK_LT(var, ContextLocalCount());
int info_index = ContextLocalNamesIndex() + var;
@ -666,7 +666,7 @@ MaybeAssignedFlag ScopeInfo::ContextLocalMaybeAssignedFlag(int var) const {
}
// static
bool ScopeInfo::VariableIsSynthetic(String* name) {
bool ScopeInfo::VariableIsSynthetic(String name) {
// There's currently no flag stored on the ScopeInfo to indicate that a
// variable is a compiler-introduced temporary. However, to avoid conflict
// with user declarations, the current temporaries like .generator_object and
@ -687,7 +687,7 @@ int ScopeInfo::ModuleIndex(Handle<String> name, VariableMode* mode,
int module_vars_count = Smi::ToInt(get(ModuleVariableCountIndex()));
int entry = ModuleVariablesIndex();
for (int i = 0; i < module_vars_count; ++i) {
String* var_name = String::cast(get(entry + kModuleVariableNameOffset));
String var_name = String::cast(get(entry + kModuleVariableNameOffset));
if (name->Equals(var_name)) {
int index;
ModuleVariable(i, nullptr, &index, mode, init_flag, maybe_assigned_flag);
@ -736,7 +736,7 @@ int ScopeInfo::ReceiverContextSlotIndex() const {
return -1;
}
int ScopeInfo::FunctionContextSlotIndex(String* name) const {
int ScopeInfo::FunctionContextSlotIndex(String name) const {
DCHECK(name->IsInternalizedString());
if (length() > 0) {
if (FunctionVariableField::decode(Flags()) == CONTEXT &&
@ -793,7 +793,7 @@ int ScopeInfo::ModuleVariablesIndex() const {
return ModuleVariableCountIndex() + 1;
}
void ScopeInfo::ModuleVariable(int i, String** name, int* index,
void ScopeInfo::ModuleVariable(int i, String* name, int* index,
VariableMode* mode,
InitializationFlag* init_flag,
MaybeAssignedFlag* maybe_assigned_flag) {
@ -921,7 +921,7 @@ int ModuleInfo::RegularExportCount() const {
return regular_exports()->length() / kRegularExportLength;
}
String* ModuleInfo::RegularExportLocalName(int i) const {
String ModuleInfo::RegularExportLocalName(int i) const {
return String::cast(regular_exports()->get(i * kRegularExportLength +
kRegularExportLocalNameOffset));
}

View File

@ -77,7 +77,7 @@ class ScopeInfo : public FixedArray {
bool HasInferredFunctionName() const;
void SetFunctionName(Object* name);
void SetInferredFunctionName(String* name);
void SetInferredFunctionName(String name);
// Does this scope belong to a function?
bool HasPositionInfo() const;
@ -95,7 +95,7 @@ class ScopeInfo : public FixedArray {
// The function's name if it is non-empty, otherwise the inferred name or an
// empty string.
String* FunctionDebugName() const;
String FunctionDebugName() const;
// Return the function's inferred name if present.
// See SharedFunctionInfo::function_identifier.
@ -109,7 +109,7 @@ class ScopeInfo : public FixedArray {
ModuleInfo ModuleDescriptorInfo() const;
// Return the name of the given context local.
String* ContextLocalName(int var) const;
String ContextLocalName(int var) const;
// Return the mode of the given context local.
VariableMode ContextLocalMode(int var) const;
@ -125,7 +125,7 @@ class ScopeInfo : public FixedArray {
// Return true if this local was introduced by the compiler, and should not be
// exposed to the user in a debugger.
static bool VariableIsSynthetic(String* name);
static bool VariableIsSynthetic(String name);
// Lookup support for serialized scope info. Returns the local context slot
// index for a given slot name if the slot is present; otherwise
@ -147,7 +147,7 @@ class ScopeInfo : public FixedArray {
// slot index if the function name is present and context-allocated (named
// function expressions, only), otherwise returns a value < 0. The name
// must be an internalized string.
int FunctionContextSlotIndex(String* name) const;
int FunctionContextSlotIndex(String name) const;
// Lookup support for serialized scope info. Returns the receiver context
// slot index if scope has a "this" binding, and the binding is
@ -262,7 +262,7 @@ class ScopeInfo : public FixedArray {
// Get metadata of i-th MODULE-allocated variable, where 0 <= i <
// ModuleVariableCount. The metadata is returned via out-arguments, which may
// be nullptr if the corresponding information is not requested
void ModuleVariable(int i, String** name, int* index,
void ModuleVariable(int i, String* name, int* index,
VariableMode* mode = nullptr,
InitializationFlag* init_flag = nullptr,
MaybeAssignedFlag* maybe_assigned_flag = nullptr);

View File

@ -101,7 +101,7 @@ void Script::set_origin_options(ScriptOriginOptions origin_options) {
bool Script::HasValidSource() {
Object* src = this->source();
if (!src->IsString()) return true;
String* src_str = String::cast(src);
String src_str = String::cast(src);
if (!StringShape(src_str).IsExternal()) return true;
if (src_str->IsOneByteRepresentation()) {
return ExternalOneByteString::cast(src)->resource() != nullptr;

View File

@ -54,7 +54,7 @@ void PreParsedScopeData::clear_padding() {
}
CAST_ACCESSOR(UncompiledData)
ACCESSORS(UncompiledData, inferred_name, String, kInferredNameOffset)
ACCESSORS2(UncompiledData, inferred_name, String, kInferredNameOffset)
INT32_ACCESSORS(UncompiledData, start_position, kStartPositionOffset)
INT32_ACCESSORS(UncompiledData, end_position, kEndPositionOffset)
INT32_ACCESSORS(UncompiledData, function_literal_id, kFunctionLiteralIdOffset)
@ -108,7 +108,7 @@ bool SharedFunctionInfo::HasSharedName() const {
return value != kNoSharedNameSentinel;
}
String* SharedFunctionInfo::Name() const {
String SharedFunctionInfo::Name() const {
if (!HasSharedName()) return GetReadOnlyRoots().empty_string();
Object* value = name_or_scope_info();
if (value->IsScopeInfo()) {
@ -120,7 +120,7 @@ String* SharedFunctionInfo::Name() const {
return String::cast(value);
}
void SharedFunctionInfo::SetName(String* name) {
void SharedFunctionInfo::SetName(String name) {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo::cast(maybe_scope_info)->SetFunctionName(name);
@ -608,7 +608,7 @@ bool SharedFunctionInfo::HasInferredName() {
return HasUncompiledData();
}
String* SharedFunctionInfo::inferred_name() {
String SharedFunctionInfo::inferred_name() {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo scope_info = ScopeInfo::cast(maybe_scope_info);

Some files were not shown because too many files have changed in this diff Show More