Reviewers: danno,
Message:
PTAL
Description:
Crankshaft builtins.
Enable optimizing compiler for V8 built-ins. Also fixes an issue uncovered
in
x64 codegen.
[email protected]
Please review this at https://codereview.chromium.org/34503003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+19, -17 lines):
M src/compiler.cc
M src/debug.cc
M src/runtime.cc
M src/x64/lithium-codegen-x64.cc
M test/cctest/test-compiler.cc
M test/message/paren_in_arg_string.out
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
39524a92f9f491cdac38721b71ce283debfad41b..1ce6dab6c8440f90630b5037cc27c4d7d346159a
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -123,7 +123,7 @@ void CompilationInfo::Initialize(Isolate* isolate,
mode_ = STUB;
return;
}
- mode_ = isolate->use_crankshaft() ? mode : NONOPT;
+ mode_ = mode;
abort_due_to_dependency_ = false;
if (script_->type()->value() == Script::TYPE_NATIVE) {
MarkAsNative();
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index
c820b97fadfa62acdbf2f274bee8b99158cf6675..35970e5ee934e9eb9ff3558d98da544cfd0ebd56
100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -2106,6 +2106,7 @@ void Debug::PrepareForBreakPoints() {
if (!shared->allows_lazy_compilation()) continue;
if (!shared->script()->IsScript()) continue;
+ if (function->IsBuiltin()) continue;
if (shared->code()->gc_metadata() == active_code_marker)
continue;
Code::Kind kind = function->code()->kind();
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
b25547b23e235e64a7366110c249bb5f4de11016..1b9c914b2bdf1977521233a3c33f481dd411cc21
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -2933,19 +2933,18 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) {
source_shared->set_dont_flush(true);
// Set the code, scope info, formal parameter count, and the length
- // of the target shared function info. Set the source code of the
- // 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());
+ // of the target shared function info.
target_shared->set_scope_info(source_shared->scope_info());
target_shared->set_length(source_shared->length());
target_shared->set_formal_parameter_count(
source_shared->formal_parameter_count());
- target_shared->set_script(isolate->heap()->undefined_value());
-
- // Since we don't store the source we should never optimize this.
- target_shared->code()->set_optimizable(false);
+ target_shared->set_script(source_shared->script());
+ target_shared->set_start_position_and_type(
+ source_shared->start_position_and_type());
+ 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.
target->ReplaceCode(source_shared->code());
@@ -8346,7 +8345,7 @@ bool AllowOptimization(Isolate* isolate,
Handle<JSFunction> function) {
// If the function is not optimizable or debugger is active continue
using the
// code from the full compiler.
- if (!FLAG_crankshaft ||
+ if (!isolate->use_crankshaft() ||
function->shared()->optimization_disabled() ||
isolate->DebuggerHasBreakPoints()) {
if (FLAG_trace_opt) {
@@ -8628,7 +8627,7 @@ static bool IsSuitableForOnStackReplacement(Isolate*
isolate,
Handle<JSFunction> function,
Handle<Code> unoptimized) {
// 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
// activations of the function, it means (a) the function is directly or
// indirectly recursive and (b) an optimized invocation has been
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index
c82ef8d81b3c9274672970b06642aea6884d29e6..4327997952b82652abefaa29fa5e34a980a1e951
100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -5257,7 +5257,7 @@ void LCodeGen::EmitIsConstructCall(Register temp) {
__ Cmp(Operand(temp, StandardFrameConstants::kContextOffset),
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
__ 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.
__ bind(&check_frame_marker);
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index
156115522b9a694737dabd037958dad8dc9d4e85..9fd68e5222d697f73c2451f16df58abd984aa10e
100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -377,8 +377,10 @@ TEST(OptimizedCodeSharing) {
*v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure1"))));
Handle<JSFunction> fun2 = v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure2"))));
- CHECK(fun1->IsOptimized() || !fun1->IsOptimizable());
- CHECK(fun2->IsOptimized() || !fun2->IsOptimizable());
+ CHECK(fun1->IsOptimized()
+ || !CcTest::i_isolate()->use_crankshaft() |
| !fun1->IsOptimizable());
+ CHECK(fun2->IsOptimized()
+ || !CcTest::i_isolate()->use_crankshaft() |
| !fun2->IsOptimizable());
CHECK_EQ(fun1->code(), fun2->code());
}
}
Index: test/message/paren_in_arg_string.out
diff --git a/test/message/paren_in_arg_string.out
b/test/message/paren_in_arg_string.out
index
3bc978b965b890e2e6b2971a526232b788ed93b0..0ed59bab1e43329e129a6217fedf8a8db986869d
100644
--- a/test/message/paren_in_arg_string.out
+++ b/test/message/paren_in_arg_string.out
@@ -2,5 +2,5 @@
var paren_in_arg_string_bad = new Function(')', 'return;');
^
SyntaxError: Function arg string contains parenthesis
- at Function (<anonymous>)
- at *%(basename)s:29:31
\ No newline at end of file
+ at Function (native)
+ at *%(basename)s:29:31
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.