Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: src/runtime.cc

Issue 174392: Generate specialized constructor code for constructing simple objects (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.h ('k') | src/stub-cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 2752)
+++ src/runtime.cc (working copy)
@@ -45,6 +45,7 @@
#include "v8threads.h"
#include "smart-pointer.h"
#include "parser.h"
+#include "stub-cache.h"
namespace v8 {
namespace internal {
@@ -1235,6 +1236,9 @@
// Array, and Object, and some web code
// doesn't like seeing source code for constructors.
target->shared()->set_script(Heap::undefined_value());
+ // Clear the optimization hints related to the compiled code as these are no
+ // longer valid when the code is overwritten.
+ target->shared()->ClearThisPropertyAssignmentsInfo();
context = Handle<Context>(fun->context());
// Make sure we get a fresh copy of the literal vector to avoid
@@ -4326,11 +4330,21 @@
}
-static Handle<Code> ComputeConstructStub(Handle<Map> map) {
+static Code* ComputeConstructStub(Handle<SharedFunctionInfo> shared) {
// TODO(385): Change this to create a construct stub specialized for
// the given map to make allocation of simple objects - and maybe
// arrays - much faster.
- return Handle<Code>(Builtins::builtin(Builtins::JSConstructStubGeneric));
+ if (FLAG_inline_new
+ && shared->has_only_simple_this_property_assignments()) {
+ ConstructStubCompiler compiler;
+ Object* code = compiler.CompileConstructStub(*shared);
+ if (code->IsFailure()) {
+ return Builtins::builtin(Builtins::JSConstructStubGeneric);
+ }
+ return Code::cast(code);
+ }
+
+ return Builtins::builtin(Builtins::JSConstructStubGeneric);
}
@@ -4373,15 +4387,25 @@
}
}
+ // The function should be compiled for the optimization hints to be available.
+ if (!function->shared()->is_compiled()) {
+ CompileLazyShared(Handle<SharedFunctionInfo>(function->shared()),
+ CLEAR_EXCEPTION,
+ 0);
+ }
+
bool first_allocation = !function->has_initial_map();
Handle<JSObject> result = Factory::NewJSObject(function);
if (first_allocation) {
Handle<Map> map = Handle<Map>(function->initial_map());
- Handle<Code> stub = ComputeConstructStub(map);
+ Handle<Code> stub = Handle<Code>(
+ ComputeConstructStub(Handle<SharedFunctionInfo>(function->shared())));
function->shared()->set_construct_stub(*stub);
}
+
Counters::constructed_objects.Increment();
Counters::constructed_objects_runtime.Increment();
+
return *result;
}
@@ -7386,7 +7410,7 @@
}
-static Object* Runtime_FunctionGetAssemblerCode(Arguments args) {
+static Object* Runtime_DebugDisassembleFunction(Arguments args) {
#ifdef DEBUG
HandleScope scope;
ASSERT(args.length() == 1);
@@ -7401,6 +7425,21 @@
}
+static Object* Runtime_DebugDisassembleConstructor(Arguments args) {
+#ifdef DEBUG
+ HandleScope scope;
+ ASSERT(args.length() == 1);
+ // Get the function and make sure it is compiled.
+ CONVERT_ARG_CHECKED(JSFunction, func, 0);
+ if (!func->is_compiled() && !CompileLazy(func, KEEP_EXCEPTION)) {
+ return Failure::Exception();
+ }
+ func->shared()->construct_stub()->PrintLn();
+#endif // DEBUG
+ return Heap::undefined_value();
+}
+
+
static Object* Runtime_FunctionGetInferredName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
« no previous file with comments | « src/runtime.h ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698