Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
[fullcodegen] Factor out VisitCallRuntime from archs.
Browse files Browse the repository at this point in the history
This makes the aforementioned visitation function independent of the
target architecture by leveraging existing abstractions.

[email protected]

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

Cr-Commit-Position: refs/heads/master@{#34833}
  • Loading branch information
mstarzinger authored and Commit bot committed Mar 16, 2016
1 parent 894bc10 commit 71ec6ec
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 426 deletions.
50 changes: 2 additions & 48 deletions src/full-codegen/arm/full-codegen-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3375,55 +3375,9 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
}


void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();

if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRuntime");
EmitLoadJSRuntimeFunction(expr);

// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);

// Restore context register.
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));

context()->DropAndPlug(1, r0);

} else {
const Runtime::Function* function = expr->function();
switch (function->function_id) {
#define CALL_INTRINSIC_GENERATOR(Name) \
case Runtime::kInline##Name: { \
Comment cmnt(masm_, "[ Inline" #Name); \
return Emit##Name(expr); \
}
FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
#undef CALL_INTRINSIC_GENERATOR
default: {
Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

// Call the C runtime function.
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(expr->function(), arg_count);
OperandStackDepthDecrement(arg_count);
context()->Plug(r0);
}
}
}
// Restore context register.
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
}


Expand Down
49 changes: 2 additions & 47 deletions src/full-codegen/arm64/full-codegen-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3194,54 +3194,9 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
}


void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();

if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRunTime");
EmitLoadJSRuntimeFunction(expr);

for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);

// Restore context register.
__ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));

context()->DropAndPlug(1, x0);

} else {
const Runtime::Function* function = expr->function();
switch (function->function_id) {
#define CALL_INTRINSIC_GENERATOR(Name) \
case Runtime::kInline##Name: { \
Comment cmnt(masm_, "[ Inline" #Name); \
return Emit##Name(expr); \
}
FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
#undef CALL_INTRINSIC_GENERATOR
default: {
Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

// Call the C runtime function.
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(expr->function(), arg_count);
OperandStackDepthDecrement(arg_count);
context()->Plug(x0);
}
}
}
// Restore context register.
__ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
}


Expand Down
43 changes: 43 additions & 0 deletions src/full-codegen/full-codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,49 @@ void FullCodeGenerator::VisitCall(Call* expr) {
#endif
}

void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();

if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRuntime");
EmitLoadJSRuntimeFunction(expr);

// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);
context()->DropAndPlug(1, result_register());

} else {
const Runtime::Function* function = expr->function();
switch (function->function_id) {
#define CALL_INTRINSIC_GENERATOR(Name) \
case Runtime::kInline##Name: { \
Comment cmnt(masm_, "[ Inline" #Name); \
return Emit##Name(expr); \
}
FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
#undef CALL_INTRINSIC_GENERATOR
default: {
Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

// Call the C runtime function.
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(expr->function(), arg_count);
OperandStackDepthDecrement(arg_count);
context()->Plug(result_register());
}
}
}
}

void FullCodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); }

Expand Down
49 changes: 2 additions & 47 deletions src/full-codegen/ia32/full-codegen-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3262,54 +3262,9 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
}


void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();

if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRuntime");
EmitLoadJSRuntimeFunction(expr);

// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);

// Restore context register.
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
context()->DropAndPlug(1, eax);

} else {
const Runtime::Function* function = expr->function();
switch (function->function_id) {
#define CALL_INTRINSIC_GENERATOR(Name) \
case Runtime::kInline##Name: { \
Comment cmnt(masm_, "[ Inline" #Name); \
return Emit##Name(expr); \
}
FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
#undef CALL_INTRINSIC_GENERATOR
default: {
Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

// Call the C runtime function.
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(expr->function(), arg_count);
OperandStackDepthDecrement(arg_count);
context()->Plug(eax);
}
}
}
// Restore context register.
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
}


Expand Down
50 changes: 2 additions & 48 deletions src/full-codegen/mips/full-codegen-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3385,55 +3385,9 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
}


void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();

if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRuntime");
EmitLoadJSRuntimeFunction(expr);

// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);

// Restore context register.
__ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));

context()->DropAndPlug(1, v0);

} else {
const Runtime::Function* function = expr->function();
switch (function->function_id) {
#define CALL_INTRINSIC_GENERATOR(Name) \
case Runtime::kInline##Name: { \
Comment cmnt(masm_, "[ Inline" #Name); \
return Emit##Name(expr); \
}
FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
#undef CALL_INTRINSIC_GENERATOR
default: {
Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

// Call the C runtime function.
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(expr->function(), arg_count);
OperandStackDepthDecrement(arg_count);
context()->Plug(v0);
}
}
}
// Restore context register.
__ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
}


Expand Down
49 changes: 2 additions & 47 deletions src/full-codegen/mips64/full-codegen-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3388,54 +3388,9 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
}


void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();

if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRuntime");
EmitLoadJSRuntimeFunction(expr);

// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);

// Restore context register.
__ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));

context()->DropAndPlug(1, v0);
} else {
const Runtime::Function* function = expr->function();
switch (function->function_id) {
#define CALL_INTRINSIC_GENERATOR(Name) \
case Runtime::kInline##Name: { \
Comment cmnt(masm_, "[ Inline" #Name); \
return Emit##Name(expr); \
}
FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
#undef CALL_INTRINSIC_GENERATOR
default: {
Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

// Call the C runtime function.
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(expr->function(), arg_count);
OperandStackDepthDecrement(arg_count);
context()->Plug(v0);
}
}
}
// Restore context register.
__ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
}


Expand Down
50 changes: 2 additions & 48 deletions src/full-codegen/ppc/full-codegen-ppc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3370,55 +3370,9 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
OperandStackDepthDecrement(arg_count + 1);
}


void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();

if (expr->is_jsruntime()) {
Comment cmnt(masm_, "[ CallRuntime");
EmitLoadJSRuntimeFunction(expr);

// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
EmitCallJSRuntimeFunction(expr);

// Restore context register.
__ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));

context()->DropAndPlug(1, r3);

} else {
const Runtime::Function* function = expr->function();
switch (function->function_id) {
#define CALL_INTRINSIC_GENERATOR(Name) \
case Runtime::kInline##Name: { \
Comment cmnt(masm_, "[ Inline" #Name); \
return Emit##Name(expr); \
}
FOR_EACH_FULL_CODE_INTRINSIC(CALL_INTRINSIC_GENERATOR)
#undef CALL_INTRINSIC_GENERATOR
default: {
Comment cmnt(masm_, "[ CallRuntime for unhandled intrinsic");
// Push the arguments ("left-to-right").
for (int i = 0; i < arg_count; i++) {
VisitForStackValue(args->at(i));
}

// Call the C runtime function.
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS);
__ CallRuntime(expr->function(), arg_count);
OperandStackDepthDecrement(arg_count);
context()->Plug(r3);
}
}
}
// Restore context register.
__ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
}


Expand Down
Loading

0 comments on commit 71ec6ec

Please sign in to comment.