| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 5906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5917 const char* flag = "--turbo-filter=*"; | 5917 const char* flag = "--turbo-filter=*"; |
| 5918 FlagList::SetFlagsFromString(flag, StrLength(flag)); | 5918 FlagList::SetFlagsFromString(flag, StrLength(flag)); |
| 5919 FLAG_always_opt = true; | 5919 FLAG_always_opt = true; |
| 5920 FLAG_turbo_try_catch = true; | 5920 FLAG_turbo_try_catch = true; |
| 5921 FLAG_turbo_try_finally = true; | 5921 FLAG_turbo_try_finally = true; |
| 5922 | 5922 |
| 5923 CompileRun(test); | 5923 CompileRun(test); |
| 5924 } | 5924 } |
| 5925 | 5925 |
| 5926 | 5926 |
| 5927 static void CheckEqualSharedFunctionInfos( | |
| 5928 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 5929 Handle<Object> obj1 = v8::Utils::OpenHandle(*args[0]); | |
| 5930 Handle<Object> obj2 = v8::Utils::OpenHandle(*args[1]); | |
| 5931 Handle<JSFunction> fun1 = Handle<JSFunction>::cast(obj1); | |
| 5932 Handle<JSFunction> fun2 = Handle<JSFunction>::cast(obj2); | |
| 5933 CHECK(fun1->shared() == fun2->shared()); | |
| 5934 } | |
| 5935 | |
| 5936 | |
| 5937 static void RemoveCodeAndGC(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 5938 Isolate* isolate = CcTest::i_isolate(); | |
| 5939 Handle<Object> obj = v8::Utils::OpenHandle(*args[0]); | |
| 5940 Handle<JSFunction> fun = Handle<JSFunction>::cast(obj); | |
| 5941 fun->ReplaceCode(*isolate->builtins()->CompileLazy()); | |
| 5942 fun->shared()->ReplaceCode(*isolate->builtins()->CompileLazy()); | |
| 5943 isolate->heap()->CollectAllAvailableGarbage("remove code and gc"); | |
| 5944 } | |
| 5945 | |
| 5946 | |
| 5947 TEST(CanonicalSharedFunctionInfo) { | |
| 5948 CcTest::InitializeVM(); | |
| 5949 v8::Isolate* isolate = CcTest::isolate(); | |
| 5950 v8::HandleScope scope(isolate); | |
| 5951 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); | |
| 5952 global->Set(isolate, "check", v8::FunctionTemplate::New( | |
| 5953 isolate, CheckEqualSharedFunctionInfos)); | |
| 5954 global->Set(isolate, "remove", | |
| 5955 v8::FunctionTemplate::New(isolate, RemoveCodeAndGC)); | |
| 5956 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); | |
| 5957 v8::Context::Scope cscope(context); | |
| 5958 CompileRun( | |
| 5959 "function f() { return function g() {}; }" | |
| 5960 "var g1 = f();" | |
| 5961 "remove(f);" | |
| 5962 "var g2 = f();" | |
| 5963 "check(g1, g2);"); | |
| 5964 | |
| 5965 CompileRun( | |
| 5966 "function f() { return (function() { return function g() {}; })(); }" | |
| 5967 "var g1 = f();" | |
| 5968 "remove(f);" | |
| 5969 "var g2 = f();" | |
| 5970 "check(g1, g2);"); | |
| 5971 } | |
| 5972 | |
| 5973 | |
| 5974 TEST(OldGenerationAllocationThroughput) { | 5927 TEST(OldGenerationAllocationThroughput) { |
| 5975 CcTest::InitializeVM(); | 5928 CcTest::InitializeVM(); |
| 5976 v8::HandleScope scope(CcTest::isolate()); | 5929 v8::HandleScope scope(CcTest::isolate()); |
| 5977 Isolate* isolate = CcTest::i_isolate(); | 5930 Isolate* isolate = CcTest::i_isolate(); |
| 5978 Heap* heap = isolate->heap(); | 5931 Heap* heap = isolate->heap(); |
| 5979 GCTracer* tracer = heap->tracer(); | 5932 GCTracer* tracer = heap->tracer(); |
| 5980 int time1 = 100; | 5933 int time1 = 100; |
| 5981 size_t counter1 = 1000; | 5934 size_t counter1 = 1000; |
| 5982 tracer->SampleAllocation(time1, 0, counter1); | 5935 tracer->SampleAllocation(time1, 0, counter1); |
| 5983 int time2 = 200; | 5936 int time2 = 200; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6008 size_t counter2 = 2000; | 5961 size_t counter2 = 2000; |
| 6009 tracer->SampleAllocation(time2, counter2, counter2); | 5962 tracer->SampleAllocation(time2, counter2, counter2); |
| 6010 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5963 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
| 6011 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); | 5964 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); |
| 6012 int time3 = 1000; | 5965 int time3 = 1000; |
| 6013 size_t counter3 = 30000; | 5966 size_t counter3 = 30000; |
| 6014 tracer->SampleAllocation(time3, counter3, counter3); | 5967 tracer->SampleAllocation(time3, counter3, counter3); |
| 6015 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5968 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
| 6016 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); | 5969 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); |
| 6017 } | 5970 } |
| OLD | NEW |