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 20019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20030 | 20030 |
20031 | 20031 |
20032 class RequestInterruptTestWithFunctionCall | 20032 class RequestInterruptTestWithFunctionCall |
20033 : public RequestInterruptTestBaseWithSimpleInterrupt { | 20033 : public RequestInterruptTestBaseWithSimpleInterrupt { |
20034 public: | 20034 public: |
20035 virtual void TestBody() { | 20035 virtual void TestBody() { |
20036 Local<Function> func = Function::New( | 20036 Local<Function> func = Function::New( |
20037 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this)); | 20037 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this)); |
20038 env_->Global()->Set(v8_str("ShouldContinue"), func); | 20038 env_->Global()->Set(v8_str("ShouldContinue"), func); |
20039 | 20039 |
20040 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. | |
20041 CompileRun("while (ShouldContinue()) { }"); | 20040 CompileRun("while (ShouldContinue()) { }"); |
20042 } | 20041 } |
20043 }; | 20042 }; |
20044 | 20043 |
20045 | 20044 |
20046 class RequestInterruptTestWithMethodCall | 20045 class RequestInterruptTestWithMethodCall |
20047 : public RequestInterruptTestBaseWithSimpleInterrupt { | 20046 : public RequestInterruptTestBaseWithSimpleInterrupt { |
20048 public: | 20047 public: |
20049 virtual void TestBody() { | 20048 virtual void TestBody() { |
20050 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); | 20049 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); |
20051 v8::Local<v8::Template> proto = t->PrototypeTemplate(); | 20050 v8::Local<v8::Template> proto = t->PrototypeTemplate(); |
20052 proto->Set(v8_str("shouldContinue"), Function::New( | 20051 proto->Set(v8_str("shouldContinue"), Function::New( |
20053 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this))); | 20052 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this))); |
20054 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); | 20053 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); |
20055 | 20054 |
20056 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. | |
20057 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }"); | 20055 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }"); |
20058 } | 20056 } |
20059 }; | 20057 }; |
20060 | 20058 |
20061 | 20059 |
20062 class RequestInterruptTestWithAccessor | 20060 class RequestInterruptTestWithAccessor |
20063 : public RequestInterruptTestBaseWithSimpleInterrupt { | 20061 : public RequestInterruptTestBaseWithSimpleInterrupt { |
20064 public: | 20062 public: |
20065 virtual void TestBody() { | 20063 virtual void TestBody() { |
20066 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); | 20064 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); |
20067 v8::Local<v8::Template> proto = t->PrototypeTemplate(); | 20065 v8::Local<v8::Template> proto = t->PrototypeTemplate(); |
20068 proto->SetAccessorProperty(v8_str("shouldContinue"), FunctionTemplate::New( | 20066 proto->SetAccessorProperty(v8_str("shouldContinue"), FunctionTemplate::New( |
20069 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this))); | 20067 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this))); |
20070 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); | 20068 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); |
20071 | 20069 |
20072 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. | |
20073 CompileRun("var obj = new Klass; while (obj.shouldContinue) { }"); | 20070 CompileRun("var obj = new Klass; while (obj.shouldContinue) { }"); |
20074 } | 20071 } |
20075 }; | 20072 }; |
20076 | 20073 |
20077 | 20074 |
20078 class RequestInterruptTestWithNativeAccessor | 20075 class RequestInterruptTestWithNativeAccessor |
20079 : public RequestInterruptTestBaseWithSimpleInterrupt { | 20076 : public RequestInterruptTestBaseWithSimpleInterrupt { |
20080 public: | 20077 public: |
20081 virtual void TestBody() { | 20078 virtual void TestBody() { |
20082 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); | 20079 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); |
20083 t->InstanceTemplate()->SetNativeDataProperty( | 20080 t->InstanceTemplate()->SetNativeDataProperty( |
20084 v8_str("shouldContinue"), | 20081 v8_str("shouldContinue"), |
20085 &ShouldContinueNativeGetter, | 20082 &ShouldContinueNativeGetter, |
20086 NULL, | 20083 NULL, |
20087 v8::External::New(isolate_, this)); | 20084 v8::External::New(isolate_, this)); |
20088 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); | 20085 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); |
20089 | 20086 |
20090 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. | |
20091 CompileRun("var obj = new Klass; while (obj.shouldContinue) { }"); | 20087 CompileRun("var obj = new Klass; while (obj.shouldContinue) { }"); |
20092 } | 20088 } |
20093 | 20089 |
20094 private: | 20090 private: |
20095 static void ShouldContinueNativeGetter( | 20091 static void ShouldContinueNativeGetter( |
20096 Local<String> property, | 20092 Local<String> property, |
20097 const v8::PropertyCallbackInfo<v8::Value>& info) { | 20093 const v8::PropertyCallbackInfo<v8::Value>& info) { |
20098 RequestInterruptTestBase* test = | 20094 RequestInterruptTestBase* test = |
20099 reinterpret_cast<RequestInterruptTestBase*>( | 20095 reinterpret_cast<RequestInterruptTestBase*>( |
20100 info.Data().As<v8::External>()->Value()); | 20096 info.Data().As<v8::External>()->Value()); |
20101 info.GetReturnValue().Set(test->ShouldContinue()); | 20097 info.GetReturnValue().Set(test->ShouldContinue()); |
20102 } | 20098 } |
20103 }; | 20099 }; |
20104 | 20100 |
20105 | 20101 |
20106 class RequestInterruptTestWithMethodCallAndInterceptor | 20102 class RequestInterruptTestWithMethodCallAndInterceptor |
20107 : public RequestInterruptTestBaseWithSimpleInterrupt { | 20103 : public RequestInterruptTestBaseWithSimpleInterrupt { |
20108 public: | 20104 public: |
20109 virtual void TestBody() { | 20105 virtual void TestBody() { |
20110 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); | 20106 v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate_); |
20111 v8::Local<v8::Template> proto = t->PrototypeTemplate(); | 20107 v8::Local<v8::Template> proto = t->PrototypeTemplate(); |
20112 proto->Set(v8_str("shouldContinue"), Function::New( | 20108 proto->Set(v8_str("shouldContinue"), Function::New( |
20113 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this))); | 20109 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this))); |
20114 v8::Local<v8::ObjectTemplate> instance_template = t->InstanceTemplate(); | 20110 v8::Local<v8::ObjectTemplate> instance_template = t->InstanceTemplate(); |
20115 instance_template->SetHandler( | 20111 instance_template->SetHandler( |
20116 v8::NamedPropertyHandlerConfiguration(EmptyInterceptor)); | 20112 v8::NamedPropertyHandlerConfiguration(EmptyInterceptor)); |
20117 | 20113 |
20118 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); | 20114 env_->Global()->Set(v8_str("Klass"), t->GetFunction()); |
20119 | 20115 |
20120 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. | |
20121 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }"); | 20116 CompileRun("var obj = new Klass; while (obj.shouldContinue()) { }"); |
20122 } | 20117 } |
20123 | 20118 |
20124 private: | 20119 private: |
20125 static void EmptyInterceptor( | 20120 static void EmptyInterceptor( |
20126 Local<Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) {} | 20121 Local<Name> property, const v8::PropertyCallbackInfo<v8::Value>& info) {} |
20127 }; | 20122 }; |
20128 | 20123 |
20129 | 20124 |
20130 class RequestInterruptTestWithMathAbs | 20125 class RequestInterruptTestWithMathAbs |
20131 : public RequestInterruptTestBaseWithSimpleInterrupt { | 20126 : public RequestInterruptTestBaseWithSimpleInterrupt { |
20132 public: | 20127 public: |
20133 virtual void TestBody() { | 20128 virtual void TestBody() { |
20134 env_->Global()->Set(v8_str("WakeUpInterruptor"), Function::New( | 20129 env_->Global()->Set(v8_str("WakeUpInterruptor"), Function::New( |
20135 isolate_, | 20130 isolate_, |
20136 WakeUpInterruptorCallback, | 20131 WakeUpInterruptorCallback, |
20137 v8::External::New(isolate_, this))); | 20132 v8::External::New(isolate_, this))); |
20138 | 20133 |
20139 env_->Global()->Set(v8_str("ShouldContinue"), Function::New( | 20134 env_->Global()->Set(v8_str("ShouldContinue"), Function::New( |
20140 isolate_, | 20135 isolate_, |
20141 ShouldContinueCallback, | 20136 ShouldContinueCallback, |
20142 v8::External::New(isolate_, this))); | 20137 v8::External::New(isolate_, this))); |
20143 | 20138 |
20144 i::FLAG_allow_natives_syntax = true; | 20139 i::FLAG_allow_natives_syntax = true; |
20145 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. | |
20146 CompileRun("function loopish(o) {" | 20140 CompileRun("function loopish(o) {" |
20147 " var pre = 10;" | 20141 " var pre = 10;" |
20148 " while (o.abs(1) > 0) {" | 20142 " while (o.abs(1) > 0) {" |
20149 " if (o.abs(1) >= 0 && !ShouldContinue()) break;" | 20143 " if (o.abs(1) >= 0 && !ShouldContinue()) break;" |
20150 " if (pre > 0) {" | 20144 " if (pre > 0) {" |
20151 " if (--pre === 0) WakeUpInterruptor(o === Math);" | 20145 " if (--pre === 0) WakeUpInterruptor(o === Math);" |
20152 " }" | 20146 " }" |
20153 " }" | 20147 " }" |
20154 "}" | 20148 "}" |
20155 "var i = 50;" | 20149 "var i = 50;" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20219 | 20213 |
20220 virtual void StartInterruptThread() { | 20214 virtual void StartInterruptThread() { |
20221 i_thread.Start(); | 20215 i_thread.Start(); |
20222 } | 20216 } |
20223 | 20217 |
20224 virtual void TestBody() { | 20218 virtual void TestBody() { |
20225 Local<Function> func = Function::New( | 20219 Local<Function> func = Function::New( |
20226 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this)); | 20220 isolate_, ShouldContinueCallback, v8::External::New(isolate_, this)); |
20227 env_->Global()->Set(v8_str("ShouldContinue"), func); | 20221 env_->Global()->Set(v8_str("ShouldContinue"), func); |
20228 | 20222 |
20229 i::FLAG_turbo_osr = false; // TODO(titzer): interrupts in TF loops. | |
20230 CompileRun("while (ShouldContinue()) { }"); | 20223 CompileRun("while (ShouldContinue()) { }"); |
20231 } | 20224 } |
20232 | 20225 |
20233 private: | 20226 private: |
20234 class InterruptThread : public v8::base::Thread { | 20227 class InterruptThread : public v8::base::Thread { |
20235 public: | 20228 public: |
20236 enum { NUM_INTERRUPTS = 10 }; | 20229 enum { NUM_INTERRUPTS = 10 }; |
20237 explicit InterruptThread(RequestMultipleInterrupts* test) | 20230 explicit InterruptThread(RequestMultipleInterrupts* test) |
20238 : Thread(Options("RequestInterruptTest")), test_(test) {} | 20231 : Thread(Options("RequestInterruptTest")), test_(test) {} |
20239 | 20232 |
(...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21900 } | 21893 } |
21901 { | 21894 { |
21902 v8::TryCatch try_catch; | 21895 v8::TryCatch try_catch; |
21903 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 21896 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
21904 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 21897 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
21905 length).IsEmpty()); | 21898 length).IsEmpty()); |
21906 CHECK(!try_catch.HasCaught()); | 21899 CHECK(!try_catch.HasCaught()); |
21907 } | 21900 } |
21908 free(buffer); | 21901 free(buffer); |
21909 } | 21902 } |
OLD | NEW |