OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 7609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7620 // Helper to maximize the odds of object moving. | 7620 // Helper to maximize the odds of object moving. |
7621 static void GenerateSomeGarbage() { | 7621 static void GenerateSomeGarbage() { |
7622 CompileRun( | 7622 CompileRun( |
7623 "var garbage;" | 7623 "var garbage;" |
7624 "for (var i = 0; i < 1000; i++) {" | 7624 "for (var i = 0; i < 1000; i++) {" |
7625 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" | 7625 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" |
7626 "}" | 7626 "}" |
7627 "garbage = undefined;"); | 7627 "garbage = undefined;"); |
7628 } | 7628 } |
7629 | 7629 |
| 7630 |
7630 v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) { | 7631 v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) { |
7631 static int count = 0; | 7632 static int count = 0; |
7632 if (count++ % 3 == 0) { | 7633 if (count++ % 3 == 0) { |
7633 v8::V8::LowMemoryNotification(); // This should move the stub | 7634 i::Heap::CollectAllGarbage(true); // This should move the stub |
7634 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed | 7635 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed |
7635 } | 7636 } |
7636 return v8::Handle<v8::Value>(); | 7637 return v8::Handle<v8::Value>(); |
7637 } | 7638 } |
7638 | 7639 |
7639 | 7640 |
7640 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { | 7641 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { |
7641 v8::HandleScope scope; | 7642 v8::HandleScope scope; |
7642 LocalContext context; | 7643 LocalContext context; |
7643 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 7644 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7675 "function f() {" | 7676 "function f() {" |
7676 " for (var i = 1; i <= 5; i++) {" | 7677 " for (var i = 1; i <= 5; i++) {" |
7677 " try { nativeobject.callback(); } catch (e) { result += e; }" | 7678 " try { nativeobject.callback(); } catch (e) { result += e; }" |
7678 " }" | 7679 " }" |
7679 "}" | 7680 "}" |
7680 "f(); result;"); | 7681 "f(); result;"); |
7681 CHECK_EQ(v8_str("ggggg"), result); | 7682 CHECK_EQ(v8_str("ggggg"), result); |
7682 } | 7683 } |
7683 | 7684 |
7684 | 7685 |
| 7686 v8::Handle<v8::Value> DirectGetterCallback(Local<String> name, |
| 7687 const v8::AccessorInfo& info) { |
| 7688 if (++p_getter_count % 3 == 0) { |
| 7689 i::Heap::CollectAllGarbage(true); |
| 7690 GenerateSomeGarbage(); |
| 7691 } |
| 7692 return v8::Handle<v8::Value>(); |
| 7693 } |
| 7694 |
| 7695 |
| 7696 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) { |
| 7697 v8::HandleScope scope; |
| 7698 LocalContext context; |
| 7699 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); |
| 7700 obj->SetAccessor(v8_str("p1"), DirectGetterCallback); |
| 7701 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
| 7702 p_getter_count = 0; |
| 7703 CompileRun( |
| 7704 "function f() {" |
| 7705 " for (var i = 0; i < 30; i++) o1.p1;" |
| 7706 "}" |
| 7707 "f();"); |
| 7708 CHECK_EQ(30, p_getter_count); |
| 7709 } |
| 7710 |
| 7711 |
| 7712 v8::Handle<v8::Value> ThrowingDirectGetterCallback( |
| 7713 Local<String> name, const v8::AccessorInfo& info) { |
| 7714 return v8::ThrowException(v8_str("g")); |
| 7715 } |
| 7716 |
| 7717 |
| 7718 THREADED_TEST(LoadICFastApi_DirectCall_Throw) { |
| 7719 v8::HandleScope scope; |
| 7720 LocalContext context; |
| 7721 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New(); |
| 7722 obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback); |
| 7723 context->Global()->Set(v8_str("o1"), obj->NewInstance()); |
| 7724 v8::Handle<Value> result = CompileRun( |
| 7725 "var result = '';" |
| 7726 "for (var i = 0; i < 5; i++) {" |
| 7727 " try { o1.p1; } catch (e) { result += e; }" |
| 7728 "}" |
| 7729 "result;"); |
| 7730 CHECK_EQ(v8_str("ggggg"), result); |
| 7731 } |
| 7732 |
| 7733 |
7685 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { | 7734 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) { |
7686 int interceptor_call_count = 0; | 7735 int interceptor_call_count = 0; |
7687 v8::HandleScope scope; | 7736 v8::HandleScope scope; |
7688 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 7737 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
7689 v8::Handle<v8::FunctionTemplate> method_templ = | 7738 v8::Handle<v8::FunctionTemplate> method_templ = |
7690 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, | 7739 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, |
7691 v8_str("method_data"), | 7740 v8_str("method_data"), |
7692 v8::Handle<v8::Signature>()); | 7741 v8::Handle<v8::Signature>()); |
7693 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 7742 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
7694 proto_templ->Set(v8_str("method"), method_templ); | 7743 proto_templ->Set(v8_str("method"), method_templ); |
(...skipping 5139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12834 v8::Handle<v8::Function> define_property = | 12883 v8::Handle<v8::Function> define_property = |
12835 CompileRun("(function() {" | 12884 CompileRun("(function() {" |
12836 " Object.defineProperty(" | 12885 " Object.defineProperty(" |
12837 " this," | 12886 " this," |
12838 " 1," | 12887 " 1," |
12839 " { configurable: true, enumerable: true, value: 3 });" | 12888 " { configurable: true, enumerable: true, value: 3 });" |
12840 "})").As<Function>(); | 12889 "})").As<Function>(); |
12841 context->DetachGlobal(); | 12890 context->DetachGlobal(); |
12842 define_property->Call(proxy, 0, NULL); | 12891 define_property->Call(proxy, 0, NULL); |
12843 } | 12892 } |
OLD | NEW |