Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Unified Diff: src/objects-inl.h

Issue 1427483002: [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 3bda179712b010834977212ceffa36772927a94a..4918ff7fd5b73ff592abdca4a72e40344b9587ea 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2125,8 +2125,10 @@ void WeakCell::clear_next(Heap* heap) {
bool WeakCell::next_cleared() { return next()->IsTheHole(); }
-int JSObject::GetHeaderSize() {
- InstanceType type = map()->instance_type();
+int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); }
+
+
+int JSObject::GetHeaderSize(InstanceType type) {
// Check for the most common kind of JavaScript object before
// falling into the generic switch. This speeds up the internal
// field operations considerably on average.
@@ -2183,10 +2185,64 @@ int JSObject::GetHeaderSize() {
}
+int JSObject::GetHeaderWithInternalFieldsSize(InstanceType type) {
+ // Check for the most common kind of JavaScript object before
+ // falling into the generic switch. This speeds up the internal
+ // field operations considerably on average.
+ if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
+ switch (type) {
+ case JS_GENERATOR_OBJECT_TYPE:
+ return JSGeneratorObject::kSize;
+ case JS_MODULE_TYPE:
+ return JSModule::kSize;
+ case JS_GLOBAL_PROXY_TYPE:
+ return JSGlobalProxy::kSize;
+ case JS_GLOBAL_OBJECT_TYPE:
+ return JSGlobalObject::kSize;
+ case JS_BUILTINS_OBJECT_TYPE:
+ return JSBuiltinsObject::kSize;
+ case JS_FUNCTION_TYPE:
+ return JSFunction::kSize;
+ case JS_VALUE_TYPE:
+ return JSValue::kSize;
+ case JS_DATE_TYPE:
+ return JSDate::kSize;
+ case JS_ARRAY_TYPE:
+ return JSArray::kSize;
+ case JS_ARRAY_BUFFER_TYPE:
+ return JSArrayBuffer::kSizeWithInternalFields;
+ case JS_TYPED_ARRAY_TYPE:
+ return JSTypedArray::kSizeWithInternalFields;
+ case JS_DATA_VIEW_TYPE:
+ return JSDataView::kSizeWithInternalFields;
+ case JS_SET_TYPE:
+ return JSSet::kSize;
+ case JS_MAP_TYPE:
+ return JSMap::kSize;
+ case JS_SET_ITERATOR_TYPE:
+ return JSSetIterator::kSize;
+ case JS_MAP_ITERATOR_TYPE:
+ return JSMapIterator::kSize;
+ case JS_ITERATOR_RESULT_TYPE:
+ return JSIteratorResult::kSize;
+ case JS_WEAK_MAP_TYPE:
+ return JSWeakMap::kSize;
+ case JS_WEAK_SET_TYPE:
+ return JSWeakSet::kSize;
+ case JS_REGEXP_TYPE:
+ return JSRegExp::kSize;
+ case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
+ return JSObject::kHeaderSize;
+ case JS_MESSAGE_OBJECT_TYPE:
+ return JSMessageObject::kSize;
+ default:
+ UNREACHABLE();
+ return 0;
+ }
+}
+
+
int JSObject::GetInternalFieldCount() {
- DCHECK(1 << kPointerSizeLog2 == kPointerSize);
- // Make sure to adjust for the number of in-object properties. These
- // properties do contribute to the size, but are not internal fields.
return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) -
map()->GetInObjectProperties();
}

Powered by Google App Engine
This is Rietveld 408576698