Commit 9be59492 authored by rossberg's avatar rossberg Committed by Commit bot

[strong] Introduce strong bit

Only set on strong functions so far to test basic operation.

R=dslomov@chromium.org
BUG=v8:3956
LOG=N

Review URL: https://codereview.chromium.org/1138243002

Cr-Commit-Position: refs/heads/master@{#28396}
parent e24b31f0
......@@ -705,7 +705,7 @@ Handle<Map> Genesis::CreateStrongFunctionMap(
map->set_function_with_prototype(is_constructor);
Map::SetPrototype(map, empty_function);
map->set_is_extensible(is_constructor);
// TODO(rossberg): mark strong
map->set_is_strong(true);
return map;
}
......
......@@ -116,6 +116,7 @@ macro IS_GENERATOR(arg) = (%_ClassOf(arg) === 'Generator');
macro IS_SET_ITERATOR(arg) = (%_ClassOf(arg) === 'Set Iterator');
macro IS_MAP_ITERATOR(arg) = (%_ClassOf(arg) === 'Map Iterator');
macro IS_UNDETECTABLE(arg) = (%_IsUndetectableObject(arg));
macro IS_STRONG(arg) = (%IsStrong(arg));
# Macro for ECMAScript 5 queries of the type:
# "Type(O) is object."
......
......@@ -4715,6 +4715,16 @@ bool Map::is_migration_target() {
}
void Map::set_is_strong(bool value) {
set_bit_field3(IsStrong::update(bit_field3(), value));
}
bool Map::is_strong() {
return IsStrong::decode(bit_field3());
}
void Map::set_counter(int value) {
set_bit_field3(Counter::update(bit_field3(), value));
}
......
......@@ -5901,7 +5901,8 @@ class Map: public HeapObject {
class Deprecated : public BitField<bool, 23, 1> {};
class IsUnstable : public BitField<bool, 24, 1> {};
class IsMigrationTarget : public BitField<bool, 25, 1> {};
// Bits 26 and 27 are free.
class IsStrong : public BitField<bool, 26, 1> {};
// Bit 27 is free.
// Keep this bit field at the very end for better code in
// Builtins::kJSConstructStubGeneric stub.
......@@ -5979,6 +5980,8 @@ class Map: public HeapObject {
return ((1 << kIsObserved) & bit_field()) != 0;
}
inline void set_is_strong(bool value);
inline bool is_strong();
inline void set_is_extensible(bool value);
inline bool is_extensible();
inline void set_is_prototype_map(bool value);
......
......@@ -1518,6 +1518,15 @@ RUNTIME_FUNCTION(Runtime_IsSpecObject) {
}
RUNTIME_FUNCTION(Runtime_IsStrong) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Object, obj, 0);
return isolate->heap()->ToBoolean(obj->IsJSReceiver() &&
JSReceiver::cast(obj)->map()->is_strong());
}
RUNTIME_FUNCTION(Runtime_ClassOf) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
......
......@@ -452,6 +452,7 @@ namespace internal {
F(IsObject, 1, 1) \
F(IsUndetectableObject, 1, 1) \
F(IsSpecObject, 1, 1) \
F(IsStrong, 1, 1) \
F(ClassOf, 1, 1) \
F(DefineGetterPropertyUnchecked, 4, 1) \
F(DefineSetterPropertyUnchecked, 4, 1)
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --strong-mode --allow-natives-syntax
'use strong';
function f() {}
assertTrue(%IsStrong(f));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment