Revert "Reland "[torque] Convert few class layout to torque.""

This reverts commit 42fee61a97.

Reason for revert: it's not safe to access in-object fields that way.
Will post more information in Gerrit.

Original change's description:
> Reland "[torque] Convert few class layout to torque."
> 
> This is a reland of b9bfd006f6
> 
> Original change's description:
> > [torque] Convert few class layout to torque and updated torque code formatter.
> >
> > 1. Converted Module, JSModuleNameSpace, JSCollator, JSV8BreakIterator,
> >       TemplateList,
> >       JSStrictArgumentsObject to torque.
> > 2. Updated torque code formatter to now handle multi-line
> >             declarations correctly.
> >
> > Bug: v8:8952
> > Change-Id: I97846b1bc0d2cba5d7a68468fc263423b1b55d19
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1536988
> > Reviewed-by: Simon Zünd <szuend@chromium.org>
> > Commit-Queue: Suraj Sharma <surshar@microsoft.com>
> > Cr-Commit-Position: refs/heads/master@{#61624}
> 
> Removed the Torque code Formatter update from this CL
> 
> Bug: v8:8952
> Change-Id: I01e88ac36acd7ba18791bec609e5ae737672c731
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1619146
> Commit-Queue: Suraj Sharma <surshar@microsoft.com>
> Reviewed-by: Simon Zünd <szuend@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#61671}

TBR=surshar@microsoft.com,szuend@chromium.org

Change-Id: I6fd66ce67aeecf0128878924d5e5b6a71ad88e32
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8952
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1622109
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61692}
This commit is contained in:
Georg Neis 2019-05-21 12:55:54 +00:00 committed by Commit Bot
parent efb11f2068
commit e165213e96
8 changed files with 95 additions and 79 deletions

View File

