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 5328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5339 array->Compact(); | 5339 array->Compact(); |
5340 WeakFixedArray::Add(array, number); | 5340 WeakFixedArray::Add(array, number); |
5341 } | 5341 } |
5342 | 5342 |
5343 | 5343 |
5344 TEST(PreprocessStackTrace) { | 5344 TEST(PreprocessStackTrace) { |
5345 // Do not automatically trigger early GC. | 5345 // Do not automatically trigger early GC. |
5346 FLAG_gc_interval = -1; | 5346 FLAG_gc_interval = -1; |
5347 CcTest::InitializeVM(); | 5347 CcTest::InitializeVM(); |
5348 v8::HandleScope scope(CcTest::isolate()); | 5348 v8::HandleScope scope(CcTest::isolate()); |
5349 v8::TryCatch try_catch; | 5349 v8::TryCatch try_catch(CcTest::isolate()); |
5350 CompileRun("throw new Error();"); | 5350 CompileRun("throw new Error();"); |
5351 CHECK(try_catch.HasCaught()); | 5351 CHECK(try_catch.HasCaught()); |
5352 Isolate* isolate = CcTest::i_isolate(); | 5352 Isolate* isolate = CcTest::i_isolate(); |
5353 Handle<Object> exception = v8::Utils::OpenHandle(*try_catch.Exception()); | 5353 Handle<Object> exception = v8::Utils::OpenHandle(*try_catch.Exception()); |
5354 Handle<Name> key = isolate->factory()->stack_trace_symbol(); | 5354 Handle<Name> key = isolate->factory()->stack_trace_symbol(); |
5355 Handle<Object> stack_trace = | 5355 Handle<Object> stack_trace = |
5356 JSObject::GetProperty(exception, key).ToHandleChecked(); | 5356 JSObject::GetProperty(exception, key).ToHandleChecked(); |
5357 Handle<Object> code = | 5357 Handle<Object> code = |
5358 Object::GetElement(isolate, stack_trace, 3).ToHandleChecked(); | 5358 Object::GetElement(isolate, stack_trace, 3).ToHandleChecked(); |
5359 CHECK(code->IsCode()); | 5359 CHECK(code->IsCode()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5413 | 5413 |
5414 TEST(Regress1878) { | 5414 TEST(Regress1878) { |
5415 FLAG_allow_natives_syntax = true; | 5415 FLAG_allow_natives_syntax = true; |
5416 CcTest::InitializeVM(); | 5416 CcTest::InitializeVM(); |
5417 v8::Isolate* isolate = CcTest::isolate(); | 5417 v8::Isolate* isolate = CcTest::isolate(); |
5418 v8::HandleScope scope(isolate); | 5418 v8::HandleScope scope(isolate); |
5419 v8::Local<v8::Function> constructor = | 5419 v8::Local<v8::Function> constructor = |
5420 v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function()); | 5420 v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function()); |
5421 CcTest::global()->Set(v8_str("InternalArray"), constructor); | 5421 CcTest::global()->Set(v8_str("InternalArray"), constructor); |
5422 | 5422 |
5423 v8::TryCatch try_catch; | 5423 v8::TryCatch try_catch(isolate); |
5424 | 5424 |
5425 CompileRun( | 5425 CompileRun( |
5426 "var a = Array();" | 5426 "var a = Array();" |
5427 "for (var i = 0; i < 1000; i++) {" | 5427 "for (var i = 0; i < 1000; i++) {" |
5428 " var ai = new InternalArray(10000);" | 5428 " var ai = new InternalArray(10000);" |
5429 " if (%HaveSameMap(ai, a)) throw Error();" | 5429 " if (%HaveSameMap(ai, a)) throw Error();" |
5430 " if (!%HasFastObjectElements(ai)) throw Error();" | 5430 " if (!%HasFastObjectElements(ai)) throw Error();" |
5431 "}" | 5431 "}" |
5432 "for (var i = 0; i < 1000; i++) {" | 5432 "for (var i = 0; i < 1000; i++) {" |
5433 " var ai = new InternalArray(10000);" | 5433 " var ai = new InternalArray(10000);" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5634 size_t counter2 = 2000; | 5634 size_t counter2 = 2000; |
5635 tracer->SampleAllocation(time2, counter2, counter2); | 5635 tracer->SampleAllocation(time2, counter2, counter2); |
5636 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5636 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
5637 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); | 5637 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); |
5638 int time3 = 1000; | 5638 int time3 = 1000; |
5639 size_t counter3 = 30000; | 5639 size_t counter3 = 30000; |
5640 tracer->SampleAllocation(time3, counter3, counter3); | 5640 tracer->SampleAllocation(time3, counter3, counter3); |
5641 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); | 5641 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); |
5642 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); | 5642 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); |
5643 } | 5643 } |
OLD | NEW |