Refactor optimized in hydrogen only runtime functions.

This splits all runtime function into 3 categories:
1) RUNTIME: implemented in runtime and called from both full and optimized code.
2) RUNTIME_HIDDEN: implemented in runtime, never called directly from JS builtins.
3) INLINE: inlined in both full and optimized code
4) INLINE_OPTIMIZED: inlined in optimized code, implemented in runtime for full code.

R=yangguo@chromium.org, yannguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20252 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
dslomov@chromium.org 2014-03-25 14:26:55 +00:00
parent c432f7166c
commit f66af4feb4
28 changed files with 152 additions and 147 deletions

View File

@ -76,7 +76,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 1;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kNumberToString)->entry;
Runtime::FunctionForId(Runtime::kHiddenNumberToString)->entry;
}
@ -141,7 +141,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 3;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry;
Runtime::FunctionForId(Runtime::kHiddenRegExpConstructResult)->entry;
}
@ -385,7 +385,7 @@ void StringAddStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kStringAdd)->entry;
Runtime::FunctionForId(Runtime::kHiddenStringAdd)->entry;
}
@ -2830,7 +2830,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
// Do the runtime call to execute the regexp.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
__ TailCallRuntime(Runtime::kHiddenRegExpExec, 4, 1);
// Deferred code for string handling.
// (6) Not a long external string? If yes, go to (8).
@ -3225,7 +3225,7 @@ void StringCharCodeAtGenerator::GenerateSlow(
call_helper.BeforeCall(masm);
__ SmiTag(index_);
__ Push(object_, index_);
__ CallRuntime(Runtime::kStringCharCodeAt, 2);
__ CallRuntime(Runtime::kHiddenStringCharCodeAt, 2);
__ Move(result_, r0);
call_helper.AfterCall(masm);
__ jmp(&exit_);
@ -3673,7 +3673,7 @@ void SubStringStub::Generate(MacroAssembler* masm) {
// Just jump to runtime to create the sub string.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kSubString, 3, 1);
__ TailCallRuntime(Runtime::kHiddenSubString, 3, 1);
__ bind(&single_char);
// r0: original string
@ -3831,7 +3831,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}
@ -4318,7 +4318,7 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
if (equality) {
__ TailCallRuntime(Runtime::kStringEquals, 2, 1);
} else {
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}
__ bind(&miss);

View File

@ -3404,7 +3404,7 @@ void FullCodeGenerator::EmitLog(CallRuntime* expr) {
if (CodeGenerator::ShouldGenerateLog(isolate(), args->at(0))) {
VisitForStackValue(args->at(1));
VisitForStackValue(args->at(2));
__ CallRuntime(Runtime::kLog, 2);
__ CallRuntime(Runtime::kHiddenLog, 2);
}
// Finally, we're expected to leave a value on the top of the stack.
@ -3867,7 +3867,7 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
__ bind(&not_found);
// Call runtime to perform the lookup.
__ Push(cache, key);
__ CallRuntime(Runtime::kGetFromCache, 2);
__ CallRuntime(Runtime::kHiddenGetFromCache, 2);
__ bind(&done);
context()->Plug(r0);
@ -4144,8 +4144,8 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
Handle<String> name = expr->name();
if (name->length() > 0 && name->Get(0) == '_') {
if (expr->function() != NULL &&
expr->function()->intrinsic_type == Runtime::INLINE) {
Comment cmnt(masm_, "[ InlineRuntimeCall");
EmitInlineRuntimeCall(expr);
return;

View File

@ -4463,7 +4463,7 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
__ SmiTag(index);
__ push(index);
}
CallRuntimeFromDeferred(Runtime::kStringCharCodeAt, 2, instr,
CallRuntimeFromDeferred(Runtime::kHiddenStringCharCodeAt, 2, instr,
instr->context());
__ AssertSmi(r0);
__ SmiUntag(r0);

View File

@ -80,7 +80,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = sizeof(registers) / sizeof(registers[0]);
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kNumberToString)->entry;
Runtime::FunctionForId(Runtime::kHiddenNumberToString)->entry;
}
@ -161,7 +161,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = sizeof(registers) / sizeof(registers[0]);
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry;
Runtime::FunctionForId(Runtime::kHiddenRegExpConstructResult)->entry;
}
@ -429,7 +429,7 @@ void StringAddStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = sizeof(registers) / sizeof(registers[0]);
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kStringAdd)->entry;
Runtime::FunctionForId(Runtime::kHiddenStringAdd)->entry;
}
@ -3134,7 +3134,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
__ Bind(&runtime);
__ PopCPURegList(used_callee_saved_registers);
__ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
__ TailCallRuntime(Runtime::kHiddenRegExpExec, 4, 1);
// Deferred code for string handling.
// (6) Not a long external string? If yes, go to (8).
@ -3550,7 +3550,7 @@ void StringCharCodeAtGenerator::GenerateSlow(
call_helper.BeforeCall(masm);
__ SmiTag(index_);
__ Push(object_, index_);
__ CallRuntime(Runtime::kStringCharCodeAt, 2);
__ CallRuntime(Runtime::kHiddenStringCharCodeAt, 2);
__ Mov(result_, x0);
call_helper.AfterCall(masm);
__ B(&exit_);
@ -3832,7 +3832,7 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
if (equality) {
__ TailCallRuntime(Runtime::kStringEquals, 2, 1);
} else {
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}
__ Bind(&miss);
@ -4222,7 +4222,7 @@ void SubStringStub::Generate(MacroAssembler* masm) {
__ Ret();
__ Bind(&runtime);
__ TailCallRuntime(Runtime::kSubString, 3, 1);
__ TailCallRuntime(Runtime::kHiddenSubString, 3, 1);
__ bind(&single_char);
// x1: result_length
@ -4399,7 +4399,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
// Call the runtime.
// Returns -1 (less), 0 (equal), or 1 (greater) tagged as a small integer.
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}

View File

@ -3137,7 +3137,7 @@ void FullCodeGenerator::EmitLog(CallRuntime* expr) {
if (CodeGenerator::ShouldGenerateLog(isolate(), args->at(0))) {
VisitForStackValue(args->at(1));
VisitForStackValue(args->at(2));
__ CallRuntime(Runtime::kLog, 2);
__ CallRuntime(Runtime::kHiddenLog, 2);
}
// Finally, we're expected to leave a value on the top of the stack.
@ -3598,7 +3598,7 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
// Call runtime to perform the lookup.
__ Push(cache, key);
__ CallRuntime(Runtime::kGetFromCache, 2);
__ CallRuntime(Runtime::kHiddenGetFromCache, 2);
__ Bind(&done);
context()->Plug(x0);
@ -3856,8 +3856,8 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
Handle<String> name = expr->name();
if (name->length() > 0 && name->Get(0) == '_') {
if (expr->function() != NULL &&
expr->function()->intrinsic_type == Runtime::INLINE) {
Comment cmnt(masm_, "[ InlineRuntimeCall");
EmitInlineRuntimeCall(expr);
return;
@ -3874,6 +3874,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
__ Push(x0);
// Load the function from the receiver.
Handle<String> name = expr->name();
__ Mov(x2, Operand(name));
CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());

View File

@ -5406,7 +5406,7 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
__ SmiTag(index);
__ Push(index);
CallRuntimeFromDeferred(Runtime::kStringCharCodeAt, 2, instr,
CallRuntimeFromDeferred(Runtime::kHiddenStringCharCodeAt, 2, instr,
instr->context());
__ AssertSmi(x0);
__ SmiUntag(x0);

View File

@ -952,59 +952,6 @@ void FullCodeGenerator::EmitDebugBreakInOptimizedCode(CallRuntime* expr) {
}
void FullCodeGenerator::EmitDoubleHi(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 1);
VisitForStackValue(args->at(0));
masm()->CallRuntime(Runtime::kDoubleHi, 1);
context()->Plug(result_register());
}
void FullCodeGenerator::EmitDoubleLo(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 1);
VisitForStackValue(args->at(0));
masm()->CallRuntime(Runtime::kDoubleLo, 1);
context()->Plug(result_register());
}
void FullCodeGenerator::EmitConstructDouble(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 2);
VisitForStackValue(args->at(0));
VisitForStackValue(args->at(1));
masm()->CallRuntime(Runtime::kConstructDouble, 2);
context()->Plug(result_register());
}
void FullCodeGenerator::EmitTypedArrayInitialize(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 5);
for (int i = 0; i < 5; i++) VisitForStackValue(args->at(i));
masm()->CallRuntime(Runtime::kTypedArrayInitialize, 5);
context()->Plug(result_register());
}
void FullCodeGenerator::EmitDataViewInitialize(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
ASSERT(args->length() == 4);
for (int i = 0; i < 4; i++) VisitForStackValue(args->at(i));
masm()->CallRuntime(Runtime::kDataViewInitialize, 4);
context()->Plug(result_register());
}
void FullCodeGenerator::EmitMaxSmi(CallRuntime* expr) {
ASSERT(expr->arguments()->length() == 0);
masm()->CallRuntime(Runtime::kMaxSmi, 0);
context()->Plug(result_register());
}
void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) {
switch (expr->op()) {
case Token::COMMA:

View File

@ -2069,9 +2069,10 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd(
// Fallback to the runtime to add the two strings.
Add<HPushArgument>(left);
Add<HPushArgument>(right);
Push(Add<HCallRuntime>(isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kStringAdd),
2));
Push(Add<HCallRuntime>(
isolate()->factory()->empty_string(),
Runtime::FunctionForId(Runtime::kHiddenStringAdd),
2));
}
if_sameencodingandsequential.End();
}
@ -8400,6 +8401,7 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
const HOptimizedGraphBuilder::InlineFunctionGenerator
HOptimizedGraphBuilder::kInlineFunctionGenerators[] = {
INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS)
INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS)
};
#undef INLINE_FUNCTION_GENERATOR_ADDRESS
@ -8602,7 +8604,8 @@ void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
const Runtime::Function* function = expr->function();
ASSERT(function != NULL);
if (function->intrinsic_type == Runtime::INLINE) {
if (function->intrinsic_type == Runtime::INLINE ||
function->intrinsic_type == Runtime::INLINE_OPTIMIZED) {
ASSERT(expr->name()->length() > 0);
ASSERT(expr->name()->Get(0) == '_');
// Call to an inline function.

View File

@ -2120,6 +2120,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
void Generate##Name(CallRuntime* call);
INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION)
INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_DECLARATION)
#undef INLINE_FUNCTION_GENERATOR_DECLARATION
void VisitDelete(UnaryOperation* expr);

