diff options
Diffstat (limited to 'deps/v8/src/runtime.cc')
-rw-r--r-- | deps/v8/src/runtime.cc | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/deps/v8/src/runtime.cc b/deps/v8/src/runtime.cc index 845ac6308c..f772d32d9d 100644 --- a/deps/v8/src/runtime.cc +++ b/deps/v8/src/runtime.cc @@ -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 @@ static Object* Runtime_SetCode(Arguments args) { // 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 @@ -4054,7 +4058,7 @@ static Object* Runtime_Math_acos(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(acos(x)); + return TranscendentalCache::Get(TranscendentalCache::ACOS, x); } @@ -4063,7 +4067,7 @@ static Object* Runtime_Math_asin(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(asin(x)); + return TranscendentalCache::Get(TranscendentalCache::ASIN, x); } @@ -4072,7 +4076,7 @@ static Object* Runtime_Math_atan(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(atan(x)); + return TranscendentalCache::Get(TranscendentalCache::ATAN, x); } @@ -4113,7 +4117,7 @@ static Object* Runtime_Math_cos(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(cos(x)); + return TranscendentalCache::Get(TranscendentalCache::COS, x); } @@ -4122,7 +4126,7 @@ static Object* Runtime_Math_exp(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(exp(x)); + return TranscendentalCache::Get(TranscendentalCache::EXP, x); } @@ -4140,7 +4144,7 @@ static Object* Runtime_Math_log(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(log(x)); + return TranscendentalCache::Get(TranscendentalCache::LOG, x); } @@ -4228,7 +4232,7 @@ static Object* Runtime_Math_sin(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(sin(x)); + return TranscendentalCache::Get(TranscendentalCache::SIN, x); } @@ -4246,7 +4250,7 @@ static Object* Runtime_Math_tan(Arguments args) { ASSERT(args.length() == 1); CONVERT_DOUBLE_CHECKED(x, args[0]); - return Heap::AllocateHeapNumber(tan(x)); + return TranscendentalCache::Get(TranscendentalCache::TAN, x); } @@ -4326,11 +4330,21 @@ static Object* Runtime_NewClosure(Arguments args) { } -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 @@ static Object* Runtime_NewObject(Arguments args) { } } + // 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_SystemBreak(Arguments args) { } -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_FunctionGetAssemblerCode(Arguments args) { } +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); |