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

Side by Side Diff: test/cctest/test-heap.cc

Issue 1211453002: Reland "Keep a canonical list of shared function infos." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix alwaysopt Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « src/x87/full-codegen-x87.cc ('k') | test/mjsunit/regress/regress-4121.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
5927 TEST(OldGenerationAllocationThroughput) { 5974 TEST(OldGenerationAllocationThroughput) {
5928 CcTest::InitializeVM(); 5975 CcTest::InitializeVM();
5929 v8::HandleScope scope(CcTest::isolate()); 5976 v8::HandleScope scope(CcTest::isolate());
5930 Isolate* isolate = CcTest::i_isolate(); 5977 Isolate* isolate = CcTest::i_isolate();
5931 Heap* heap = isolate->heap(); 5978 Heap* heap = isolate->heap();
5932 GCTracer* tracer = heap->tracer(); 5979 GCTracer* tracer = heap->tracer();
5933 int time1 = 100; 5980 int time1 = 100;
5934 size_t counter1 = 1000; 5981 size_t counter1 = 1000;
5935 tracer->SampleAllocation(time1, 0, counter1); 5982 tracer->SampleAllocation(time1, 0, counter1);
5936 int time2 = 200; 5983 int time2 = 200;
(...skipping 24 matching lines...) Expand all
5961 size_t counter2 = 2000; 6008 size_t counter2 = 2000;
5962 tracer->SampleAllocation(time2, counter2, counter2); 6009 tracer->SampleAllocation(time2, counter2, counter2);
5963 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6010 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5964 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); 6011 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput);
5965 int time3 = 1000; 6012 int time3 = 1000;
5966 size_t counter3 = 30000; 6013 size_t counter3 = 30000;
5967 tracer->SampleAllocation(time3, counter3, counter3); 6014 tracer->SampleAllocation(time3, counter3, counter3);
5968 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6015 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5969 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); 6016 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput);
5970 } 6017 }
OLDNEW
« no previous file with comments | « src/x87/full-codegen-x87.cc ('k') | test/mjsunit/regress/regress-4121.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698