| 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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 TestSimpleCallback(SimpleDirectCallback); | 1018 TestSimpleCallback(SimpleDirectCallback); |
| 1019 TestSimpleCallback(SimpleIndirectCallback); | 1019 TestSimpleCallback(SimpleIndirectCallback); |
| 1020 TestSimpleCallback(SimpleCallback); | 1020 TestSimpleCallback(SimpleCallback); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 | 1023 |
| 1024 template<typename T> | 1024 template<typename T> |
| 1025 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); | 1025 void FastReturnValueCallback(const v8::FunctionCallbackInfo<v8::Value>& info); |
| 1026 | 1026 |
| 1027 // constant return values | 1027 // constant return values |
| 1028 static const int32_t kFastReturnValueInt32 = 471; | 1028 static int32_t fast_return_value_int32 = 471; |
| 1029 static const uint32_t kFastReturnValueUint32 = 571; | 1029 static uint32_t fast_return_value_uint32 = 571; |
| 1030 static const double kFastReturnValueDouble = 2.7; | 1030 static const double kFastReturnValueDouble = 2.7; |
| 1031 // variable return values | 1031 // variable return values |
| 1032 static bool fast_return_value_bool = false; | 1032 static bool fast_return_value_bool = false; |
| 1033 static bool fast_return_value_void_is_null = false; | 1033 static bool fast_return_value_void_is_null = false; |
| 1034 static bool fast_return_value_object_is_empty = false; | 1034 static bool fast_return_value_object_is_empty = false; |
| 1035 | 1035 |
| 1036 template<> | 1036 template<> |
| 1037 void FastReturnValueCallback<int32_t>( | 1037 void FastReturnValueCallback<int32_t>( |
| 1038 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1038 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 1039 CheckReturnValue(info); | 1039 CheckReturnValue(info); |
| 1040 info.GetReturnValue().Set(kFastReturnValueInt32); | 1040 info.GetReturnValue().Set(fast_return_value_int32); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 template<> | 1043 template<> |
| 1044 void FastReturnValueCallback<uint32_t>( | 1044 void FastReturnValueCallback<uint32_t>( |
| 1045 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1045 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 1046 CheckReturnValue(info); | 1046 CheckReturnValue(info); |
| 1047 info.GetReturnValue().Set(kFastReturnValueUint32); | 1047 info.GetReturnValue().Set(fast_return_value_uint32); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 template<> | 1050 template<> |
| 1051 void FastReturnValueCallback<double>( | 1051 void FastReturnValueCallback<double>( |
| 1052 const v8::FunctionCallbackInfo<v8::Value>& info) { | 1052 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 1053 CheckReturnValue(info); | 1053 CheckReturnValue(info); |
| 1054 info.GetReturnValue().Set(kFastReturnValueDouble); | 1054 info.GetReturnValue().Set(kFastReturnValueDouble); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 template<> | 1057 template<> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1086 v8::HandleScope scope(env->GetIsolate()); | 1086 v8::HandleScope scope(env->GetIsolate()); |
| 1087 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 1087 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 1088 v8::FunctionCallback callback = &FastReturnValueCallback<T>; | 1088 v8::FunctionCallback callback = &FastReturnValueCallback<T>; |
| 1089 object_template->Set("callback", v8::FunctionTemplate::New(callback)); | 1089 object_template->Set("callback", v8::FunctionTemplate::New(callback)); |
| 1090 v8::Local<v8::Object> object = object_template->NewInstance(); | 1090 v8::Local<v8::Object> object = object_template->NewInstance(); |
| 1091 (*env)->Global()->Set(v8_str("callback_object"), object); | 1091 (*env)->Global()->Set(v8_str("callback_object"), object); |
| 1092 return scope.Close(CompileRun("callback_object.callback()")); | 1092 return scope.Close(CompileRun("callback_object.callback()")); |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 THREADED_TEST(FastReturnValues) { | 1095 THREADED_TEST(FastReturnValues) { |
| 1096 LocalContext env; |
| 1096 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1097 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 1097 v8::Handle<v8::Value> value; | 1098 v8::Handle<v8::Value> value; |
| 1098 // check int_32 | 1099 // check int32_t and uint32_t |
| 1099 value = TestFastReturnValues<int32_t>(); | 1100 int32_t int_values[] = { |
| 1100 CHECK(value->IsInt32()); | 1101 0, 1, -1, 234, -723, |
| 1101 CHECK_EQ(kFastReturnValueInt32, value->Int32Value()); | 1102 i::Smi::kMinValue, i::Smi::kMinValue-1, |
| 1102 // check uint32_t | 1103 i::Smi::kMaxValue, i::Smi::kMaxValue+1}; |
| 1103 value = TestFastReturnValues<uint32_t>(); | 1104 for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) { |
| 1104 CHECK(value->IsInt32()); | 1105 // check int32_t |
| 1105 CHECK_EQ(kFastReturnValueUint32, value->Int32Value()); | 1106 fast_return_value_int32 = int_values[i]; |
| 1107 value = TestFastReturnValues<int32_t>(); |
| 1108 CHECK(value->IsInt32()); |
| 1109 CHECK(fast_return_value_int32 == value->Int32Value()); |
| 1110 // check uint32_t |
| 1111 fast_return_value_uint32 = static_cast<uint32_t>(int_values[i]); |
| 1112 value = TestFastReturnValues<uint32_t>(); |
| 1113 CHECK(value->IsUint32()); |
| 1114 CHECK(fast_return_value_uint32 == value->Uint32Value()); |
| 1115 } |
| 1106 // check double | 1116 // check double |
| 1107 value = TestFastReturnValues<double>(); | 1117 value = TestFastReturnValues<double>(); |
| 1108 CHECK(value->IsNumber()); | 1118 CHECK(value->IsNumber()); |
| 1109 CHECK_EQ(kFastReturnValueDouble, value->ToNumber()->Value()); | 1119 CHECK_EQ(kFastReturnValueDouble, value->ToNumber()->Value()); |
| 1110 // check bool values | 1120 // check bool values |
| 1111 for (int i = 0; i < 2; i++) { | 1121 for (int i = 0; i < 2; i++) { |
| 1112 fast_return_value_bool = i == 0; | 1122 fast_return_value_bool = i == 0; |
| 1113 value = TestFastReturnValues<bool>(); | 1123 value = TestFastReturnValues<bool>(); |
| 1114 CHECK(value->IsBoolean()); | 1124 CHECK(value->IsBoolean()); |
| 1115 CHECK_EQ(fast_return_value_bool, value->ToBoolean()->Value()); | 1125 CHECK_EQ(fast_return_value_bool, value->ToBoolean()->Value()); |
| (...skipping 17992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19108 i::Semaphore* sem_; | 19118 i::Semaphore* sem_; |
| 19109 volatile int sem_value_; | 19119 volatile int sem_value_; |
| 19110 }; | 19120 }; |
| 19111 | 19121 |
| 19112 | 19122 |
| 19113 THREADED_TEST(SemaphoreInterruption) { | 19123 THREADED_TEST(SemaphoreInterruption) { |
| 19114 ThreadInterruptTest().RunTest(); | 19124 ThreadInterruptTest().RunTest(); |
| 19115 } | 19125 } |
| 19116 | 19126 |
| 19117 #endif // WIN32 | 19127 #endif // WIN32 |
| OLD | NEW |