From 3eb589976a979fa80f0934a3754ebc79d289b713 Mon Sep 17 00:00:00 2001 From: dcarney Date: Tue, 20 Jan 2015 05:27:46 -0800 Subject: [PATCH] fix debug checks for api callbacks returning symbols BUG= Review URL: https://codereview.chromium.org/854363003 Cr-Commit-Position: refs/heads/master@{#26156} --- src/ia32/macro-assembler-ia32.cc | 4 ++-- src/x64/macro-assembler-x64.cc | 4 ++-- test/cctest/test-api.cc | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 3c4349ebf8..53be8c7f2a 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -2189,8 +2189,8 @@ void MacroAssembler::CallApiFunctionAndReturn( JumpIfSmi(return_value, &ok, Label::kNear); mov(map, FieldOperand(return_value, HeapObject::kMapOffset)); - CmpInstanceType(map, FIRST_NONSTRING_TYPE); - j(below, &ok, Label::kNear); + CmpInstanceType(map, LAST_NAME_TYPE); + j(below_equal, &ok, Label::kNear); CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE); j(above_equal, &ok, Label::kNear); diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 2932ec893c..97e5690c8d 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -805,8 +805,8 @@ void MacroAssembler::CallApiFunctionAndReturn( JumpIfSmi(return_value, &ok, Label::kNear); movp(map, FieldOperand(return_value, HeapObject::kMapOffset)); - CmpInstanceType(map, FIRST_NONSTRING_TYPE); - j(below, &ok, Label::kNear); + CmpInstanceType(map, LAST_NAME_TYPE); + j(below_equal, &ok, Label::kNear); CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE); j(above_equal, &ok, Label::kNear); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 9611ddb991..9b3bd3ddbc 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -23648,6 +23648,32 @@ TEST(FunctionCallOptimizationMultipleArgs) { } +static void ReturnsSymbolCallback( + const v8::FunctionCallbackInfo& info) { + info.GetReturnValue().Set(v8::Symbol::New(info.GetIsolate())); +} + + +TEST(ApiCallbackCanReturnSymbols) { + i::FLAG_allow_natives_syntax = true; + LocalContext context; + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); + Handle global = context->Global(); + Local function = Function::New(isolate, ReturnsSymbolCallback); + global->Set(v8_str("x"), function); + CompileRun( + "function x_wrap() {\n" + " for (var i = 0; i < 5; i++) {\n" + " x();\n" + " }\n" + "}\n" + "x_wrap();\n" + "%OptimizeFunctionOnNextCall(x_wrap);" + "x_wrap();\n"); +} + + static const char* last_event_message; static int last_event_status; void StoringEventLoggerCallback(const char* message, int status) {