Commit 42f85b53 authored by dslomov@chromium.org's avatar dslomov@chromium.org

Crankshaft builtins.

Enable optimizing compiler for V8 built-ins. Also fixes an issue uncovered in
x64 codegen.

R=danno@chromium.org, mstarzinger@chromium.org, svenpanne@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17334 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e942696a
...@@ -123,7 +123,7 @@ void CompilationInfo::Initialize(Isolate* isolate, ...@@ -123,7 +123,7 @@ void CompilationInfo::Initialize(Isolate* isolate,
mode_ = STUB; mode_ = STUB;
return; return;
} }
mode_ = isolate->use_crankshaft() ? mode : NONOPT; mode_ = mode;
abort_due_to_dependency_ = false; abort_due_to_dependency_ = false;
if (script_->type()->value() == Script::TYPE_NATIVE) { if (script_->type()->value() == Script::TYPE_NATIVE) {
MarkAsNative(); MarkAsNative();
......
...@@ -2106,6 +2106,7 @@ void Debug::PrepareForBreakPoints() { ...@@ -2106,6 +2106,7 @@ void Debug::PrepareForBreakPoints() {
if (!shared->allows_lazy_compilation()) continue; if (!shared->allows_lazy_compilation()) continue;
if (!shared->script()->IsScript()) continue; if (!shared->script()->IsScript()) continue;
if (function->IsBuiltin()) continue;
if (shared->code()->gc_metadata() == active_code_marker) continue; if (shared->code()->gc_metadata() == active_code_marker) continue;
Code::Kind kind = function->code()->kind(); Code::Kind kind = function->code()->kind();
......
...@@ -2933,19 +2933,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { ...@@ -2933,19 +2933,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) {
source_shared->set_dont_flush(true); source_shared->set_dont_flush(true);
// Set the code, scope info, formal parameter count, and the length // Set the code, scope info, formal parameter count, and the length
// of the target shared function info. Set the source code of the // of the target shared function info.
// target function to undefined. SetCode is only used for built-in
// constructors like String, Array, and Object, and some web code
// doesn't like seeing source code for constructors.
target_shared->ReplaceCode(source_shared->code()); target_shared->ReplaceCode(source_shared->code());
target_shared->set_scope_info(source_shared->scope_info()); target_shared->set_scope_info(source_shared->scope_info());
target_shared->set_length(source_shared->length()); target_shared->set_length(source_shared->length());
target_shared->set_formal_parameter_count( target_shared->set_formal_parameter_count(
source_shared->formal_parameter_count()); source_shared->formal_parameter_count());
target_shared->set_script(isolate->heap()->undefined_value()); target_shared->set_script(source_shared->script());
target_shared->set_start_position_and_type(
// Since we don't store the source we should never optimize this. source_shared->start_position_and_type());
target_shared->code()->set_optimizable(false); target_shared->set_end_position(source_shared->end_position());
bool was_native = target_shared->native();
target_shared->set_compiler_hints(source_shared->compiler_hints());
target_shared->set_native(was_native);
// Set the code of the target function. // Set the code of the target function.
target->ReplaceCode(source_shared->code()); target->ReplaceCode(source_shared->code());
...@@ -8346,7 +8346,7 @@ bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) { ...@@ -8346,7 +8346,7 @@ bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) {
// If the function is not optimizable or debugger is active continue using the // If the function is not optimizable or debugger is active continue using the
// code from the full compiler. // code from the full compiler.
if (!FLAG_crankshaft || if (!isolate->use_crankshaft() ||
function->shared()->optimization_disabled() || function->shared()->optimization_disabled() ||
isolate->DebuggerHasBreakPoints()) { isolate->DebuggerHasBreakPoints()) {
if (FLAG_trace_opt) { if (FLAG_trace_opt) {
...@@ -8628,7 +8628,7 @@ static bool IsSuitableForOnStackReplacement(Isolate* isolate, ...@@ -8628,7 +8628,7 @@ static bool IsSuitableForOnStackReplacement(Isolate* isolate,
Handle<JSFunction> function, Handle<JSFunction> function,
Handle<Code> unoptimized) { Handle<Code> unoptimized) {
// Keep track of whether we've succeeded in optimizing. // Keep track of whether we've succeeded in optimizing.
if (!unoptimized->optimizable()) return false; if (!isolate->use_crankshaft() || !unoptimized->optimizable()) return false;
// If we are trying to do OSR when there are already optimized // If we are trying to do OSR when there are already optimized
// activations of the function, it means (a) the function is directly or // activations of the function, it means (a) the function is directly or
// indirectly recursive and (b) an optimized invocation has been // indirectly recursive and (b) an optimized invocation has been
......
...@@ -5249,7 +5249,7 @@ void LCodeGen::EmitIsConstructCall(Register temp) { ...@@ -5249,7 +5249,7 @@ void LCodeGen::EmitIsConstructCall(Register temp) {
__ Cmp(Operand(temp, StandardFrameConstants::kContextOffset), __ Cmp(Operand(temp, StandardFrameConstants::kContextOffset),
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ j(not_equal, &check_frame_marker, Label::kNear); __ j(not_equal, &check_frame_marker, Label::kNear);
__ movq(temp, Operand(rax, StandardFrameConstants::kCallerFPOffset)); __ movq(temp, Operand(temp, StandardFrameConstants::kCallerFPOffset));
// Check the marker in the calling frame. // Check the marker in the calling frame.
__ bind(&check_frame_marker); __ bind(&check_frame_marker);
......
...@@ -377,8 +377,10 @@ TEST(OptimizedCodeSharing) { ...@@ -377,8 +377,10 @@ TEST(OptimizedCodeSharing) {
*v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure1")))); *v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure1"))));
Handle<JSFunction> fun2 = v8::Utils::OpenHandle( Handle<JSFunction> fun2 = v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure2")))); *v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure2"))));
CHECK(fun1->IsOptimized() || !fun1->IsOptimizable()); CHECK(fun1->IsOptimized()
CHECK(fun2->IsOptimized() || !fun2->IsOptimizable()); || !CcTest::i_isolate()->use_crankshaft() || !fun1->IsOptimizable());
CHECK(fun2->IsOptimized()
|| !CcTest::i_isolate()->use_crankshaft() || !fun2->IsOptimizable());
CHECK_EQ(fun1->code(), fun2->code()); CHECK_EQ(fun1->code(), fun2->code());
} }
} }
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
var paren_in_arg_string_bad = new Function(')', 'return;'); var paren_in_arg_string_bad = new Function(')', 'return;');
^ ^
SyntaxError: Function arg string contains parenthesis SyntaxError: Function arg string contains parenthesis
at Function (<anonymous>) at Function (native)
at *%(basename)s:29:31 at *%(basename)s:29:31
\ No newline at end of file
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