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 24640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24651 " result = 1;\n" | 24651 " result = 1;\n" |
24652 " } catch (e) {\n" | 24652 " } catch (e) {\n" |
24653 " }\n" | 24653 " }\n" |
24654 " test(d+1);\n" | 24654 " test(d+1);\n" |
24655 "}\n" | 24655 "}\n" |
24656 "test(0);\n" | 24656 "test(0);\n" |
24657 "result;\n", | 24657 "result;\n", |
24658 0); | 24658 0); |
24659 } | 24659 } |
24660 | 24660 |
| 24661 THREADED_TEST(ReceiverConversionForAccessors) { |
| 24662 LocalContext env; |
| 24663 v8::Isolate* isolate = CcTest::isolate(); |
| 24664 v8::HandleScope scope(isolate); |
| 24665 Local<v8::FunctionTemplate> acc = |
| 24666 v8::FunctionTemplate::New(isolate, Returns42); |
| 24667 CHECK(env->Global() |
| 24668 ->Set(env.local(), v8_str("acc"), |
| 24669 acc->GetFunction(env.local()).ToLocalChecked()) |
| 24670 .FromJust()); |
| 24671 |
| 24672 Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
| 24673 templ->SetAccessorProperty(v8_str("acc"), acc, acc); |
| 24674 Local<v8::Object> instance = templ->NewInstance(env.local()).ToLocalChecked(); |
| 24675 |
| 24676 CHECK(env->Global()->Set(env.local(), v8_str("p"), instance).FromJust()); |
| 24677 CHECK(CompileRun("(p.acc == 42)")->BooleanValue(env.local()).FromJust()); |
| 24678 CHECK(CompileRun("(p.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); |
| 24679 |
| 24680 CHECK(!CompileRun("Number.prototype.__proto__ = p;" |
| 24681 "var a = 1;") |
| 24682 .IsEmpty()); |
| 24683 CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust()); |
| 24684 CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); |
| 24685 |
| 24686 CHECK(!CompileRun("Boolean.prototype.__proto__ = p;" |
| 24687 "var a = true;") |
| 24688 .IsEmpty()); |
| 24689 CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust()); |
| 24690 CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); |
| 24691 |
| 24692 CHECK(!CompileRun("String.prototype.__proto__ = p;" |
| 24693 "var a = 'foo';") |
| 24694 .IsEmpty()); |
| 24695 CHECK(CompileRun("(a.acc == 42)")->BooleanValue(env.local()).FromJust()); |
| 24696 CHECK(CompileRun("(a.acc = 7) == 7")->BooleanValue(env.local()).FromJust()); |
| 24697 |
| 24698 CHECK(CompileRun("acc.call(1) == 42")->BooleanValue(env.local()).FromJust()); |
| 24699 CHECK(CompileRun("acc.call(true)==42")->BooleanValue(env.local()).FromJust()); |
| 24700 CHECK(CompileRun("acc.call('aa')==42")->BooleanValue(env.local()).FromJust()); |
| 24701 CHECK( |
| 24702 CompileRun("acc.call(null) == 42")->BooleanValue(env.local()).FromJust()); |
| 24703 CHECK(CompileRun("acc.call(undefined) == 42") |
| 24704 ->BooleanValue(env.local()) |
| 24705 .FromJust()); |
| 24706 } |
| 24707 |
24661 class FutexInterruptionThread : public v8::base::Thread { | 24708 class FutexInterruptionThread : public v8::base::Thread { |
24662 public: | 24709 public: |
24663 explicit FutexInterruptionThread(v8::Isolate* isolate) | 24710 explicit FutexInterruptionThread(v8::Isolate* isolate) |
24664 : Thread(Options("FutexInterruptionThread")), isolate_(isolate) {} | 24711 : Thread(Options("FutexInterruptionThread")), isolate_(isolate) {} |
24665 | 24712 |
24666 virtual void Run() { | 24713 virtual void Run() { |
24667 // Wait a bit before terminating. | 24714 // Wait a bit before terminating. |
24668 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100)); | 24715 v8::base::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(100)); |
24669 isolate_->TerminateExecution(); | 24716 isolate_->TerminateExecution(); |
24670 } | 24717 } |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24931 } | 24978 } |
24932 delete garbage; | 24979 delete garbage; |
24933 // Check that moderate memory pressure notification sets GC into memory | 24980 // Check that moderate memory pressure notification sets GC into memory |
24934 // optimizing mode. | 24981 // optimizing mode. |
24935 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate); | 24982 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate); |
24936 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); | 24983 CHECK(CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); |
24937 // Check that disabling memory pressure returns GC into normal mode. | 24984 // Check that disabling memory pressure returns GC into normal mode. |
24938 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone); | 24985 isolate->MemoryPressureNotification(v8::MemoryPressureLevel::kNone); |
24939 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); | 24986 CHECK(!CcTest::i_isolate()->heap()->ShouldOptimizeForMemoryUsage()); |
24940 } | 24987 } |
OLD | NEW |