Commit 81f76571 authored by gsathya's avatar gsathya Committed by Commit bot

[builtins] move PromiseBuiltinsAssembler to it's own header file

BUG=v8:5343

Review-Url: https://codereview.chromium.org/2585133002
Cr-Commit-Position: refs/heads/master@{#41816}
parent dc03ed58
......@@ -960,6 +960,7 @@ v8_source_set("v8_base") {
"src/builtins/builtins-number.cc",
"src/builtins/builtins-object.cc",
"src/builtins/builtins-promise.cc",
"src/builtins/builtins-promise.h",
"src/builtins/builtins-proxy.cc",
"src/builtins/builtins-reflect.cc",
"src/builtins/builtins-regexp.cc",
......
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/builtins/builtins-promise.h"
#include "src/builtins/builtins-utils.h"
#include "src/builtins/builtins.h"
#include "src/code-factory.h"
......@@ -15,36 +16,6 @@ typedef compiler::Node Node;
typedef CodeStubAssembler::ParameterMode ParameterMode;
typedef compiler::CodeAssemblerState CodeAssemblerState;
class PromiseBuiltinsAssembler : public CodeStubAssembler {
public:
explicit PromiseBuiltinsAssembler(CodeAssemblerState* state)
: CodeStubAssembler(state) {}
protected:
Node* ThrowIfNotJSReceiver(Node* context, Node* value,
MessageTemplate::Template msg_template);
Node* SpeciesConstructor(Node* context, Node* object,
Node* default_constructor);
Node* PromiseHasHandler(Node* promise);
void PromiseSetHasHandler(Node* promise);
void AppendPromiseCallback(int offset, compiler::Node* promise,
compiler::Node* value);
Node* InternalPerformPromiseThen(Node* context, Node* promise,
Node* on_resolve, Node* on_reject,
Node* deferred);
void InternalResolvePromise(Node* context, Node* promise, Node* result,
Label* out);
void BranchIfFastPath(Node* context, Node* promise, Label* if_isunmodified,
Label* if_ismodified);
};
Node* PromiseBuiltinsAssembler::ThrowIfNotJSReceiver(
Node* context, Node* value, MessageTemplate::Template msg_template) {
Label out(this), throw_exception(this, Label::kDeferred);
......
// Copyright 2016 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.
#include "src/code-stub-assembler.h"
namespace v8 {
namespace internal {
typedef compiler::Node Node;
typedef CodeStubAssembler::ParameterMode ParameterMode;
typedef compiler::CodeAssemblerState CodeAssemblerState;
class PromiseBuiltinsAssembler : public CodeStubAssembler {
public:
explicit PromiseBuiltinsAssembler(CodeAssemblerState* state)
: CodeStubAssembler(state) {}
Node* ThrowIfNotJSReceiver(Node* context, Node* value,
MessageTemplate::Template msg_template);
Node* SpeciesConstructor(Node* context, Node* object,
Node* default_constructor);
Node* PromiseHasHandler(Node* promise);
void PromiseSetHasHandler(Node* promise);
void AppendPromiseCallback(int offset, compiler::Node* promise,
compiler::Node* value);
Node* InternalPerformPromiseThen(Node* context, Node* promise,
Node* on_resolve, Node* on_reject,
Node* deferred);
void InternalResolvePromise(Node* context, Node* promise, Node* result,
Label* out);
void BranchIfFastPath(Node* context, Node* promise, Label* if_isunmodified,
Label* if_ismodified);
};
} // namespace internal
} // namespace v8
......@@ -499,6 +499,7 @@
'builtins/builtins-number.cc',
'builtins/builtins-object.cc',
'builtins/builtins-promise.cc',
'builtins/builtins-promise.h',
'builtins/builtins-proxy.cc',
'builtins/builtins-reflect.cc',
'builtins/builtins-regexp.cc',
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "src/base/utils/random-number-generator.h"
#include "src/builtins/builtins-promise.h"
#include "src/code-factory.h"
#include "src/code-stub-assembler.h"
#include "src/compiler/node.h"
......@@ -1974,5 +1975,26 @@ TEST(IsPrivateSymbol) {
CHECK_EQ(isolate->heap()->true_value(), *result);
}
TEST(PromiseHasHandler) {
Isolate* isolate(CcTest::InitIsolateOnce());
const int kNumParams = 1;
CodeAssemblerTester data(isolate, kNumParams);
PromiseBuiltinsAssembler m(data.state());
Node* const context = m.Parameter(kNumParams + 2);
Node* const promise = m.AllocateJSPromise(context);
m.PromiseInit(promise);
m.Return(m.SelectBooleanConstant(m.PromiseHasHandler(promise)));
Handle<Code> code = data.GenerateCode();
CHECK(!code.is_null());
FunctionTester ft(code, kNumParams);
Handle<Object> result =
ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
CHECK_EQ(isolate->heap()->false_value(), *result);
}
} // namespace internal
} // namespace v8
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