From: rossberg Date: Wed, 13 May 2015 13:31:19 +0000 (-0700) Subject: [strong] Introduce strong bit X-Git-Tag: upstream/4.7.83~2644 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9be59492f99f3e9d943a3f05b62ab6a4a2617fab;p=platform%2Fupstream%2Fv8.git [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} --- diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index f49e340..f2e5196 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -705,7 +705,7 @@ Handle 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; } diff --git a/src/macros.py b/src/macros.py index 9fd5442..9c166f6 100644 --- a/src/macros.py +++ b/src/macros.py @@ -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." diff --git a/src/objects-inl.h b/src/objects-inl.h index 026166f..fc43120 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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)); } diff --git a/src/objects.h b/src/objects.h index 7c9b4f8..0aefb4c 100644 --- a/src/objects.h +++ b/src/objects.h @@ -5901,7 +5901,8 @@ class Map: public HeapObject { class Deprecated : public BitField {}; class IsUnstable : public BitField {}; class IsMigrationTarget : public BitField {}; - // Bits 26 and 27 are free. + class IsStrong : public BitField {}; + // 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); diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index ca35c10..e4478b7 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -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); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 809ce66..bd37a68 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -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) diff --git a/test/mjsunit/strong/objects.js b/test/mjsunit/strong/objects.js new file mode 100644 index 0000000..4654606 --- /dev/null +++ b/test/mjsunit/strong/objects.js @@ -0,0 +1,10 @@ +// 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));