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

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

Issue 1183733006: Keep a canonical list of shared function infos. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test 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 5908 matching lines...) Expand 10 before | Expand all | Expand 10 after
5919 const char* flag = "--turbo-filter=*"; 5919 const char* flag = "--turbo-filter=*";
5920 FlagList::SetFlagsFromString(flag, StrLength(flag)); 5920 FlagList::SetFlagsFromString(flag, StrLength(flag));
5921 FLAG_always_opt = true; 5921 FLAG_always_opt = true;
5922 FLAG_turbo_try_catch = true; 5922 FLAG_turbo_try_catch = true;
5923 FLAG_turbo_try_finally = true; 5923 FLAG_turbo_try_finally = true;
5924 5924
5925 CompileRun(test); 5925 CompileRun(test);
5926 } 5926 }
5927 5927
5928 5928
5929 static void CheckEqualSharedFunctionInfos(
5930 const v8::FunctionCallbackInfo<v8::Value>& args) {
5931 Handle<Object> obj1 = v8::Utils::OpenHandle(*args[0]);
5932 Handle<Object> obj2 = v8::Utils::OpenHandle(*args[1]);
5933 Handle<JSFunction> fun1 = Handle<JSFunction>::cast(obj1);
5934 Handle<JSFunction> fun2 = Handle<JSFunction>::cast(obj2);
5935 CHECK(fun1->shared() == fun2->shared());
5936 }
5937
5938
5939 static void RemoveCodeAndGC(const v8::FunctionCallbackInfo<v8::Value>& args) {
5940 Isolate* isolate = CcTest::i_isolate();
5941 Handle<Object> obj = v8::Utils::OpenHandle(*args[0]);
5942 Handle<JSFunction> fun = Handle<JSFunction>::cast(obj);
5943 fun->ReplaceCode(*isolate->builtins()->CompileLazy());
5944 fun->shared()->ReplaceCode(*isolate->builtins()->CompileLazy());
5945 isolate->heap()->CollectAllAvailableGarbage("remove code and gc");
5946 }
5947
5948
5949 TEST(CanonicalSharedFunctionInfo) {
5950 CcTest::InitializeVM();
5951 v8::Isolate* isolate = CcTest::isolate();
5952 v8::HandleScope scope(isolate);
5953 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
5954 global->Set(isolate, "check", v8::FunctionTemplate::New(
5955 isolate, CheckEqualSharedFunctionInfos));
5956 global->Set(isolate, "remove",
5957 v8::FunctionTemplate::New(isolate, RemoveCodeAndGC));
5958 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
5959 v8::Context::Scope cscope(context);
5960 CompileRun(
5961 "function f() { return function g() {}; }"
5962 "var g1 = f();"
5963 "remove(f);"
5964 "var g2 = f();"
5965 "check(g1, g2);");
5966
5967 CompileRun(
5968 "function f() { return (function() { return function g() {}; })(); }"
5969 "var g1 = f();"
5970 "remove(f);"
5971 "var g2 = f();"
5972 "check(g1, g2);");
5973 }
5974
5975
5929 TEST(OldGenerationAllocationThroughput) { 5976 TEST(OldGenerationAllocationThroughput) {
5930 CcTest::InitializeVM(); 5977 CcTest::InitializeVM();
5931 v8::HandleScope scope(CcTest::isolate()); 5978 v8::HandleScope scope(CcTest::isolate());
5932 Isolate* isolate = CcTest::i_isolate(); 5979 Isolate* isolate = CcTest::i_isolate();
5933 Heap* heap = isolate->heap(); 5980 Heap* heap = isolate->heap();
5934 GCTracer* tracer = heap->tracer(); 5981 GCTracer* tracer = heap->tracer();
5935 int time1 = 100; 5982 int time1 = 100;
5936 size_t counter1 = 1000; 5983 size_t counter1 = 1000;
5937 tracer->SampleAllocation(time1, 0, counter1); 5984 tracer->SampleAllocation(time1, 0, counter1);
5938 int time2 = 200; 5985 int time2 = 200;
(...skipping 24 matching lines...) Expand all
5963 size_t counter2 = 2000; 6010 size_t counter2 = 2000;
5964 tracer->SampleAllocation(time2, counter2, counter2); 6011 tracer->SampleAllocation(time2, counter2, counter2);
5965 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6012 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5966 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); 6013 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput);
5967 int time3 = 1000; 6014 int time3 = 1000;
5968 size_t counter3 = 30000; 6015 size_t counter3 = 30000;
5969 tracer->SampleAllocation(time3, counter3, counter3); 6016 tracer->SampleAllocation(time3, counter3, counter3);
5970 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 6017 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5971 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); 6018 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput);
5972 } 6019 }
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