@ -16,7 +16,6 @@
#include 'src/objects/js-regexp-string-iterator.h'
#include 'src/objects/module.h'
#include 'src/objects/stack-frame-info.h'
#include 'src/objects/template-objects.h'
#include 'src/builtins/builtins-regexp-gen.h'
#include 'src/objects/template-objects.h'
@ -367,11 +366,6 @@ extern class JSSloppyArgumentsObject extends JSArgumentsObjectWithLength {
callee: Object;
}
@hasSameInstanceTypeAsParent
@noVerifier
extern class JSStrictArgumentsObject extends JSArgumentsObjectWithLength {
}
extern class JSArrayIterator extends JSObject {
iterated_object: JSReceiver;
next_index: Number;
@ -435,36 +429,7 @@ transient type FastJSArrayWithNoCustomIteration extends FastJSArray;
type NoSharedNameSentinel extends Smi;
type ModuleInfo extends FixedArray;
type ObjectHashTable extends FixedArray;
extern class Module extends Struct {
code: SharedFunctionInfo | JSFunction |
JSGeneratorObject | ModuleInfo;
exports: ObjectHashTable;
regular_exports: FixedArray;
regular_imports: FixedArray;
hash: Smi;
status: Smi;
module_namespace: JSModuleNamespace | Undefined;
requested_modules: FixedArray;
dfs_index: Smi;
dfs_ancestor_index: Smi;
exception: Object;
script: Script;
@noVerifier import_meta: Hole | JSObject;
}
extern class JSModuleNamespace extends JSObject {
module: Module;
to_string_tag_field: Object;
}
@hasSameInstanceTypeAsParent
@noVerifier
extern class TemplateList extends FixedArray {
}
type JSModuleNamespace extends JSObject;
type WeakArrayList extends HeapObject;
@abstract

View File

@ -1572,7 +1572,10 @@ void BigInt::BigIntVerify(Isolate* isolate) {
CHECK_IMPLIES(is_zero(), !sign()); // There is no -0n.
}
USE_TORQUE_VERIFIER(JSModuleNamespace)
void JSModuleNamespace::JSModuleNamespaceVerify(Isolate* isolate) {
CHECK(IsJSModuleNamespace());
VerifyPointer(isolate, module());
}
void ModuleInfoEntry::ModuleInfoEntryVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::ModuleInfoEntryVerify(*this, isolate);
@ -1582,7 +1585,17 @@ void ModuleInfoEntry::ModuleInfoEntryVerify(Isolate* isolate) {
}
void Module::ModuleVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::ModuleVerify(*this, isolate);
CHECK(IsModule());
VerifyPointer(isolate, code());
VerifyPointer(isolate, exports());
VerifyPointer(isolate, module_namespace());
VerifyPointer(isolate, requested_modules());
VerifyPointer(isolate, script());
VerifyPointer(isolate, import_meta());
VerifyPointer(isolate, exception());
VerifySmiField(kHashOffset);
VerifySmiField(kStatusOffset);
CHECK((status() >= kEvaluating && code()->IsModuleInfo()) ||
(status() == kInstantiated && code()->IsJSGeneratorObject()) ||
@ -1868,10 +1881,25 @@ void UncompiledDataWithoutPreparseData::UncompiledDataWithoutPreparseDataVerify(
USE_TORQUE_VERIFIER(InterpreterData)
#ifdef V8_INTL_SUPPORT
void JSV8BreakIterator::JSV8BreakIteratorVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kTypeOffset);
VerifyObjectField(isolate, kBreakIteratorOffset);
VerifyObjectField(isolate, kUnicodeStringOffset);
VerifyObjectField(isolate, kBoundAdoptTextOffset);
VerifyObjectField(isolate, kBoundFirstOffset);
VerifyObjectField(isolate, kBoundNextOffset);
VerifyObjectField(isolate, kBoundCurrentOffset);
VerifyObjectField(isolate, kBoundBreakTypeOffset);
}
USE_TORQUE_VERIFIER(JSV8BreakIterator)
USE_TORQUE_VERIFIER(JSCollator)
void JSCollator::JSCollatorVerify(Isolate* isolate) {
CHECK(IsJSCollator());
JSObjectVerify(isolate);
VerifyObjectField(isolate, kICUCollatorOffset);
VerifyObjectField(isolate, kBoundCompareOffset);
}
void JSDateTimeFormat::JSDateTimeFormatVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::JSDateTimeFormatVerify(*this, isolate);

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include 'src/objects/js-break-iterator.h'
#include 'src/objects/js-collator.h'
#include 'src/objects/js-number-format.h'
#include 'src/objects/js-objects.h'
#include 'src/objects/js-plural-rules.h'
@ -64,20 +62,3 @@ extern class JSSegmentIterator extends JSObject {
unicode_string: Foreign; // Managed<icu::UnicodeString>
flags: Smi;
}
extern class JSV8BreakIterator extends JSObject {
locale: String;
break_iterator: Foreign; // Managed<icu::BreakIterator>;
unicode_string: Foreign; // Managed<icu::UnicodeString>;
bound_adopt_text: Undefined | JSFunction;
bound_first: Undefined | JSFunction;
bound_next: Undefined | JSFunction;
bound_current: Undefined | JSFunction;
bound_break_type: Undefined | JSFunction;
break_iterator_type: Smi;
}
extern class JSCollator extends JSObject {
icu_collator: Foreign; // Managed<icu::Collator>
bound_compare: Undefined | JSFunction;
}

View File

@ -22,12 +22,11 @@ OBJECT_CONSTRUCTORS_IMPL(JSV8BreakIterator, JSObject)
inline void JSV8BreakIterator::set_type(Type type) {
DCHECK_GT(JSV8BreakIterator::Type::COUNT, type);
WRITE_FIELD(*this, kBreakIteratorTypeOffset,
Smi::FromInt(static_cast<int>(type)));
WRITE_FIELD(*this, kTypeOffset, Smi::FromInt(static_cast<int>(type)));
}
inline JSV8BreakIterator::Type JSV8BreakIterator::type() const {
Object value = READ_FIELD(*this, kBreakIteratorTypeOffset);
Object value = READ_FIELD(*this, kTypeOffset);
return static_cast<JSV8BreakIterator::Type>(Smi::ToInt(value));
}

View File

@ -15,7 +15,6 @@
#include "src/objects.h"
#include "src/objects/intl-objects.h"
#include "src/objects/managed.h"
#include "torque-generated/field-offsets-tq.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@ -71,8 +70,22 @@ class JSV8BreakIterator : public JSObject {
DECL_ACCESSORS(bound_break_type, Object)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSV8BREAK_ITERATOR_FIELDS)
#define BREAK_ITERATOR_FIELDS(V) \
/* Pointer fields. */ \
V(kLocaleOffset, kTaggedSize) \
V(kTypeOffset, kTaggedSize) \
V(kBreakIteratorOffset, kTaggedSize) \
V(kUnicodeStringOffset, kTaggedSize) \
V(kBoundAdoptTextOffset, kTaggedSize) \
V(kBoundFirstOffset, kTaggedSize) \
V(kBoundNextOffset, kTaggedSize) \
V(kBoundCurrentOffset, kTaggedSize) \
V(kBoundBreakTypeOffset, kTaggedSize) \
/* Total Size */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, BREAK_ITERATOR_FIELDS)
#undef BREAK_ITERATOR_FIELDS
OBJECT_CONSTRUCTORS(JSV8BreakIterator, JSObject);
};

