OLD | NEW |
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 { | 536 { |
537 v8::HandleScope handle_scope(v8_isolate); | 537 v8::HandleScope handle_scope(v8_isolate); |
538 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); | 538 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); |
539 // After execution, e's function context refers to the global object. | 539 // After execution, e's function context refers to the global object. |
540 CompileRun( | 540 CompileRun( |
541 "var e;" | 541 "var e;" |
542 "(function() {" | 542 "(function() {" |
543 " e = function(s) { return eval (s); }" | 543 " e = function(s) { return eval (s); }" |
544 "})();" | 544 "})();" |
545 "var o = this;" | 545 "var o = this;" |
546 "var r = Math.random() + Math.cos(0);" | 546 "var r = Math.sin(0) + Math.cos(0);" |
547 "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);" | 547 "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);" |
548 "var s = parseInt('12345');"); | 548 "var s = parseInt('12345');"); |
549 | 549 |
550 Vector<const uint8_t> source = ConstructSource( | 550 Vector<const uint8_t> source = ConstructSource( |
551 STATIC_CHAR_VECTOR("function g() { return [,"), | 551 STATIC_CHAR_VECTOR("function g() { return [,"), |
552 STATIC_CHAR_VECTOR("1,"), | 552 STATIC_CHAR_VECTOR("1,"), |
553 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000); | 553 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000); |
554 v8::MaybeLocal<v8::String> source_str = v8::String::NewFromOneByte( | 554 v8::MaybeLocal<v8::String> source_str = v8::String::NewFromOneByte( |
555 v8_isolate, source.start(), v8::NewStringType::kNormal, | 555 v8_isolate, source.start(), v8::NewStringType::kNormal, |
556 source.length()); | 556 source.length()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 Handle<JSObject> global_object(context->global_object(), isolate); | 647 Handle<JSObject> global_object(context->global_object(), isolate); |
648 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o); | 648 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o); |
649 CHECK(property.is_identical_to(global_proxy)); | 649 CHECK(property.is_identical_to(global_proxy)); |
650 | 650 |
651 v8::Local<v8::Context> v8_context = v8::Utils::ToLocal(context); | 651 v8::Local<v8::Context> v8_context = v8::Utils::ToLocal(context); |
652 v8::Context::Scope context_scope(v8_context); | 652 v8::Context::Scope context_scope(v8_context); |
653 double r = CompileRun("r") | 653 double r = CompileRun("r") |
654 ->ToNumber(v8_isolate->GetCurrentContext()) | 654 ->ToNumber(v8_isolate->GetCurrentContext()) |
655 .ToLocalChecked() | 655 .ToLocalChecked() |
656 ->Value(); | 656 ->Value(); |
657 CHECK(r >= 1 && r <= 2); | 657 CHECK_EQ(1, r); |
658 int f = CompileRun("f()") | 658 int f = CompileRun("f()") |
659 ->ToNumber(v8_isolate->GetCurrentContext()) | 659 ->ToNumber(v8_isolate->GetCurrentContext()) |
660 .ToLocalChecked() | 660 .ToLocalChecked() |
661 ->Int32Value(v8_isolate->GetCurrentContext()) | 661 ->Int32Value(v8_isolate->GetCurrentContext()) |
662 .FromJust(); | 662 .FromJust(); |
663 CHECK_EQ(5, f); | 663 CHECK_EQ(5, f); |
664 f = CompileRun("e('f()')") | 664 f = CompileRun("e('f()')") |
665 ->ToNumber(v8_isolate->GetCurrentContext()) | 665 ->ToNumber(v8_isolate->GetCurrentContext()) |
666 .ToLocalChecked() | 666 .ToLocalChecked() |
667 ->Int32Value(v8_isolate->GetCurrentContext()) | 667 ->Int32Value(v8_isolate->GetCurrentContext()) |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 delete script_data; | 1781 delete script_data; |
1782 } | 1782 } |
1783 | 1783 |
1784 | 1784 |
1785 TEST(SerializationMemoryStats) { | 1785 TEST(SerializationMemoryStats) { |
1786 FLAG_profile_deserialization = true; | 1786 FLAG_profile_deserialization = true; |
1787 FLAG_always_opt = false; | 1787 FLAG_always_opt = false; |
1788 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1788 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
1789 delete[] blob.data; | 1789 delete[] blob.data; |
1790 } | 1790 } |
OLD | NEW |