From: dslomov@chromium.org Date: Tue, 25 Mar 2014 14:26:55 +0000 (+0000) Subject: Refactor optimized in hydrogen only runtime functions. X-Git-Tag: upstream/4.7.83~10010 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f66af4feb4f5ea9d8852e3f9dbd04bd55f1e58ca;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index b3df94e..759e1b2 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -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); diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index e2753a8..8b0a715 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -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(¬_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 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; diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 0fe38a0..9f27b16 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -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); diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index b512e42..88bffe3 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -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); } diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 272e1c7..768a8ae 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -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 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 name = expr->name(); __ Mov(x2, Operand(name)); CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); diff --git a/src/arm64/lithium-codegen-arm64.cc b/src/arm64/lithium-codegen-arm64.cc index 41ae711..5b0b018 100644 --- a/src/arm64/lithium-codegen-arm64.cc +++ b/src/arm64/lithium-codegen-arm64.cc @@ -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); diff --git a/src/full-codegen.cc b/src/full-codegen.cc index 0229c74..1299023 100644 --- a/src/full-codegen.cc +++ b/src/full-codegen.cc @@ -952,59 +952,6 @@ void FullCodeGenerator::EmitDebugBreakInOptimizedCode(CallRuntime* expr) { } -void FullCodeGenerator::EmitDoubleHi(CallRuntime* expr) { - ZoneList* 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* 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* 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* 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* 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: diff --git a/src/hydrogen.cc b/src/hydrogen.cc index c669cc2..03d4ff9 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -2069,9 +2069,10 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd( // Fallback to the runtime to add the two strings. Add(left); Add(right); - Push(Add(isolate()->factory()->empty_string(), - Runtime::FunctionForId(Runtime::kStringAdd), - 2)); + Push(Add( + 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. diff --git a/src/hydrogen.h b/src/hydrogen.h index d0bfa02..7fcadea 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -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); diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index 02af639..e834fc0 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -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); diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index b05b888..d51de08 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -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 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; diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 9afde8e..aab2c96 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -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); diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js index b07d1fe..d413b09 100644 --- a/src/mirror-debugger.js +++ b/src/mirror-debugger.js @@ -538,7 +538,7 @@ inherits(NumberMirror, ValueMirror); NumberMirror.prototype.toText = function() { - return %NumberToString(this.value_); + return %_NumberToString(this.value_); }; diff --git a/src/runtime.cc b/src/runtime.cc index 2e4c993..229eb89 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -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); diff --git a/src/runtime.h b/src/runtime.h index d70afd9..7c74999 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -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,16 +730,24 @@ 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 }; enum IntrinsicType { RUNTIME, - INLINE + RUNTIME_HIDDEN, + INLINE, + INLINE_OPTIMIZED }; // Intrinsic function descriptor. diff --git a/src/serialize.cc b/src/serialize.cc index 7e9f4f5..219761e 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -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, \ diff --git a/src/typedarray.js b/src/typedarray.js index a7a6d87..d13ee61 100644 --- a/src/typedarray.js +++ b/src/typedarray.js @@ -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)) { diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 17bdc42..37c7415 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -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); diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 8eb6092..a5ac4e6 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -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 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; diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index b5e0339..5773fd5 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -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); diff --git a/test/mjsunit/compiler/dead-string-char-code-at.js b/test/mjsunit/compiler/dead-string-char-code-at.js index 56835ce..9f01541 100644 --- a/test/mjsunit/compiler/dead-string-char-code-at.js +++ b/test/mjsunit/compiler/dead-string-char-code-at.js @@ -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 } diff --git a/test/mjsunit/fuzz-natives-part1.js b/test/mjsunit/fuzz-natives-part1.js index 1bbe49e..63aca1b 100644 --- a/test/mjsunit/fuzz-natives-part1.js +++ b/test/mjsunit/fuzz-natives-part1.js @@ -161,7 +161,6 @@ var knownProblems = { "CreateArrayLiteralBoilerplate": true, "IS_VAR": true, "ResolvePossiblyDirectEval": true, - "Log": true, "DeclareGlobals": true, "ArrayConstructor": true, "InternalArrayConstructor": true, diff --git a/test/mjsunit/fuzz-natives-part2.js b/test/mjsunit/fuzz-natives-part2.js index 394c2d7..35d843f 100644 --- a/test/mjsunit/fuzz-natives-part2.js +++ b/test/mjsunit/fuzz-natives-part2.js @@ -161,7 +161,6 @@ var knownProblems = { "CreateArrayLiteralBoilerplate": true, "IS_VAR": true, "ResolvePossiblyDirectEval": true, - "Log": true, "DeclareGlobals": true, "ArrayConstructor": true, "InternalArrayConstructor": true, diff --git a/test/mjsunit/fuzz-natives-part3.js b/test/mjsunit/fuzz-natives-part3.js index 28c24b0..c9ece59 100644 --- a/test/mjsunit/fuzz-natives-part3.js +++ b/test/mjsunit/fuzz-natives-part3.js @@ -161,7 +161,6 @@ var knownProblems = { "CreateArrayLiteralBoilerplate": true, "IS_VAR": true, "ResolvePossiblyDirectEval": true, - "Log": true, "DeclareGlobals": true, "ArrayConstructor": true, "InternalArrayConstructor": true, diff --git a/test/mjsunit/fuzz-natives-part4.js b/test/mjsunit/fuzz-natives-part4.js index 2a336ca..97d08bd 100644 --- a/test/mjsunit/fuzz-natives-part4.js +++ b/test/mjsunit/fuzz-natives-part4.js @@ -161,7 +161,6 @@ var knownProblems = { "CreateArrayLiteralBoilerplate": true, "IS_VAR": true, "ResolvePossiblyDirectEval": true, - "Log": true, "DeclareGlobals": true, "ArrayConstructor": true, "InternalArrayConstructor": true, diff --git a/test/mjsunit/harmony/generators-objects.js b/test/mjsunit/harmony/generators-objects.js index bb29bed..c1cda07 100644 --- a/test/mjsunit/harmony/generators-objects.js +++ b/test/mjsunit/harmony/generators-objects.js @@ -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()); diff --git a/test/mjsunit/regress/regress-319722-ArrayBuffer.js b/test/mjsunit/regress/regress-319722-ArrayBuffer.js index 4a48a61..9a24fc5 100644 --- a/test/mjsunit/regress/regress-319722-ArrayBuffer.js +++ b/test/mjsunit/regress/regress-319722-ArrayBuffer.js @@ -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. diff --git a/test/mjsunit/regress/regress-319722-TypedArrays.js b/test/mjsunit/regress/regress-319722-TypedArrays.js index 0445e2d..e497aec 100644 --- a/test/mjsunit/regress/regress-319722-TypedArrays.js +++ b/test/mjsunit/regress/regress-319722-TypedArrays.js @@ -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);