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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 { | 455 { |
456 v8::HandleScope handle_scope(v8_isolate); | 456 v8::HandleScope handle_scope(v8_isolate); |
457 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); | 457 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); |
458 // After execution, e's function context refers to the global object. | 458 // After execution, e's function context refers to the global object. |
459 CompileRun( | 459 CompileRun( |
460 "var e;" | 460 "var e;" |
461 "(function() {" | 461 "(function() {" |
462 " e = function(s) { return eval (s); }" | 462 " e = function(s) { return eval (s); }" |
463 "})();" | 463 "})();" |
464 "var o = this;" | 464 "var o = this;" |
465 "var r = Math.random();" | 465 "var r = Math.sin(0) + Math.cos(0);" |
466 "var c = Math.sin(0) + Math.cos(0);" | |
467 "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);" | 466 "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);" |
468 "var s = parseInt('12345');"); | 467 "var s = parseInt('12345');"); |
469 | 468 |
470 Vector<const uint8_t> source = ConstructSource( | 469 Vector<const uint8_t> source = ConstructSource( |
471 STATIC_CHAR_VECTOR("function g() { return [,"), | 470 STATIC_CHAR_VECTOR("function g() { return [,"), |
472 STATIC_CHAR_VECTOR("1,"), | 471 STATIC_CHAR_VECTOR("1,"), |
473 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000); | 472 STATIC_CHAR_VECTOR("];} a = g(); b = g(); b.push(1);"), 100000); |
474 v8::MaybeLocal<v8::String> source_str = v8::String::NewFromOneByte( | 473 v8::MaybeLocal<v8::String> source_str = v8::String::NewFromOneByte( |
475 v8_isolate, source.start(), v8::NewStringType::kNormal, | 474 v8_isolate, source.start(), v8::NewStringType::kNormal, |
476 source.length()); | 475 source.length()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 Handle<JSObject> global_object(context->global_object(), isolate); | 551 Handle<JSObject> global_object(context->global_object(), isolate); |
553 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o); | 552 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o); |
554 CHECK(property.is_identical_to(global_proxy)); | 553 CHECK(property.is_identical_to(global_proxy)); |
555 | 554 |
556 v8::Local<v8::Context> v8_context = v8::Utils::ToLocal(context); | 555 v8::Local<v8::Context> v8_context = v8::Utils::ToLocal(context); |
557 v8::Context::Scope context_scope(v8_context); | 556 v8::Context::Scope context_scope(v8_context); |
558 double r = CompileRun("r") | 557 double r = CompileRun("r") |
559 ->ToNumber(v8_isolate->GetCurrentContext()) | 558 ->ToNumber(v8_isolate->GetCurrentContext()) |
560 .ToLocalChecked() | 559 .ToLocalChecked() |
561 ->Value(); | 560 ->Value(); |
562 CHECK(0.0 <= r && r < 1.0); | 561 CHECK_EQ(1, r); |
563 // Math.random still works. | |
564 double random = CompileRun("Math.random()") | |
565 ->ToNumber(v8_isolate->GetCurrentContext()) | |
566 .ToLocalChecked() | |
567 ->Value(); | |
568 CHECK(0.0 <= random && random < 1.0); | |
569 double c = CompileRun("c") | |
570 ->ToNumber(v8_isolate->GetCurrentContext()) | |
571 .ToLocalChecked() | |
572 ->Value(); | |
573 CHECK_EQ(1, c); | |
574 int f = CompileRun("f()") | 562 int f = CompileRun("f()") |
575 ->ToNumber(v8_isolate->GetCurrentContext()) | 563 ->ToNumber(v8_isolate->GetCurrentContext()) |
576 .ToLocalChecked() | 564 .ToLocalChecked() |
577 ->Int32Value(v8_isolate->GetCurrentContext()) | 565 ->Int32Value(v8_isolate->GetCurrentContext()) |
578 .FromJust(); | 566 .FromJust(); |
579 CHECK_EQ(5, f); | 567 CHECK_EQ(5, f); |
580 f = CompileRun("e('f()')") | 568 f = CompileRun("e('f()')") |
581 ->ToNumber(v8_isolate->GetCurrentContext()) | 569 ->ToNumber(v8_isolate->GetCurrentContext()) |
582 .ToLocalChecked() | 570 .ToLocalChecked() |
583 ->Int32Value(v8_isolate->GetCurrentContext()) | 571 ->Int32Value(v8_isolate->GetCurrentContext()) |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 delete script_data; | 1660 delete script_data; |
1673 } | 1661 } |
1674 | 1662 |
1675 | 1663 |
1676 TEST(SerializationMemoryStats) { | 1664 TEST(SerializationMemoryStats) { |
1677 FLAG_profile_deserialization = true; | 1665 FLAG_profile_deserialization = true; |
1678 FLAG_always_opt = false; | 1666 FLAG_always_opt = false; |
1679 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1667 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
1680 delete[] blob.data; | 1668 delete[] blob.data; |
1681 } | 1669 } |
OLD | NEW |