Commit 3e362c75 authored by jgruber's avatar jgruber Committed by Commit bot

[cleanup] Refactor builtins-object.cc to use TF_BUILTIN macro

BUG=

Review-Url: https://codereview.chromium.org/2621303002
Cr-Commit-Position: refs/heads/master@{#42226}
parent 0959983c
...@@ -11,59 +11,57 @@ ...@@ -11,59 +11,57 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class ObjectBuiltinsAssembler : public CodeStubAssembler {
public:
explicit ObjectBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
protected:
void IsString(Node* object, Label* if_string, Label* if_notstring);
void ReturnToStringFormat(Node* context, Node* string);
};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ES6 section 19.1 Object Objects // ES6 section 19.1 Object Objects
void Builtins::Generate_ObjectHasOwnProperty( TF_BUILTIN(ObjectHasOwnProperty, ObjectBuiltinsAssembler) {
compiler::CodeAssemblerState* state) { Node* object = Parameter(0);
typedef compiler::Node Node; Node* key = Parameter(1);
typedef CodeStubAssembler::Label Label; Node* context = Parameter(4);
typedef CodeStubAssembler::Variable Variable;
CodeStubAssembler assembler(state);
Node* object = assembler.Parameter(0); Label call_runtime(this), return_true(this), return_false(this);
Node* key = assembler.Parameter(1);
Node* context = assembler.Parameter(4);
Label call_runtime(&assembler), return_true(&assembler),
return_false(&assembler);
// Smi receivers do not have own properties. // Smi receivers do not have own properties.
Label if_objectisnotsmi(&assembler); Label if_objectisnotsmi(this);
assembler.Branch(assembler.TaggedIsSmi(object), &return_false, Branch(TaggedIsSmi(object), &return_false, &if_objectisnotsmi);
&if_objectisnotsmi); Bind(&if_objectisnotsmi);
assembler.Bind(&if_objectisnotsmi);
Node* map = assembler.LoadMap(object); Node* map = LoadMap(object);
Node* instance_type = assembler.LoadMapInstanceType(map); Node* instance_type = LoadMapInstanceType(map);
Variable var_index(&assembler, MachineType::PointerRepresentation()); Variable var_index(this, MachineType::PointerRepresentation());
Label keyisindex(&assembler), if_iskeyunique(&assembler); Label keyisindex(this), if_iskeyunique(this);
assembler.TryToName(key, &keyisindex, &var_index, &if_iskeyunique, TryToName(key, &keyisindex, &var_index, &if_iskeyunique, &call_runtime);
&call_runtime);
assembler.Bind(&if_iskeyunique); Bind(&if_iskeyunique);
assembler.TryHasOwnProperty(object, map, instance_type, key, &return_true, TryHasOwnProperty(object, map, instance_type, key, &return_true,
&return_false, &call_runtime); &return_false, &call_runtime);
assembler.Bind(&keyisindex); Bind(&keyisindex);
// Handle negative keys in the runtime. // Handle negative keys in the runtime.
assembler.GotoIf( GotoIf(IntPtrLessThan(var_index.value(), IntPtrConstant(0)), &call_runtime);
assembler.IntPtrLessThan(var_index.value(), assembler.IntPtrConstant(0)), TryLookupElement(object, map, instance_type, var_index.value(), &return_true,
&call_runtime); &return_false, &call_runtime);
assembler.TryLookupElement(object, map, instance_type, var_index.value(),
&return_true, &return_false, &call_runtime);
assembler.Bind(&return_true); Bind(&return_true);
assembler.Return(assembler.BooleanConstant(true)); Return(BooleanConstant(true));
assembler.Bind(&return_false); Bind(&return_false);
assembler.Return(assembler.BooleanConstant(false)); Return(BooleanConstant(false));
assembler.Bind(&call_runtime); Bind(&call_runtime);
assembler.Return(assembler.CallRuntime(Runtime::kObjectHasOwnProperty, Return(CallRuntime(Runtime::kObjectHasOwnProperty, context, object, key));
context, object, key));
} }
// ES6 19.1.2.1 Object.assign // ES6 19.1.2.1 Object.assign
...@@ -106,115 +104,90 @@ BUILTIN(ObjectPrototypePropertyIsEnumerable) { ...@@ -106,115 +104,90 @@ BUILTIN(ObjectPrototypePropertyIsEnumerable) {
return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0); return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0);
} }
namespace { // anonymous namespace for ObjectProtoToString() void ObjectBuiltinsAssembler::IsString(Node* object, Label* if_string,
Label* if_notstring) {
void IsString(CodeStubAssembler* assembler, compiler::Node* object, Label if_notsmi(this);
CodeStubAssembler::Label* if_string, Branch(TaggedIsSmi(object), if_notstring, &if_notsmi);
CodeStubAssembler::Label* if_notstring) {
typedef compiler::Node Node;
typedef CodeStubAssembler::Label Label;
Label if_notsmi(assembler); Bind(&if_notsmi);
assembler->Branch(assembler->TaggedIsSmi(object), if_notstring, &if_notsmi);
assembler->Bind(&if_notsmi);
{ {
Node* instance_type = assembler->LoadInstanceType(object); Node* instance_type = LoadInstanceType(object);
assembler->Branch(assembler->IsStringInstanceType(instance_type), if_string, Branch(IsStringInstanceType(instance_type), if_string, if_notstring);
if_notstring);
} }
} }
void ReturnToStringFormat(CodeStubAssembler* assembler, compiler::Node* context, void ObjectBuiltinsAssembler::ReturnToStringFormat(Node* context,
compiler::Node* string) { Node* string) {
typedef compiler::Node Node; Node* lhs = HeapConstant(factory()->NewStringFromStaticChars("[object "));
Node* rhs = HeapConstant(factory()->NewStringFromStaticChars("]"));
Node* lhs = assembler->HeapConstant(
assembler->factory()->NewStringFromStaticChars("[object "));
Node* rhs = assembler->HeapConstant(
assembler->factory()->NewStringFromStaticChars("]"));
Callable callable = CodeFactory::StringAdd( Callable callable =
assembler->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED); CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED);
assembler->Return(assembler->CallStub( Return(CallStub(callable, context, CallStub(callable, context, lhs, string),
callable, context, assembler->CallStub(callable, context, lhs, string), rhs));
rhs));
} }
} // namespace
// ES6 section 19.1.3.6 Object.prototype.toString // ES6 section 19.1.3.6 Object.prototype.toString
void Builtins::Generate_ObjectProtoToString( TF_BUILTIN(ObjectProtoToString, ObjectBuiltinsAssembler) {
compiler::CodeAssemblerState* state) { Label return_undefined(this, Label::kDeferred),
typedef compiler::Node Node; return_null(this, Label::kDeferred),
typedef CodeStubAssembler::Label Label; return_arguments(this, Label::kDeferred), return_array(this),
typedef CodeStubAssembler::Variable Variable; return_api(this, Label::kDeferred), return_object(this),
CodeStubAssembler assembler(state); return_regexp(this), return_function(this), return_error(this),
return_date(this), return_jsvalue(this),
return_jsproxy(this, Label::kDeferred);
Label return_undefined(&assembler, Label::kDeferred), Label if_isproxy(this, Label::kDeferred);
return_null(&assembler, Label::kDeferred),
return_arguments(&assembler, Label::kDeferred), return_array(&assembler),
return_api(&assembler, Label::kDeferred), return_object(&assembler),
return_regexp(&assembler), return_function(&assembler),
return_error(&assembler), return_date(&assembler),
return_jsvalue(&assembler), return_jsproxy(&assembler, Label::kDeferred);
Label if_isproxy(&assembler, Label::kDeferred); Label checkstringtag(this);
Label if_tostringtag(this), if_notostringtag(this);
Label checkstringtag(&assembler); Node* receiver = Parameter(0);
Label if_tostringtag(&assembler), if_notostringtag(&assembler); Node* context = Parameter(3);
Node* receiver = assembler.Parameter(0); GotoIf(WordEqual(receiver, UndefinedConstant()), &return_undefined);
Node* context = assembler.Parameter(3);
assembler.GotoIf(assembler.WordEqual(receiver, assembler.UndefinedConstant()), GotoIf(WordEqual(receiver, NullConstant()), &return_null);
&return_undefined);
assembler.GotoIf(assembler.WordEqual(receiver, assembler.NullConstant()), Callable to_object = CodeFactory::ToObject(isolate());
&return_null); receiver = CallStub(to_object, context, receiver);
Callable to_object = CodeFactory::ToObject(assembler.isolate()); Node* receiver_instance_type = LoadInstanceType(receiver);
receiver = assembler.CallStub(to_object, context, receiver);
Node* receiver_instance_type = assembler.LoadInstanceType(receiver);
// for proxies, check IsArray before getting @@toStringTag // for proxies, check IsArray before getting @@toStringTag
Variable var_proxy_is_array(&assembler, MachineRepresentation::kTagged); Variable var_proxy_is_array(this, MachineRepresentation::kTagged);
var_proxy_is_array.Bind(assembler.BooleanConstant(false)); var_proxy_is_array.Bind(BooleanConstant(false));
assembler.Branch( Branch(Word32Equal(receiver_instance_type, Int32Constant(JS_PROXY_TYPE)),
assembler.Word32Equal(receiver_instance_type, &if_isproxy, &checkstringtag);
assembler.Int32Constant(JS_PROXY_TYPE)),
&if_isproxy, &checkstringtag);
assembler.Bind(&if_isproxy); Bind(&if_isproxy);
{ {
// This can throw // This can throw
var_proxy_is_array.Bind( var_proxy_is_array.Bind(
assembler.CallRuntime(Runtime::kArrayIsArray, context, receiver)); CallRuntime(Runtime::kArrayIsArray, context, receiver));
assembler.Goto(&checkstringtag); Goto(&checkstringtag);
} }
assembler.Bind(&checkstringtag); Bind(&checkstringtag);
{ {
Node* to_string_tag_symbol = assembler.HeapConstant( Node* to_string_tag_symbol =
assembler.isolate()->factory()->to_string_tag_symbol()); HeapConstant(isolate()->factory()->to_string_tag_symbol());
GetPropertyStub stub(assembler.isolate()); GetPropertyStub stub(isolate());
Callable get_property = Callable get_property =
Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
Node* to_string_tag_value = assembler.CallStub( Node* to_string_tag_value =
get_property, context, receiver, to_string_tag_symbol); CallStub(get_property, context, receiver, to_string_tag_symbol);
IsString(&assembler, to_string_tag_value, &if_tostringtag, IsString(to_string_tag_value, &if_tostringtag, &if_notostringtag);
&if_notostringtag);
assembler.Bind(&if_tostringtag); Bind(&if_tostringtag);
ReturnToStringFormat(&assembler, context, to_string_tag_value); ReturnToStringFormat(context, to_string_tag_value);
} }
assembler.Bind(&if_notostringtag); Bind(&if_notostringtag);
{ {
size_t const kNumCases = 11; size_t const kNumCases = 11;
Label* case_labels[kNumCases]; Label* case_labels[kNumCases];
...@@ -242,195 +215,164 @@ void Builtins::Generate_ObjectProtoToString( ...@@ -242,195 +215,164 @@ void Builtins::Generate_ObjectProtoToString(
case_labels[10] = &return_jsproxy; case_labels[10] = &return_jsproxy;
case_values[10] = JS_PROXY_TYPE; case_values[10] = JS_PROXY_TYPE;
assembler.Switch(receiver_instance_type, &return_object, case_values, Switch(receiver_instance_type, &return_object, case_values, case_labels,
case_labels, arraysize(case_values)); arraysize(case_values));
assembler.Bind(&return_undefined); Bind(&return_undefined);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->undefined_to_string()));
assembler.isolate()->factory()->undefined_to_string()));
assembler.Bind(&return_null); Bind(&return_null);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->null_to_string()));
assembler.isolate()->factory()->null_to_string()));
assembler.Bind(&return_arguments); Bind(&return_arguments);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->arguments_to_string()));
assembler.isolate()->factory()->arguments_to_string()));
assembler.Bind(&return_array); Bind(&return_array);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->array_to_string()));
assembler.isolate()->factory()->array_to_string()));
assembler.Bind(&return_function); Bind(&return_function);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->function_to_string()));
assembler.isolate()->factory()->function_to_string()));
assembler.Bind(&return_error); Bind(&return_error);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->error_to_string()));
assembler.isolate()->factory()->error_to_string()));
assembler.Bind(&return_date); Bind(&return_date);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->date_to_string()));
assembler.isolate()->factory()->date_to_string()));
assembler.Bind(&return_regexp); Bind(&return_regexp);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->regexp_to_string()));
assembler.isolate()->factory()->regexp_to_string()));
assembler.Bind(&return_api); Bind(&return_api);
{ {
Node* class_name = Node* class_name = CallRuntime(Runtime::kClassOf, context, receiver);
assembler.CallRuntime(Runtime::kClassOf, context, receiver); ReturnToStringFormat(context, class_name);
ReturnToStringFormat(&assembler, context, class_name);
} }
assembler.Bind(&return_jsvalue); Bind(&return_jsvalue);
{ {
Label return_boolean(&assembler), return_number(&assembler), Label return_boolean(this), return_number(this), return_string(this);
return_string(&assembler);
Node* value = LoadJSValueValue(receiver);
Node* value = assembler.LoadJSValueValue(receiver); GotoIf(TaggedIsSmi(value), &return_number);
assembler.GotoIf(assembler.TaggedIsSmi(value), &return_number); Node* instance_type = LoadInstanceType(value);
Node* instance_type = assembler.LoadInstanceType(value);
GotoIf(IsStringInstanceType(instance_type), &return_string);
assembler.GotoIf(assembler.IsStringInstanceType(instance_type), GotoIf(Word32Equal(instance_type, Int32Constant(HEAP_NUMBER_TYPE)),
&return_string); &return_number);
assembler.GotoIf( GotoIf(Word32Equal(instance_type, Int32Constant(ODDBALL_TYPE)),
assembler.Word32Equal(instance_type, &return_boolean);
assembler.Int32Constant(HEAP_NUMBER_TYPE)),
&return_number); CSA_ASSERT(this, Word32Equal(instance_type, Int32Constant(SYMBOL_TYPE)));
assembler.GotoIf( Goto(&return_object);
assembler.Word32Equal(instance_type,
assembler.Int32Constant(ODDBALL_TYPE)), Bind(&return_string);
&return_boolean); Return(HeapConstant(isolate()->factory()->string_to_string()));
CSA_ASSERT(&assembler, Bind(&return_number);
assembler.Word32Equal(instance_type, Return(HeapConstant(isolate()->factory()->number_to_string()));
assembler.Int32Constant(SYMBOL_TYPE)));
assembler.Goto(&return_object); Bind(&return_boolean);
Return(HeapConstant(isolate()->factory()->boolean_to_string()));
assembler.Bind(&return_string);
assembler.Return(assembler.HeapConstant(
assembler.isolate()->factory()->string_to_string()));
assembler.Bind(&return_number);
assembler.Return(assembler.HeapConstant(
assembler.isolate()->factory()->number_to_string()));
assembler.Bind(&return_boolean);
assembler.Return(assembler.HeapConstant(
assembler.isolate()->factory()->boolean_to_string()));
} }
assembler.Bind(&return_jsproxy); Bind(&return_jsproxy);
{ {
assembler.GotoIf(assembler.WordEqual(var_proxy_is_array.value(), GotoIf(WordEqual(var_proxy_is_array.value(), BooleanConstant(true)),
assembler.BooleanConstant(true)), &return_array);
&return_array);
Node* map = assembler.LoadMap(receiver); Node* map = LoadMap(receiver);
// Return object if the proxy {receiver} is not callable. // Return object if the proxy {receiver} is not callable.
assembler.Branch(assembler.IsCallableMap(map), &return_function, Branch(IsCallableMap(map), &return_function, &return_object);
&return_object);
} }
// Default // Default
assembler.Bind(&return_object); Bind(&return_object);
assembler.Return(assembler.HeapConstant( Return(HeapConstant(isolate()->factory()->object_to_string()));
assembler.isolate()->factory()->object_to_string()));
} }
} }
void Builtins::Generate_ObjectCreate(compiler::CodeAssemblerState* state) { TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
typedef compiler::Node Node; Node* prototype = Parameter(1);
typedef CodeStubAssembler::Label Label; Node* properties = Parameter(2);
typedef CodeStubAssembler::Variable Variable; Node* context = Parameter(3 + 2);
CodeStubAssembler a(state);
Node* prototype = a.Parameter(1);
Node* properties = a.Parameter(2);
Node* context = a.Parameter(3 + 2);
Label call_runtime(&a, Label::kDeferred), prototype_valid(&a), Label call_runtime(this, Label::kDeferred), prototype_valid(this),
no_properties(&a); no_properties(this);
{ {
a.Comment("Argument 1 check: prototype"); Comment("Argument 1 check: prototype");
a.GotoIf(a.WordEqual(prototype, a.NullConstant()), &prototype_valid); GotoIf(WordEqual(prototype, NullConstant()), &prototype_valid);
a.BranchIfJSReceiver(prototype, &prototype_valid, &call_runtime); BranchIfJSReceiver(prototype, &prototype_valid, &call_runtime);
} }
a.Bind(&prototype_valid); Bind(&prototype_valid);
{ {
a.Comment("Argument 2 check: properties"); Comment("Argument 2 check: properties");
// Check that we have a simple object // Check that we have a simple object
a.GotoIf(a.TaggedIsSmi(properties), &call_runtime); GotoIf(TaggedIsSmi(properties), &call_runtime);
// Undefined implies no properties. // Undefined implies no properties.
a.GotoIf(a.WordEqual(properties, a.UndefinedConstant()), &no_properties); GotoIf(WordEqual(properties, UndefinedConstant()), &no_properties);
Node* properties_map = a.LoadMap(properties); Node* properties_map = LoadMap(properties);
a.GotoIf(a.IsSpecialReceiverMap(properties_map), &call_runtime); GotoIf(IsSpecialReceiverMap(properties_map), &call_runtime);
// Stay on the fast path only if there are no elements. // Stay on the fast path only if there are no elements.
a.GotoUnless(a.WordEqual(a.LoadElements(properties), GotoUnless(WordEqual(LoadElements(properties),
a.LoadRoot(Heap::kEmptyFixedArrayRootIndex)), LoadRoot(Heap::kEmptyFixedArrayRootIndex)),
&call_runtime); &call_runtime);
// Handle dictionary objects or fast objects with properties in runtime. // Handle dictionary objects or fast objects with properties in runtime.
Node* bit_field3 = a.LoadMapBitField3(properties_map); Node* bit_field3 = LoadMapBitField3(properties_map);
a.GotoIf(a.IsSetWord32<Map::DictionaryMap>(bit_field3), &call_runtime); GotoIf(IsSetWord32<Map::DictionaryMap>(bit_field3), &call_runtime);
a.Branch(a.IsSetWord32<Map::NumberOfOwnDescriptorsBits>(bit_field3), Branch(IsSetWord32<Map::NumberOfOwnDescriptorsBits>(bit_field3),
&call_runtime, &no_properties); &call_runtime, &no_properties);
} }
// Create a new object with the given prototype. // Create a new object with the given prototype.
a.Bind(&no_properties); Bind(&no_properties);
{ {
Variable map(&a, MachineRepresentation::kTagged); Variable map(this, MachineRepresentation::kTagged);
Variable properties(&a, MachineRepresentation::kTagged); Variable properties(this, MachineRepresentation::kTagged);
Label non_null_proto(&a), instantiate_map(&a), good(&a); Label non_null_proto(this), instantiate_map(this), good(this);
a.Branch(a.WordEqual(prototype, a.NullConstant()), &good, &non_null_proto); Branch(WordEqual(prototype, NullConstant()), &good, &non_null_proto);
a.Bind(&good); Bind(&good);
{ {
map.Bind(a.LoadContextElement( map.Bind(LoadContextElement(
context, Context::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP)); context, Context::SLOW_OBJECT_WITH_NULL_PROTOTYPE_MAP));
properties.Bind( properties.Bind(AllocateNameDictionary(NameDictionary::kInitialCapacity));
a.AllocateNameDictionary(NameDictionary::kInitialCapacity)); Goto(&instantiate_map);
a.Goto(&instantiate_map);
} }
a.Bind(&non_null_proto); Bind(&non_null_proto);
{ {
properties.Bind(a.EmptyFixedArrayConstant()); properties.Bind(EmptyFixedArrayConstant());
Node* object_function = Node* object_function =
a.LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX); LoadContextElement(context, Context::OBJECT_FUNCTION_INDEX);
Node* object_function_map = a.LoadObjectField( Node* object_function_map = LoadObjectField(
object_function, JSFunction::kPrototypeOrInitialMapOffset); object_function, JSFunction::kPrototypeOrInitialMapOffset);
map.Bind(object_function_map); map.Bind(object_function_map);
a.GotoIf(a.WordEqual(prototype, a.LoadMapPrototype(map.value())), GotoIf(WordEqual(prototype, LoadMapPrototype(map.value())),
&instantiate_map); &instantiate_map);
// Try loading the prototype info. // Try loading the prototype info.
Node* prototype_info = Node* prototype_info =
a.LoadMapPrototypeInfo(a.LoadMap(prototype), &call_runtime); LoadMapPrototypeInfo(LoadMap(prototype), &call_runtime);
a.Comment("Load ObjectCreateMap from PrototypeInfo"); Comment("Load ObjectCreateMap from PrototypeInfo");
Node* weak_cell = Node* weak_cell =
a.LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap); LoadObjectField(prototype_info, PrototypeInfo::kObjectCreateMap);
a.GotoIf(a.WordEqual(weak_cell, a.UndefinedConstant()), &call_runtime); GotoIf(WordEqual(weak_cell, UndefinedConstant()), &call_runtime);
map.Bind(a.LoadWeakCellValue(weak_cell, &call_runtime)); map.Bind(LoadWeakCellValue(weak_cell, &call_runtime));
a.Goto(&instantiate_map); Goto(&instantiate_map);
} }
a.Bind(&instantiate_map); Bind(&instantiate_map);
{ {
Node* instance = Node* instance = AllocateJSObjectFromMap(map.value(), properties.value());
a.AllocateJSObjectFromMap(map.value(), properties.value()); Return(instance);
a.Return(instance);
} }
} }
a.Bind(&call_runtime); Bind(&call_runtime);
{ {
a.Return( Return(CallRuntime(Runtime::kObjectCreate, context, prototype, properties));
a.CallRuntime(Runtime::kObjectCreate, context, prototype, properties));
} }
} }
...@@ -927,90 +869,73 @@ BUILTIN(ObjectSeal) { ...@@ -927,90 +869,73 @@ BUILTIN(ObjectSeal) {
return *object; return *object;
} }
void Builtins::Generate_CreateIterResultObject( TF_BUILTIN(CreateIterResultObject, ObjectBuiltinsAssembler) {
compiler::CodeAssemblerState* state) {
typedef CreateIterResultObjectDescriptor Descriptor; typedef CreateIterResultObjectDescriptor Descriptor;
typedef compiler::Node Node;
CodeStubAssembler a(state);
Node* const value = a.Parameter(Descriptor::kValue); Node* const value = Parameter(Descriptor::kValue);
Node* const done = a.Parameter(Descriptor::kDone); Node* const done = Parameter(Descriptor::kDone);
Node* const context = a.Parameter(Descriptor::kContext); Node* const context = Parameter(Descriptor::kContext);
Node* const native_context = a.LoadNativeContext(context); Node* const native_context = LoadNativeContext(context);
Node* const map = Node* const map =
a.LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX); LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX);
Node* const result = a.AllocateJSObjectFromMap(map); Node* const result = AllocateJSObjectFromMap(map);
a.StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kValueOffset, StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kValueOffset, value);
value); StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kDoneOffset, done);
a.StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kDoneOffset, done);
a.Return(result); Return(result);
} }
void Builtins::Generate_HasProperty(compiler::CodeAssemblerState* state) { TF_BUILTIN(HasProperty, ObjectBuiltinsAssembler) {
typedef HasPropertyDescriptor Descriptor; typedef HasPropertyDescriptor Descriptor;
typedef compiler::Node Node;
CodeStubAssembler assembler(state);
Node* key = assembler.Parameter(Descriptor::kKey); Node* key = Parameter(Descriptor::kKey);
Node* object = assembler.Parameter(Descriptor::kObject); Node* object = Parameter(Descriptor::kObject);
Node* context = assembler.Parameter(Descriptor::kContext); Node* context = Parameter(Descriptor::kContext);
assembler.Return( Return(HasProperty(object, key, context, Runtime::kHasProperty));
assembler.HasProperty(object, key, context, Runtime::kHasProperty));
} }
void Builtins::Generate_ForInFilter(compiler::CodeAssemblerState* state) { TF_BUILTIN(ForInFilter, ObjectBuiltinsAssembler) {
typedef compiler::Node Node;
typedef ForInFilterDescriptor Descriptor; typedef ForInFilterDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* key = assembler.Parameter(Descriptor::kKey); Node* key = Parameter(Descriptor::kKey);
Node* object = assembler.Parameter(Descriptor::kObject); Node* object = Parameter(Descriptor::kObject);
Node* context = assembler.Parameter(Descriptor::kContext); Node* context = Parameter(Descriptor::kContext);
assembler.Return(assembler.ForInFilter(key, object, context)); Return(ForInFilter(key, object, context));
} }
void Builtins::Generate_InstanceOf(compiler::CodeAssemblerState* state) { TF_BUILTIN(InstanceOf, ObjectBuiltinsAssembler) {
typedef compiler::Node Node;
typedef CompareDescriptor Descriptor; typedef CompareDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* object = assembler.Parameter(Descriptor::kLeft); Node* object = Parameter(Descriptor::kLeft);
Node* callable = assembler.Parameter(Descriptor::kRight); Node* callable = Parameter(Descriptor::kRight);
Node* context = assembler.Parameter(Descriptor::kContext); Node* context = Parameter(Descriptor::kContext);
assembler.Return(assembler.InstanceOf(object, callable, context)); Return(InstanceOf(object, callable, context));
} }
// ES6 section 7.3.19 OrdinaryHasInstance ( C, O ) // ES6 section 7.3.19 OrdinaryHasInstance ( C, O )
void Builtins::Generate_OrdinaryHasInstance( TF_BUILTIN(OrdinaryHasInstance, ObjectBuiltinsAssembler) {
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node;
typedef CompareDescriptor Descriptor; typedef CompareDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* constructor = assembler.Parameter(Descriptor::kLeft); Node* constructor = Parameter(Descriptor::kLeft);
Node* object = assembler.Parameter(Descriptor::kRight); Node* object = Parameter(Descriptor::kRight);
Node* context = assembler.Parameter(Descriptor::kContext); Node* context = Parameter(Descriptor::kContext);
assembler.Return(assembler.OrdinaryHasInstance(context, constructor, object)); Return(OrdinaryHasInstance(context, constructor, object));
} }
void Builtins::Generate_GetSuperConstructor( TF_BUILTIN(GetSuperConstructor, ObjectBuiltinsAssembler) {
compiler::CodeAssemblerState* state) {
typedef compiler::Node Node;
typedef TypeofDescriptor Descriptor; typedef TypeofDescriptor Descriptor;
CodeStubAssembler assembler(state);
Node* object = assembler.Parameter(Descriptor::kObject); Node* object = Parameter(Descriptor::kObject);
Node* context = assembler.Parameter(Descriptor::kContext); Node* context = Parameter(Descriptor::kContext);
assembler.Return(assembler.GetSuperConstructor(object, context)); Return(GetSuperConstructor(object, context));
} }
} // namespace internal } // namespace internal
......
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