View File

@ -20,7 +20,7 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(JSCollator, JSObject)
ACCESSORS(JSCollator, icu_collator, Managed<icu::Collator>, kIcuCollatorOffset)
ACCESSORS(JSCollator, icu_collator, Managed<icu::Collator>, kICUCollatorOffset)
ACCESSORS(JSCollator, bound_compare, Object, kBoundCompareOffset)
CAST_ACCESSOR(JSCollator)

View File

@ -47,8 +47,14 @@ class JSCollator : public JSObject {
DECL_VERIFIER(JSCollator)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSCOLLATOR_FIELDS)
#define JS_COLLATOR_FIELDS(V) \
V(kICUCollatorOffset, kTaggedSize) \
V(kBoundCompareOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, JS_COLLATOR_FIELDS)
#undef JS_COLLATOR_FIELDS
DECL_ACCESSORS(icu_collator, Managed<icu::Collator>)
DECL_ACCESSORS(bound_compare, Object)

View File

@ -9,7 +9,6 @@
#include "src/objects/fixed-array.h"
#include "src/objects/js-objects.h"
#include "src/objects/struct.h"
#include "torque-generated/field-offsets-tq.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@ -127,8 +126,25 @@ class Module : public Struct {
Handle<Module> module);
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_MODULE_FIELDS)
#define MODULE_FIELDS(V) \
V(kCodeOffset, kTaggedSize) \
V(kExportsOffset, kTaggedSize) \
V(kRegularExportsOffset, kTaggedSize) \
V(kRegularImportsOffset, kTaggedSize) \
V(kHashOffset, kTaggedSize) \
V(kModuleNamespaceOffset, kTaggedSize) \
V(kRequestedModulesOffset, kTaggedSize) \
V(kStatusOffset, kTaggedSize) \
V(kDfsIndexOffset, kTaggedSize) \
V(kDfsAncestorIndexOffset, kTaggedSize) \
V(kExceptionOffset, kTaggedSize) \
V(kScriptOffset, kTaggedSize) \
V(kImportMetaOffset, kTaggedSize) \
/* Total size. */ \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, MODULE_FIELDS)
#undef MODULE_FIELDS
private:
friend class Factory;
@ -229,14 +245,23 @@ class JSModuleNamespace : public JSObject {
LookupIterator* it);
// In-object fields.
static constexpr int kToStringTagFieldIndex = 0;
static constexpr int kInObjectFieldCount = 1;
enum {
kToStringTagFieldIndex,
kInObjectFieldCount,
};
// Layout description.
#define JS_MODULE_NAMESPACE_FIELDS(V) \
V(kModuleOffset, kTaggedSize) \
/* Header size. */ \
V(kHeaderSize, 0) \
V(kInObjectFieldsOffset, kTaggedSize* kInObjectFieldCount) \
/* Total size. */ \
V(kSize, 0)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_JSMODULE_NAMESPACE_FIELDS)
static const int kHeaderSize = kToStringTagFieldOffset;
JS_MODULE_NAMESPACE_FIELDS)
#undef JS_MODULE_NAMESPACE_FIELDS
OBJECT_CONSTRUCTORS(JSModuleNamespace, JSObject);
};
@ -284,7 +309,6 @@ class ModuleInfo : public FixedArray {
kRegularExportExportNamesOffset,
kRegularExportLength
};
OBJECT_CONSTRUCTORS(ModuleInfo, FixedArray);
};