View File

@ -81,7 +81,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 1;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kNumberToString)->entry;
Runtime::FunctionForId(Runtime::kHiddenNumberToString)->entry;
}
@ -146,7 +146,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 3;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry;
Runtime::FunctionForId(Runtime::kHiddenRegExpConstructResult)->entry;
}
@ -388,7 +388,7 @@ void StringAddStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kStringAdd)->entry;
Runtime::FunctionForId(Runtime::kHiddenStringAdd)->entry;
}
@ -1863,7 +1863,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
// Do the runtime call to execute the regexp.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
__ TailCallRuntime(Runtime::kHiddenRegExpExec, 4, 1);
// Deferred code for string handling.
// (7) Not a long external string? If yes, go to (10).
@ -3155,7 +3155,7 @@ void StringCharCodeAtGenerator::GenerateSlow(
__ push(object_);
__ SmiTag(index_);
__ push(index_);
__ CallRuntime(Runtime::kStringCharCodeAt, 2);
__ CallRuntime(Runtime::kHiddenStringCharCodeAt, 2);
if (!result_.is(eax)) {
__ mov(result_, eax);
}
@ -3551,7 +3551,7 @@ void SubStringStub::Generate(MacroAssembler* masm) {
// Just jump to runtime to create the sub string.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kSubString, 3, 1);
__ TailCallRuntime(Runtime::kHiddenSubString, 3, 1);
__ bind(&single_char);
// eax: string
@ -3733,7 +3733,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}
@ -4256,7 +4256,7 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
if (equality) {
__ TailCallRuntime(Runtime::kStringEquals, 2, 1);
} else {
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}
__ bind(&miss);

View File

@ -3360,7 +3360,7 @@ void FullCodeGenerator::EmitLog(CallRuntime* expr) {
if (CodeGenerator::ShouldGenerateLog(isolate(), args->at(0))) {
VisitForStackValue(args->at(1));
VisitForStackValue(args->at(2));
__ CallRuntime(Runtime::kLog, 2);
__ CallRuntime(Runtime::kHiddenLog, 2);
}
// Finally, we're expected to leave a value on the top of the stack.
__ mov(eax, isolate()->factory()->undefined_value());
@ -3835,7 +3835,7 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
// Call runtime to perform the lookup.
__ push(cache);
__ push(key);
__ CallRuntime(Runtime::kGetFromCache, 2);
__ CallRuntime(Runtime::kHiddenGetFromCache, 2);
__ bind(&done);
context()->Plug(eax);
@ -4145,8 +4145,8 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
Handle<String> name = expr->name();
if (name->length() > 0 && name->Get(0) == '_') {
if (expr->function() != NULL &&
expr->function()->intrinsic_type == Runtime::INLINE) {
Comment cmnt(masm_, "[ InlineRuntimeCall");
EmitInlineRuntimeCall(expr);
return;

View File

@ -4802,7 +4802,7 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
__ SmiTag(index);
__ push(index);
}
CallRuntimeFromDeferred(Runtime::kStringCharCodeAt, 2,
CallRuntimeFromDeferred(Runtime::kHiddenStringCharCodeAt, 2,
instr, instr->context());
__ AssertSmi(eax);
__ SmiUntag(eax);

View File

@ -538,7 +538,7 @@ inherits(NumberMirror, ValueMirror);
NumberMirror.prototype.toText = function() {
return %NumberToString(this.value_);
return %_NumberToString(this.value_);
};

View File

@ -2544,7 +2544,7 @@ RUNTIME_FUNCTION(MaybeObject*,
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpExec) {
HandleScope scope(isolate);
ASSERT(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
@ -2565,7 +2565,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 3);
CONVERT_SMI_ARG_CHECKED(elements_count, 0);
@ -3227,7 +3227,7 @@ MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate,
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCharCodeAt) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 2);
@ -4497,7 +4497,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_SubString) {
HandleScope scope(isolate);
ASSERT(args.length() == 3);
@ -6861,7 +6861,7 @@ bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 1);
@ -7065,7 +7065,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) {
HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(String, str1, 0);
@ -7688,7 +7688,7 @@ static Object* FlatStringCompare(String* x, String* y) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCompare) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 2);
@ -14530,7 +14530,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TryMigrateInstance) {
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_GetFromCache) {
SealHandleScope shs(isolate);
// This is only called from codegen, so checks might be more lax.
CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0);
@ -14652,6 +14652,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
#define COUNT_ENTRY(Name, argc, ressize) + 1
int entry_count = 0
RUNTIME_FUNCTION_LIST(COUNT_ENTRY)
RUNTIME_HIDDEN_FUNCTION_LIST(COUNT_ENTRY)
INLINE_FUNCTION_LIST(COUNT_ENTRY);
#undef COUNT_ENTRY
Factory* factory = isolate->factory();
@ -14678,6 +14679,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
}
inline_runtime_functions = false;
RUNTIME_FUNCTION_LIST(ADD_ENTRY)
// Calling hidden runtime functions should just throw.
RUNTIME_HIDDEN_FUNCTION_LIST(ADD_ENTRY)
inline_runtime_functions = true;
INLINE_FUNCTION_LIST(ADD_ENTRY)
#undef ADD_ENTRY
@ -14688,7 +14691,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
#endif
RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) {
RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Log) {
HandleScope handle_scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(String, format, 0);
@ -15033,16 +15036,31 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MaxSmi) {
FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
#define FH(name, number_of_args, result_size) \
{ Runtime::kHidden##name, Runtime::RUNTIME_HIDDEN, NULL, \
FUNCTION_ADDR(RuntimeHidden_##name), number_of_args, result_size },
#define I(name, number_of_args, result_size) \
{ Runtime::kInline##name, Runtime::INLINE, \
"_" #name, NULL, number_of_args, result_size },
#define IO(name, number_of_args, result_size) \
{ Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, \
"_" #name, FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
static const Runtime::Function kIntrinsicFunctions[] = {
RUNTIME_FUNCTION_LIST(F)
RUNTIME_HIDDEN_FUNCTION_LIST(FH)
INLINE_FUNCTION_LIST(I)
INLINE_OPTIMIZED_FUNCTION_LIST(IO)
};
#undef IO
#undef I
#undef FH
#undef F
@ -15051,9 +15069,11 @@ MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap,
ASSERT(dictionary != NULL);
ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0);
for (int i = 0; i < kNumFunctions; ++i) {
const char* name = kIntrinsicFunctions[i].name;
if (name == NULL) continue;
Object* name_string;
{ MaybeObject* maybe_name_string =
heap->InternalizeUtf8String(kIntrinsicFunctions[i].name);
heap->InternalizeUtf8String(name);
if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string;
}
NameDictionary* name_dictionary = NameDictionary::cast(dictionary);

View File

@ -594,14 +594,28 @@ namespace internal {
// RUNTIME_FUNCTION_LIST defines all runtime functions accessed
// either directly by id (via the code generator), or indirectly
// via a native call by name (from within JS code).
// Entries have the form F(name, number of arguments, number of return values).
#define RUNTIME_FUNCTION_LIST(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
RUNTIME_FUNCTION_LIST_DEBUG(F) \
RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F) \
INLINE_RUNTIME_FUNCTION_LIST(F)
RUNTIME_FUNCTION_LIST_I18N_SUPPORT(F)
// RUNTIME_HIDDEN_FUNCTION_LIST defines all runtime functions accessed
// by id from code generator, but not via native call by name.
// Entries have the form F(name, number of arguments, number of return values).
#define RUNTIME_HIDDEN_FUNCTION_LIST(F) \
F(NumberToString, 1, 1) \
F(RegExpConstructResult, 3, 1) \
F(RegExpExec, 4, 1) \
F(StringAdd, 2, 1) \
F(SubString, 3, 1) \
F(StringCompare, 2, 1) \
F(StringCharCodeAt, 2, 1) \
F(Log, 3, 1) \
F(GetFromCache, 2, 1)
// ----------------------------------------------------------------------------
// INLINE_FUNCTION_LIST defines all inlined functions accessed
@ -639,15 +653,6 @@ namespace internal {
F(GeneratorNext, 2, 1) \
F(GeneratorThrow, 2, 1) \
F(DebugBreakInOptimizedCode, 0, 1) \
INLINE_RUNTIME_FUNCTION_LIST(F)
// ----------------------------------------------------------------------------
// INLINE_RUNTIME_FUNCTION_LIST defines all inlined functions accessed
// with a native call of the form %_name from within JS code that also have
// a corresponding runtime function, that is called for slow cases.
// Entries have the form F(name, number of arguments, number of return values).
#define INLINE_RUNTIME_FUNCTION_LIST(F) \
F(ClassOf, 1, 1) \
F(StringCharCodeAt, 2, 1) \
F(Log, 3, 1) \
@ -657,7 +662,15 @@ namespace internal {
F(RegExpExec, 4, 1) \
F(RegExpConstructResult, 3, 1) \
F(GetFromCache, 2, 1) \
F(NumberToString, 1, 1) \
F(NumberToString, 1, 1)
// ----------------------------------------------------------------------------
// INLINE_OPTIMIZED_FUNCTION_LIST defines all inlined functions accessed
// with a native call of the form %_name from within JS code that also have
// a corresponding runtime function, that is called from non-optimized code.
// Entries have the form F(name, number of arguments, number of return values).
#define INLINE_OPTIMIZED_FUNCTION_LIST(F) \
F(DoubleHi, 1, 1) \
F(DoubleLo, 1, 1) \
F(ConstructDouble, 2, 1) \
@ -717,8 +730,14 @@ class Runtime : public AllStatic {
#define F(name, nargs, ressize) k##name,
RUNTIME_FUNCTION_LIST(F)
#undef F
#define F(name, nargs, ressize) kHidden##name,
RUNTIME_HIDDEN_FUNCTION_LIST(F)
#undef F
#define F(name, nargs, ressize) kInline##name,
INLINE_FUNCTION_LIST(F)
#undef F
#define F(name, nargs, ressize) kInlineOptimized##name,
INLINE_OPTIMIZED_FUNCTION_LIST(F)
#undef F
kNumFunctions,
kFirstInlineFunction = kInlineIsSmi
@ -726,7 +745,9 @@ class Runtime : public AllStatic {
enum IntrinsicType {
RUNTIME,
INLINE
RUNTIME_HIDDEN,
INLINE,
INLINE_OPTIMIZED
};
// Intrinsic function descriptor.

View File

@ -175,6 +175,22 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) {
RUNTIME_FUNCTION_LIST(RUNTIME_ENTRY)
#undef RUNTIME_ENTRY
#define RUNTIME_HIDDEN_ENTRY(name, nargs, ressize) \
{ RUNTIME_FUNCTION, \
Runtime::kHidden##name, \
"Runtime::Hidden" #name },
RUNTIME_HIDDEN_FUNCTION_LIST(RUNTIME_HIDDEN_ENTRY)
#undef RUNTIME_HIDDEN_ENTRY
#define INLINE_OPTIMIZED_ENTRY(name, nargs, ressize) \
{ RUNTIME_FUNCTION, \
Runtime::kInlineOptimized##name, \
"Runtime::" #name },
INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_OPTIMIZED_ENTRY)
#undef INLINE_OPTIMIZED_ENTRY
// IC utilities
#define IC_ENTRY(name) \
{ IC_UTILITY, \

View File

@ -257,7 +257,7 @@ function TypedArraySet(obj, offset) {
throw MakeTypeError("typed_array_set_negative_offset");
}
if (intOffset > %MaxSmi()) {
if (intOffset > %_MaxSmi()) {
throw MakeRangeError("typed_array_set_source_too_large");
}
switch (%TypedArraySetFastCases(this, obj, intOffset)) {

View File

@ -77,7 +77,7 @@ void NumberToStringStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 1;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kNumberToString)->entry;
Runtime::FunctionForId(Runtime::kHiddenNumberToString)->entry;
}
@ -142,7 +142,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 3;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry;
Runtime::FunctionForId(Runtime::kHiddenRegExpConstructResult)->entry;
}
@ -385,7 +385,7 @@ void StringAddStub::InitializeInterfaceDescriptor(
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
Runtime::FunctionForId(Runtime::kStringAdd)->entry;
Runtime::FunctionForId(Runtime::kHiddenStringAdd)->entry;
}
@ -1734,7 +1734,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
// Do the runtime call to execute the regexp.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
__ TailCallRuntime(Runtime::kHiddenRegExpExec, 4, 1);
// Deferred code for string handling.
// (7) Not a long external string? If yes, go to (10).
@ -3034,7 +3034,7 @@ void StringCharCodeAtGenerator::GenerateSlow(
__ Push(object_);
__ Integer32ToSmi(index_, index_);
__ Push(index_);
__ CallRuntime(Runtime::kStringCharCodeAt, 2);
__ CallRuntime(Runtime::kHiddenStringCharCodeAt, 2);
if (!result_.is(rax)) {
__ movp(result_, rax);
}
@ -3409,7 +3409,7 @@ void SubStringStub::Generate(MacroAssembler* masm) {
// Just jump to runtime to create the sub string.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kSubString, 3, 1);
__ TailCallRuntime(Runtime::kHiddenSubString, 3, 1);
__ bind(&single_char);
// rax: string
@ -3606,7 +3606,7 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer.
__ bind(&runtime);
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}
@ -4101,7 +4101,7 @@ void ICCompareStub::GenerateStrings(MacroAssembler* masm) {
if (equality) {
__ TailCallRuntime(Runtime::kStringEquals, 2, 1);
} else {
__ TailCallRuntime(Runtime::kStringCompare, 2, 1);
__ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
}
__ bind(&miss);

View File

@ -3339,7 +3339,7 @@ void FullCodeGenerator::EmitLog(CallRuntime* expr) {
if (CodeGenerator::ShouldGenerateLog(isolate(), args->at(0))) {
VisitForStackValue(args->at(1));
VisitForStackValue(args->at(2));
__ CallRuntime(Runtime::kLog, 2);
__ CallRuntime(Runtime::kHiddenLog, 2);
}
// Finally, we're expected to leave a value on the top of the stack.
__ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
@ -3814,7 +3814,7 @@ void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
// Call runtime to perform the lookup.
__ Push(cache);
__ Push(key);
__ CallRuntime(Runtime::kGetFromCache, 2);
__ CallRuntime(Runtime::kHiddenGetFromCache, 2);
__ bind(&done);
context()->Plug(rax);
@ -4145,8 +4145,8 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
Handle<String> name = expr->name();
if (name->length() > 0 && name->Get(0) == '_') {
if (expr->function() != NULL &&
expr->function()->intrinsic_type == Runtime::INLINE) {
Comment cmnt(masm_, "[ InlineRuntimeCall");
EmitInlineRuntimeCall(expr);
return;

View File

@ -4461,7 +4461,7 @@ void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
__ Push(index);
}
CallRuntimeFromDeferred(
Runtime::kStringCharCodeAt, 2, instr, instr->context());
Runtime::kHiddenStringCharCodeAt, 2, instr, instr->context());
__ AssertSmi(rax);
__ SmiToInteger32(rax, rax);
__ StoreToSafepointRegisterSlot(result, rax);

View File

@ -31,21 +31,21 @@ var S1 = "string1";
var S2 = "@@string2";
function dead1(a, b) {
var x = %StringCharCodeAt(a, 4);
var x = %_StringCharCodeAt(a, 4);
return a; // x is dead code
}
function dead2(a, b) {
var x = %StringCharCodeAt(a, 3);
var y = %StringCharCodeAt(b, 1);
var x = %_StringCharCodeAt(a, 3);
var y = %_StringCharCodeAt(b, 1);
return a; // x and y are both dead
}
function dead3(a, b) {
a = a ? "11" : "12";
b = b ? "13" : "14";
var x = %StringCharCodeAt(a, 2);
var y = %StringCharCodeAt(b, 0);
var x = %_StringCharCodeAt(a, 2);
var y = %_StringCharCodeAt(b, 0);
return a; // x and y are both dead
}

View File

@ -161,7 +161,6 @@ var knownProblems = {
"CreateArrayLiteralBoilerplate": true,
"IS_VAR": true,
"ResolvePossiblyDirectEval": true,
"Log": true,
"DeclareGlobals": true,
"ArrayConstructor": true,
"InternalArrayConstructor": true,

View File

@ -161,7 +161,6 @@ var knownProblems = {
"CreateArrayLiteralBoilerplate": true,
"IS_VAR": true,
"ResolvePossiblyDirectEval": true,
"Log": true,
"DeclareGlobals": true,
"ArrayConstructor": true,
"InternalArrayConstructor": true,

View File

@ -161,7 +161,6 @@ var knownProblems = {
"CreateArrayLiteralBoilerplate": true,
"IS_VAR": true,
"ResolvePossiblyDirectEval": true,
"Log": true,
"DeclareGlobals": true,
"ArrayConstructor": true,
"InternalArrayConstructor": true,

View File

@ -161,7 +161,6 @@ var knownProblems = {
"CreateArrayLiteralBoilerplate": true,
"IS_VAR": true,
"ResolvePossiblyDirectEval": true,
"Log": true,
"DeclareGlobals": true,
"ArrayConstructor": true,
"InternalArrayConstructor": true,

View File

@ -55,7 +55,7 @@ function TestGeneratorObject() {
var iter = g();
assertSame(g.prototype, Object.getPrototypeOf(iter));
assertTrue(iter instanceof g);
assertEquals("Generator", %ClassOf(iter));
assertEquals("Generator", %_ClassOf(iter));
assertEquals("[object Generator]", String(iter));
assertEquals([], Object.getOwnPropertyNames(iter));
assertTrue(iter !== g());
@ -64,7 +64,7 @@ function TestGeneratorObject() {
iter = new g();
assertSame(g.prototype, Object.getPrototypeOf(iter));
assertTrue(iter instanceof g);
assertEquals("Generator", %ClassOf(iter));
assertEquals("Generator", %_ClassOf(iter));
assertEquals("[object Generator]", String(iter));
assertEquals([], Object.getOwnPropertyNames(iter));
assertTrue(iter !== new g());

View File

@ -26,7 +26,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --nostress-opt --allow-natives-syntax --mock-arraybuffer-allocator
var maxSize = %MaxSmi() + 1;
var maxSize = %_MaxSmi() + 1;
var ab;
// Allocate the largest ArrayBuffer we can on this architecture.

View File

@ -27,7 +27,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --nostress-opt --allow-natives-syntax
var maxSize = %MaxSmi() + 1;
var maxSize = %_MaxSmi() + 1;
function TestArray(constr) {
assertThrows(function() {
new constr(maxSize);