| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); | 186 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); |
| 187 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize()); | 187 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize()); |
| 188 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); | 188 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); |
| 189 // TODO(mstarzinger): This should fail gracefully instead of asserting. | 189 // TODO(mstarzinger): This should fail gracefully instead of asserting. |
| 190 // for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize()); | 190 // for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize()); |
| 191 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); | 191 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 | 194 |
| 195 THREADED_TEST(Handles) { | 195 THREADED_TEST(Handles) { |
| 196 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 196 v8::HandleScope scope(CcTest::isolate()); |
| 197 Local<Context> local_env; | 197 Local<Context> local_env; |
| 198 { | 198 { |
| 199 LocalContext env; | 199 LocalContext env; |
| 200 local_env = env.local(); | 200 local_env = env.local(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Local context should still be live. | 203 // Local context should still be live. |
| 204 CHECK(!local_env.IsEmpty()); | 204 CHECK(!local_env.IsEmpty()); |
| 205 local_env->Enter(); | 205 local_env->Enter(); |
| 206 | 206 |
| 207 v8::Handle<v8::Primitive> undef = v8::Undefined(); | 207 v8::Handle<v8::Primitive> undef = v8::Undefined(); |
| 208 CHECK(!undef.IsEmpty()); | 208 CHECK(!undef.IsEmpty()); |
| 209 CHECK(undef->IsUndefined()); | 209 CHECK(undef->IsUndefined()); |
| 210 | 210 |
| 211 const char* c_source = "1 + 2 + 3"; | 211 const char* c_source = "1 + 2 + 3"; |
| 212 Local<String> source = String::New(c_source); | 212 Local<String> source = String::New(c_source); |
| 213 Local<Script> script = Script::Compile(source); | 213 Local<Script> script = Script::Compile(source); |
| 214 CHECK_EQ(6, script->Run()->Int32Value()); | 214 CHECK_EQ(6, script->Run()->Int32Value()); |
| 215 | 215 |
| 216 local_env->Exit(); | 216 local_env->Exit(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 | 219 |
| 220 THREADED_TEST(IsolateOfContext) { | 220 THREADED_TEST(IsolateOfContext) { |
| 221 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 221 v8::HandleScope scope(CcTest::isolate()); |
| 222 v8::Handle<Context> env = Context::New(v8::Isolate::GetCurrent()); | 222 v8::Handle<Context> env = Context::New(CcTest::isolate()); |
| 223 | 223 |
| 224 CHECK(!env->InContext()); | 224 CHECK(!env->InContext()); |
| 225 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); | 225 CHECK(env->GetIsolate() == CcTest::isolate()); |
| 226 env->Enter(); | 226 env->Enter(); |
| 227 CHECK(env->InContext()); | 227 CHECK(env->InContext()); |
| 228 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); | 228 CHECK(env->GetIsolate() == CcTest::isolate()); |
| 229 env->Exit(); | 229 env->Exit(); |
| 230 CHECK(!env->InContext()); | 230 CHECK(!env->InContext()); |
| 231 CHECK(env->GetIsolate() == v8::Isolate::GetCurrent()); | 231 CHECK(env->GetIsolate() == CcTest::isolate()); |
| 232 } | 232 } |
| 233 | 233 |
| 234 | 234 |
| 235 static void TestSignature(const char* loop_js, Local<Value> receiver) { | 235 static void TestSignature(const char* loop_js, Local<Value> receiver) { |
| 236 i::ScopedVector<char> source(200); | 236 i::ScopedVector<char> source(200); |
| 237 i::OS::SNPrintF(source, | 237 i::OS::SNPrintF(source, |
| 238 "for (var i = 0; i < 10; i++) {" | 238 "for (var i = 0; i < 10; i++) {" |
| 239 " %s" | 239 " %s" |
| 240 "}", | 240 "}", |
| 241 loop_js); | 241 loop_js); |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 | 732 |
| 733 // Trigger GCs and force evacuation. | 733 // Trigger GCs and force evacuation. |
| 734 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 734 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 735 HEAP->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); | 735 HEAP->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); |
| 736 } | 736 } |
| 737 | 737 |
| 738 | 738 |
| 739 THREADED_TEST(UsingExternalString) { | 739 THREADED_TEST(UsingExternalString) { |
| 740 i::Factory* factory = i::Isolate::Current()->factory(); | 740 i::Factory* factory = i::Isolate::Current()->factory(); |
| 741 { | 741 { |
| 742 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 742 v8::HandleScope scope(CcTest::isolate()); |
| 743 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 743 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 744 Local<String> string = | 744 Local<String> string = |
| 745 String::NewExternal(new TestResource(two_byte_string)); | 745 String::NewExternal(new TestResource(two_byte_string)); |
| 746 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 746 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 747 // Trigger GCs so that the newly allocated string moves to old gen. | 747 // Trigger GCs so that the newly allocated string moves to old gen. |
| 748 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 748 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 749 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 749 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 750 i::Handle<i::String> isymbol = | 750 i::Handle<i::String> isymbol = |
| 751 factory->InternalizedStringFromString(istring); | 751 factory->InternalizedStringFromString(istring); |
| 752 CHECK(isymbol->IsInternalizedString()); | 752 CHECK(isymbol->IsInternalizedString()); |
| 753 } | 753 } |
| 754 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 754 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 755 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 755 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 756 } | 756 } |
| 757 | 757 |
| 758 | 758 |
| 759 THREADED_TEST(UsingExternalAsciiString) { | 759 THREADED_TEST(UsingExternalAsciiString) { |
| 760 i::Factory* factory = i::Isolate::Current()->factory(); | 760 i::Factory* factory = i::Isolate::Current()->factory(); |
| 761 { | 761 { |
| 762 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 762 v8::HandleScope scope(CcTest::isolate()); |
| 763 const char* one_byte_string = "test string"; | 763 const char* one_byte_string = "test string"; |
| 764 Local<String> string = String::NewExternal( | 764 Local<String> string = String::NewExternal( |
| 765 new TestAsciiResource(i::StrDup(one_byte_string))); | 765 new TestAsciiResource(i::StrDup(one_byte_string))); |
| 766 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 766 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 767 // Trigger GCs so that the newly allocated string moves to old gen. | 767 // Trigger GCs so that the newly allocated string moves to old gen. |
| 768 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 768 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 769 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 769 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 770 i::Handle<i::String> isymbol = | 770 i::Handle<i::String> isymbol = |
| 771 factory->InternalizedStringFromString(istring); | 771 factory->InternalizedStringFromString(istring); |
| 772 CHECK(isymbol->IsInternalizedString()); | 772 CHECK(isymbol->IsInternalizedString()); |
| 773 } | 773 } |
| 774 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 774 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 775 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 775 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 776 } | 776 } |
| 777 | 777 |
| 778 | 778 |
| 779 THREADED_TEST(ScavengeExternalString) { | 779 THREADED_TEST(ScavengeExternalString) { |
| 780 i::FLAG_stress_compaction = false; | 780 i::FLAG_stress_compaction = false; |
| 781 i::FLAG_gc_global = false; | 781 i::FLAG_gc_global = false; |
| 782 int dispose_count = 0; | 782 int dispose_count = 0; |
| 783 bool in_new_space = false; | 783 bool in_new_space = false; |
| 784 { | 784 { |
| 785 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 785 v8::HandleScope scope(CcTest::isolate()); |
| 786 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 786 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 787 Local<String> string = | 787 Local<String> string = |
| 788 String::NewExternal(new TestResource(two_byte_string, | 788 String::NewExternal(new TestResource(two_byte_string, |
| 789 &dispose_count)); | 789 &dispose_count)); |
| 790 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 790 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 791 HEAP->CollectGarbage(i::NEW_SPACE); | 791 HEAP->CollectGarbage(i::NEW_SPACE); |
| 792 in_new_space = HEAP->InNewSpace(*istring); | 792 in_new_space = HEAP->InNewSpace(*istring); |
| 793 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); | 793 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); |
| 794 CHECK_EQ(0, dispose_count); | 794 CHECK_EQ(0, dispose_count); |
| 795 } | 795 } |
| 796 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 796 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
| 797 CHECK_EQ(1, dispose_count); | 797 CHECK_EQ(1, dispose_count); |
| 798 } | 798 } |
| 799 | 799 |
| 800 | 800 |
| 801 THREADED_TEST(ScavengeExternalAsciiString) { | 801 THREADED_TEST(ScavengeExternalAsciiString) { |
| 802 i::FLAG_stress_compaction = false; | 802 i::FLAG_stress_compaction = false; |
| 803 i::FLAG_gc_global = false; | 803 i::FLAG_gc_global = false; |
| 804 int dispose_count = 0; | 804 int dispose_count = 0; |
| 805 bool in_new_space = false; | 805 bool in_new_space = false; |
| 806 { | 806 { |
| 807 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 807 v8::HandleScope scope(CcTest::isolate()); |
| 808 const char* one_byte_string = "test string"; | 808 const char* one_byte_string = "test string"; |
| 809 Local<String> string = String::NewExternal( | 809 Local<String> string = String::NewExternal( |
| 810 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); | 810 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); |
| 811 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 811 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 812 HEAP->CollectGarbage(i::NEW_SPACE); | 812 HEAP->CollectGarbage(i::NEW_SPACE); |
| 813 in_new_space = HEAP->InNewSpace(*istring); | 813 in_new_space = HEAP->InNewSpace(*istring); |
| 814 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); | 814 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); |
| 815 CHECK_EQ(0, dispose_count); | 815 CHECK_EQ(0, dispose_count); |
| 816 } | 816 } |
| 817 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 817 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 global->Set(v8_str("pi"), v8_num(3.1415926)); | 941 global->Set(v8_str("pi"), v8_num(3.1415926)); |
| 942 Local<Value> pi = global->Get(v8_str("pi")); | 942 Local<Value> pi = global->Get(v8_str("pi")); |
| 943 CHECK_EQ(3.1415926, pi->NumberValue()); | 943 CHECK_EQ(3.1415926, pi->NumberValue()); |
| 944 } | 944 } |
| 945 | 945 |
| 946 | 946 |
| 947 template<typename T> | 947 template<typename T> |
| 948 static void CheckReturnValue(const T& t, i::Address callback) { | 948 static void CheckReturnValue(const T& t, i::Address callback) { |
| 949 v8::ReturnValue<v8::Value> rv = t.GetReturnValue(); | 949 v8::ReturnValue<v8::Value> rv = t.GetReturnValue(); |
| 950 i::Object** o = *reinterpret_cast<i::Object***>(&rv); | 950 i::Object** o = *reinterpret_cast<i::Object***>(&rv); |
| 951 CHECK_EQ(v8::Isolate::GetCurrent(), t.GetIsolate()); | 951 CHECK_EQ(CcTest::isolate(), t.GetIsolate()); |
| 952 CHECK_EQ(t.GetIsolate(), rv.GetIsolate()); | 952 CHECK_EQ(t.GetIsolate(), rv.GetIsolate()); |
| 953 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); | 953 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); |
| 954 // Verify reset | 954 // Verify reset |
| 955 bool is_runtime = (*o)->IsTheHole(); | 955 bool is_runtime = (*o)->IsTheHole(); |
| 956 rv.Set(true); | 956 rv.Set(true); |
| 957 CHECK(!(*o)->IsTheHole() && !(*o)->IsUndefined()); | 957 CHECK(!(*o)->IsTheHole() && !(*o)->IsUndefined()); |
| 958 rv.Set(v8::Handle<v8::Object>()); | 958 rv.Set(v8::Handle<v8::Object>()); |
| 959 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); | 959 CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); |
| 960 CHECK_EQ(is_runtime, (*o)->IsTheHole()); | 960 CHECK_EQ(is_runtime, (*o)->IsTheHole()); |
| 961 | 961 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 v8::FunctionCallback callback = &FastReturnValueCallback<T>; | 1193 v8::FunctionCallback callback = &FastReturnValueCallback<T>; |
| 1194 object_template->Set("callback", v8::FunctionTemplate::New(callback)); | 1194 object_template->Set("callback", v8::FunctionTemplate::New(callback)); |
| 1195 v8::Local<v8::Object> object = object_template->NewInstance(); | 1195 v8::Local<v8::Object> object = object_template->NewInstance(); |
| 1196 (*env)->Global()->Set(v8_str("callback_object"), object); | 1196 (*env)->Global()->Set(v8_str("callback_object"), object); |
| 1197 return scope.Close(CompileRun("callback_object.callback()")); | 1197 return scope.Close(CompileRun("callback_object.callback()")); |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 | 1200 |
| 1201 THREADED_PROFILED_TEST(FastReturnValues) { | 1201 THREADED_PROFILED_TEST(FastReturnValues) { |
| 1202 LocalContext env; | 1202 LocalContext env; |
| 1203 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1203 v8::HandleScope scope(CcTest::isolate()); |
| 1204 v8::Handle<v8::Value> value; | 1204 v8::Handle<v8::Value> value; |
| 1205 // check int32_t and uint32_t | 1205 // check int32_t and uint32_t |
| 1206 int32_t int_values[] = { | 1206 int32_t int_values[] = { |
| 1207 0, 234, -723, | 1207 0, 234, -723, |
| 1208 i::Smi::kMinValue, i::Smi::kMaxValue | 1208 i::Smi::kMinValue, i::Smi::kMaxValue |
| 1209 }; | 1209 }; |
| 1210 for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) { | 1210 for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) { |
| 1211 for (int modifier = -1; modifier <= 1; modifier++) { | 1211 for (int modifier = -1; modifier <= 1; modifier++) { |
| 1212 int int_value = int_values[i] + modifier; | 1212 int int_value = int_values[i] + modifier; |
| 1213 // check int32_t | 1213 // check int32_t |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 CHECK_EQ(derived_instance2, | 1413 CHECK_EQ(derived_instance2, |
| 1414 other_instance->FindInstanceInPrototypeChain(derived)); | 1414 other_instance->FindInstanceInPrototypeChain(derived)); |
| 1415 CHECK_EQ(other_instance, | 1415 CHECK_EQ(other_instance, |
| 1416 other_instance->FindInstanceInPrototypeChain(other)); | 1416 other_instance->FindInstanceInPrototypeChain(other)); |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 | 1419 |
| 1420 THREADED_TEST(TinyInteger) { | 1420 THREADED_TEST(TinyInteger) { |
| 1421 LocalContext env; | 1421 LocalContext env; |
| 1422 v8::HandleScope scope(env->GetIsolate()); | 1422 v8::HandleScope scope(env->GetIsolate()); |
| 1423 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1423 v8::Isolate* isolate = CcTest::isolate(); |
| 1424 | 1424 |
| 1425 int32_t value = 239; | 1425 int32_t value = 239; |
| 1426 Local<v8::Integer> value_obj = v8::Integer::New(value); | 1426 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 1427 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1427 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1428 | 1428 |
| 1429 value_obj = v8::Integer::New(value, isolate); | 1429 value_obj = v8::Integer::New(value, isolate); |
| 1430 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1430 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1431 } | 1431 } |
| 1432 | 1432 |
| 1433 | 1433 |
| 1434 THREADED_TEST(BigSmiInteger) { | 1434 THREADED_TEST(BigSmiInteger) { |
| 1435 LocalContext env; | 1435 LocalContext env; |
| 1436 v8::HandleScope scope(env->GetIsolate()); | 1436 v8::HandleScope scope(env->GetIsolate()); |
| 1437 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1437 v8::Isolate* isolate = CcTest::isolate(); |
| 1438 | 1438 |
| 1439 int32_t value = i::Smi::kMaxValue; | 1439 int32_t value = i::Smi::kMaxValue; |
| 1440 // We cannot add one to a Smi::kMaxValue without wrapping. | 1440 // We cannot add one to a Smi::kMaxValue without wrapping. |
| 1441 if (i::SmiValuesAre31Bits()) { | 1441 if (i::SmiValuesAre31Bits()) { |
| 1442 CHECK(i::Smi::IsValid(value)); | 1442 CHECK(i::Smi::IsValid(value)); |
| 1443 CHECK(!i::Smi::IsValid(value + 1)); | 1443 CHECK(!i::Smi::IsValid(value + 1)); |
| 1444 | 1444 |
| 1445 Local<v8::Integer> value_obj = v8::Integer::New(value); | 1445 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 1446 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1446 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1447 | 1447 |
| 1448 value_obj = v8::Integer::New(value, isolate); | 1448 value_obj = v8::Integer::New(value, isolate); |
| 1449 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1449 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1450 } | 1450 } |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 | 1453 |
| 1454 THREADED_TEST(BigInteger) { | 1454 THREADED_TEST(BigInteger) { |
| 1455 LocalContext env; | 1455 LocalContext env; |
| 1456 v8::HandleScope scope(env->GetIsolate()); | 1456 v8::HandleScope scope(env->GetIsolate()); |
| 1457 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1457 v8::Isolate* isolate = CcTest::isolate(); |
| 1458 | 1458 |
| 1459 // We cannot add one to a Smi::kMaxValue without wrapping. | 1459 // We cannot add one to a Smi::kMaxValue without wrapping. |
| 1460 if (i::SmiValuesAre31Bits()) { | 1460 if (i::SmiValuesAre31Bits()) { |
| 1461 // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1. | 1461 // The casts allow this to compile, even if Smi::kMaxValue is 2^31-1. |
| 1462 // The code will not be run in that case, due to the "if" guard. | 1462 // The code will not be run in that case, due to the "if" guard. |
| 1463 int32_t value = | 1463 int32_t value = |
| 1464 static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1); | 1464 static_cast<int32_t>(static_cast<uint32_t>(i::Smi::kMaxValue) + 1); |
| 1465 CHECK(value > i::Smi::kMaxValue); | 1465 CHECK(value > i::Smi::kMaxValue); |
| 1466 CHECK(!i::Smi::IsValid(value)); | 1466 CHECK(!i::Smi::IsValid(value)); |
| 1467 | 1467 |
| 1468 Local<v8::Integer> value_obj = v8::Integer::New(value); | 1468 Local<v8::Integer> value_obj = v8::Integer::New(value); |
| 1469 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1469 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1470 | 1470 |
| 1471 value_obj = v8::Integer::New(value, isolate); | 1471 value_obj = v8::Integer::New(value, isolate); |
| 1472 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1472 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1473 } | 1473 } |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 | 1476 |
| 1477 THREADED_TEST(TinyUnsignedInteger) { | 1477 THREADED_TEST(TinyUnsignedInteger) { |
| 1478 LocalContext env; | 1478 LocalContext env; |
| 1479 v8::HandleScope scope(env->GetIsolate()); | 1479 v8::HandleScope scope(env->GetIsolate()); |
| 1480 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1480 v8::Isolate* isolate = CcTest::isolate(); |
| 1481 | 1481 |
| 1482 uint32_t value = 239; | 1482 uint32_t value = 239; |
| 1483 | 1483 |
| 1484 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1484 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1485 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1485 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1486 | 1486 |
| 1487 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1487 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1488 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1488 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1489 } | 1489 } |
| 1490 | 1490 |
| 1491 | 1491 |
| 1492 THREADED_TEST(BigUnsignedSmiInteger) { | 1492 THREADED_TEST(BigUnsignedSmiInteger) { |
| 1493 LocalContext env; | 1493 LocalContext env; |
| 1494 v8::HandleScope scope(env->GetIsolate()); | 1494 v8::HandleScope scope(env->GetIsolate()); |
| 1495 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1495 v8::Isolate* isolate = CcTest::isolate(); |
| 1496 | 1496 |
| 1497 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue); | 1497 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue); |
| 1498 CHECK(i::Smi::IsValid(value)); | 1498 CHECK(i::Smi::IsValid(value)); |
| 1499 CHECK(!i::Smi::IsValid(value + 1)); | 1499 CHECK(!i::Smi::IsValid(value + 1)); |
| 1500 | 1500 |
| 1501 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1501 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1502 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1502 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1503 | 1503 |
| 1504 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1504 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1505 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1505 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 | 1508 |
| 1509 THREADED_TEST(BigUnsignedInteger) { | 1509 THREADED_TEST(BigUnsignedInteger) { |
| 1510 LocalContext env; | 1510 LocalContext env; |
| 1511 v8::HandleScope scope(env->GetIsolate()); | 1511 v8::HandleScope scope(env->GetIsolate()); |
| 1512 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1512 v8::Isolate* isolate = CcTest::isolate(); |
| 1513 | 1513 |
| 1514 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1; | 1514 uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1; |
| 1515 CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue)); | 1515 CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue)); |
| 1516 CHECK(!i::Smi::IsValid(value)); | 1516 CHECK(!i::Smi::IsValid(value)); |
| 1517 | 1517 |
| 1518 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1518 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1519 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1519 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1520 | 1520 |
| 1521 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1521 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1522 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1522 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1523 } | 1523 } |
| 1524 | 1524 |
| 1525 | 1525 |
| 1526 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { | 1526 THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
| 1527 LocalContext env; | 1527 LocalContext env; |
| 1528 v8::HandleScope scope(env->GetIsolate()); | 1528 v8::HandleScope scope(env->GetIsolate()); |
| 1529 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 1529 v8::Isolate* isolate = CcTest::isolate(); |
| 1530 | 1530 |
| 1531 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; | 1531 uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; |
| 1532 uint32_t value = INT32_MAX_AS_UINT + 1; | 1532 uint32_t value = INT32_MAX_AS_UINT + 1; |
| 1533 CHECK(value > INT32_MAX_AS_UINT); // No overflow. | 1533 CHECK(value > INT32_MAX_AS_UINT); // No overflow. |
| 1534 | 1534 |
| 1535 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); | 1535 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value); |
| 1536 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1536 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| 1537 | 1537 |
| 1538 value_obj = v8::Integer::NewFromUnsigned(value, isolate); | 1538 value_obj = v8::Integer::NewFromUnsigned(value, isolate); |
| 1539 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); | 1539 CHECK_EQ(static_cast<int64_t>(value), value_obj->Value()); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 | 1738 |
| 1739 | 1739 |
| 1740 static void GetM(Local<String> name, | 1740 static void GetM(Local<String> name, |
| 1741 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1741 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1742 ApiTestFuzzer::Fuzz(); | 1742 ApiTestFuzzer::Fuzz(); |
| 1743 info.GetReturnValue().Set(v8_num(876)); | 1743 info.GetReturnValue().Set(v8_num(876)); |
| 1744 } | 1744 } |
| 1745 | 1745 |
| 1746 | 1746 |
| 1747 THREADED_TEST(GlobalPrototype) { | 1747 THREADED_TEST(GlobalPrototype) { |
| 1748 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1748 v8::HandleScope scope(CcTest::isolate()); |
| 1749 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); | 1749 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); |
| 1750 func_templ->PrototypeTemplate()->Set( | 1750 func_templ->PrototypeTemplate()->Set( |
| 1751 "dummy", | 1751 "dummy", |
| 1752 v8::FunctionTemplate::New(DummyCallHandler)); | 1752 v8::FunctionTemplate::New(DummyCallHandler)); |
| 1753 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); | 1753 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); |
| 1754 templ->Set("x", v8_num(200)); | 1754 templ->Set("x", v8_num(200)); |
| 1755 templ->SetAccessor(v8_str("m"), GetM); | 1755 templ->SetAccessor(v8_str("m"), GetM); |
| 1756 LocalContext env(0, templ); | 1756 LocalContext env(0, templ); |
| 1757 v8::Handle<Script> script(v8_compile("dummy()")); | 1757 v8::Handle<Script> script(v8_compile("dummy()")); |
| 1758 v8::Handle<Value> result(script->Run()); | 1758 v8::Handle<Value> result(script->Run()); |
| 1759 CHECK_EQ(13.4, result->NumberValue()); | 1759 CHECK_EQ(13.4, result->NumberValue()); |
| 1760 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); | 1760 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); |
| 1761 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); | 1761 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); |
| 1762 } | 1762 } |
| 1763 | 1763 |
| 1764 | 1764 |
| 1765 THREADED_TEST(ObjectTemplate) { | 1765 THREADED_TEST(ObjectTemplate) { |
| 1766 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1766 v8::HandleScope scope(CcTest::isolate()); |
| 1767 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); | 1767 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); |
| 1768 templ1->Set("x", v8_num(10)); | 1768 templ1->Set("x", v8_num(10)); |
| 1769 templ1->Set("y", v8_num(13)); | 1769 templ1->Set("y", v8_num(13)); |
| 1770 LocalContext env; | 1770 LocalContext env; |
| 1771 Local<v8::Object> instance1 = templ1->NewInstance(); | 1771 Local<v8::Object> instance1 = templ1->NewInstance(); |
| 1772 env->Global()->Set(v8_str("p"), instance1); | 1772 env->Global()->Set(v8_str("p"), instance1); |
| 1773 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); | 1773 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); |
| 1774 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); | 1774 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); |
| 1775 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); | 1775 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); |
| 1776 fun->PrototypeTemplate()->Set("nirk", v8_num(123)); | 1776 fun->PrototypeTemplate()->Set("nirk", v8_num(123)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1793 | 1793 |
| 1794 | 1794 |
| 1795 static void GetKnurd(Local<String> property, | 1795 static void GetKnurd(Local<String> property, |
| 1796 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1796 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1797 ApiTestFuzzer::Fuzz(); | 1797 ApiTestFuzzer::Fuzz(); |
| 1798 info.GetReturnValue().Set(v8_num(15.2)); | 1798 info.GetReturnValue().Set(v8_num(15.2)); |
| 1799 } | 1799 } |
| 1800 | 1800 |
| 1801 | 1801 |
| 1802 THREADED_TEST(DescriptorInheritance) { | 1802 THREADED_TEST(DescriptorInheritance) { |
| 1803 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1803 v8::HandleScope scope(CcTest::isolate()); |
| 1804 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); | 1804 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); |
| 1805 super->PrototypeTemplate()->Set("flabby", | 1805 super->PrototypeTemplate()->Set("flabby", |
| 1806 v8::FunctionTemplate::New(GetFlabby)); | 1806 v8::FunctionTemplate::New(GetFlabby)); |
| 1807 super->PrototypeTemplate()->Set("PI", v8_num(3.14)); | 1807 super->PrototypeTemplate()->Set("PI", v8_num(3.14)); |
| 1808 | 1808 |
| 1809 super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd); | 1809 super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd); |
| 1810 | 1810 |
| 1811 v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(); | 1811 v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(); |
| 1812 base1->Inherit(super); | 1812 base1->Inherit(super); |
| 1813 base1->PrototypeTemplate()->Set("v1", v8_num(20.1)); | 1813 base1->PrototypeTemplate()->Set("v1", v8_num(20.1)); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 void AddInterceptor(Handle<FunctionTemplate> templ, | 1936 void AddInterceptor(Handle<FunctionTemplate> templ, |
| 1937 v8::NamedPropertyGetterCallback getter, | 1937 v8::NamedPropertyGetterCallback getter, |
| 1938 v8::NamedPropertySetterCallback setter) { | 1938 v8::NamedPropertySetterCallback setter) { |
| 1939 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); | 1939 templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); |
| 1940 } | 1940 } |
| 1941 | 1941 |
| 1942 | 1942 |
| 1943 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { | 1943 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { |
| 1944 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1944 v8::HandleScope scope(CcTest::isolate()); |
| 1945 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1945 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 1946 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1946 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 1947 child->Inherit(parent); | 1947 child->Inherit(parent); |
| 1948 AddAccessor(parent, v8_str("age"), | 1948 AddAccessor(parent, v8_str("age"), |
| 1949 SimpleAccessorGetter, SimpleAccessorSetter); | 1949 SimpleAccessorGetter, SimpleAccessorSetter); |
| 1950 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 1950 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1951 LocalContext env; | 1951 LocalContext env; |
| 1952 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 1952 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 1953 CompileRun("var child = new Child;" | 1953 CompileRun("var child = new Child;" |
| 1954 "child.age = 10;"); | 1954 "child.age = 10;"); |
| 1955 ExpectBoolean("child.hasOwnProperty('age')", false); | 1955 ExpectBoolean("child.hasOwnProperty('age')", false); |
| 1956 ExpectInt32("child.age", 10); | 1956 ExpectInt32("child.age", 10); |
| 1957 ExpectInt32("child.accessor_age", 10); | 1957 ExpectInt32("child.accessor_age", 10); |
| 1958 } | 1958 } |
| 1959 | 1959 |
| 1960 | 1960 |
| 1961 THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) { | 1961 THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) { |
| 1962 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1962 v8::HandleScope scope(CcTest::isolate()); |
| 1963 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1963 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 1964 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1964 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 1965 child->Inherit(parent); | 1965 child->Inherit(parent); |
| 1966 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 1966 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1967 LocalContext env; | 1967 LocalContext env; |
| 1968 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 1968 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 1969 CompileRun("var child = new Child;" | 1969 CompileRun("var child = new Child;" |
| 1970 "var parent = child.__proto__;" | 1970 "var parent = child.__proto__;" |
| 1971 "Object.defineProperty(parent, 'age', " | 1971 "Object.defineProperty(parent, 'age', " |
| 1972 " {get: function(){ return this.accessor_age; }, " | 1972 " {get: function(){ return this.accessor_age; }, " |
| 1973 " set: function(v){ this.accessor_age = v; }, " | 1973 " set: function(v){ this.accessor_age = v; }, " |
| 1974 " enumerable: true, configurable: true});" | 1974 " enumerable: true, configurable: true});" |
| 1975 "child.age = 10;"); | 1975 "child.age = 10;"); |
| 1976 ExpectBoolean("child.hasOwnProperty('age')", false); | 1976 ExpectBoolean("child.hasOwnProperty('age')", false); |
| 1977 ExpectInt32("child.age", 10); | 1977 ExpectInt32("child.age", 10); |
| 1978 ExpectInt32("child.accessor_age", 10); | 1978 ExpectInt32("child.accessor_age", 10); |
| 1979 } | 1979 } |
| 1980 | 1980 |
| 1981 | 1981 |
| 1982 THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) { | 1982 THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) { |
| 1983 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 1983 v8::HandleScope scope(CcTest::isolate()); |
| 1984 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 1984 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 1985 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 1985 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 1986 child->Inherit(parent); | 1986 child->Inherit(parent); |
| 1987 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); | 1987 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 1988 LocalContext env; | 1988 LocalContext env; |
| 1989 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 1989 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 1990 CompileRun("var child = new Child;" | 1990 CompileRun("var child = new Child;" |
| 1991 "var parent = child.__proto__;" | 1991 "var parent = child.__proto__;" |
| 1992 "parent.name = 'Alice';"); | 1992 "parent.name = 'Alice';"); |
| 1993 ExpectBoolean("child.hasOwnProperty('name')", false); | 1993 ExpectBoolean("child.hasOwnProperty('name')", false); |
| 1994 ExpectString("child.name", "Alice"); | 1994 ExpectString("child.name", "Alice"); |
| 1995 CompileRun("child.name = 'Bob';"); | 1995 CompileRun("child.name = 'Bob';"); |
| 1996 ExpectString("child.name", "Bob"); | 1996 ExpectString("child.name", "Bob"); |
| 1997 ExpectBoolean("child.hasOwnProperty('name')", true); | 1997 ExpectBoolean("child.hasOwnProperty('name')", true); |
| 1998 ExpectString("parent.name", "Alice"); | 1998 ExpectString("parent.name", "Alice"); |
| 1999 } | 1999 } |
| 2000 | 2000 |
| 2001 | 2001 |
| 2002 THREADED_TEST(SwitchFromInterceptorToAccessor) { | 2002 THREADED_TEST(SwitchFromInterceptorToAccessor) { |
| 2003 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2003 v8::HandleScope scope(CcTest::isolate()); |
| 2004 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2004 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 2005 AddAccessor(templ, v8_str("age"), | 2005 AddAccessor(templ, v8_str("age"), |
| 2006 SimpleAccessorGetter, SimpleAccessorSetter); | 2006 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2007 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2007 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2008 LocalContext env; | 2008 LocalContext env; |
| 2009 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2009 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2010 CompileRun("var obj = new Obj;" | 2010 CompileRun("var obj = new Obj;" |
| 2011 "function setAge(i){ obj.age = i; };" | 2011 "function setAge(i){ obj.age = i; };" |
| 2012 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2012 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2013 // All i < 10000 go to the interceptor. | 2013 // All i < 10000 go to the interceptor. |
| 2014 ExpectInt32("obj.interceptor_age", 9999); | 2014 ExpectInt32("obj.interceptor_age", 9999); |
| 2015 // The last i goes to the accessor. | 2015 // The last i goes to the accessor. |
| 2016 ExpectInt32("obj.accessor_age", 10000); | 2016 ExpectInt32("obj.accessor_age", 10000); |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 | 2019 |
| 2020 THREADED_TEST(SwitchFromAccessorToInterceptor) { | 2020 THREADED_TEST(SwitchFromAccessorToInterceptor) { |
| 2021 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2021 v8::HandleScope scope(CcTest::isolate()); |
| 2022 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2022 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 2023 AddAccessor(templ, v8_str("age"), | 2023 AddAccessor(templ, v8_str("age"), |
| 2024 SimpleAccessorGetter, SimpleAccessorSetter); | 2024 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2025 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2025 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2026 LocalContext env; | 2026 LocalContext env; |
| 2027 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2027 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2028 CompileRun("var obj = new Obj;" | 2028 CompileRun("var obj = new Obj;" |
| 2029 "function setAge(i){ obj.age = i; };" | 2029 "function setAge(i){ obj.age = i; };" |
| 2030 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2030 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2031 // All i >= 10000 go to the accessor. | 2031 // All i >= 10000 go to the accessor. |
| 2032 ExpectInt32("obj.accessor_age", 10000); | 2032 ExpectInt32("obj.accessor_age", 10000); |
| 2033 // The last i goes to the interceptor. | 2033 // The last i goes to the interceptor. |
| 2034 ExpectInt32("obj.interceptor_age", 9999); | 2034 ExpectInt32("obj.interceptor_age", 9999); |
| 2035 } | 2035 } |
| 2036 | 2036 |
| 2037 | 2037 |
| 2038 THREADED_TEST(SwitchFromInterceptorToAccessorWithInheritance) { | 2038 THREADED_TEST(SwitchFromInterceptorToAccessorWithInheritance) { |
| 2039 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2039 v8::HandleScope scope(CcTest::isolate()); |
| 2040 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2040 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 2041 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2041 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 2042 child->Inherit(parent); | 2042 child->Inherit(parent); |
| 2043 AddAccessor(parent, v8_str("age"), | 2043 AddAccessor(parent, v8_str("age"), |
| 2044 SimpleAccessorGetter, SimpleAccessorSetter); | 2044 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2045 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2045 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2046 LocalContext env; | 2046 LocalContext env; |
| 2047 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2047 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2048 CompileRun("var child = new Child;" | 2048 CompileRun("var child = new Child;" |
| 2049 "function setAge(i){ child.age = i; };" | 2049 "function setAge(i){ child.age = i; };" |
| 2050 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2050 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2051 // All i < 10000 go to the interceptor. | 2051 // All i < 10000 go to the interceptor. |
| 2052 ExpectInt32("child.interceptor_age", 9999); | 2052 ExpectInt32("child.interceptor_age", 9999); |
| 2053 // The last i goes to the accessor. | 2053 // The last i goes to the accessor. |
| 2054 ExpectInt32("child.accessor_age", 10000); | 2054 ExpectInt32("child.accessor_age", 10000); |
| 2055 } | 2055 } |
| 2056 | 2056 |
| 2057 | 2057 |
| 2058 THREADED_TEST(SwitchFromAccessorToInterceptorWithInheritance) { | 2058 THREADED_TEST(SwitchFromAccessorToInterceptorWithInheritance) { |
| 2059 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2059 v8::HandleScope scope(CcTest::isolate()); |
| 2060 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2060 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 2061 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2061 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 2062 child->Inherit(parent); | 2062 child->Inherit(parent); |
| 2063 AddAccessor(parent, v8_str("age"), | 2063 AddAccessor(parent, v8_str("age"), |
| 2064 SimpleAccessorGetter, SimpleAccessorSetter); | 2064 SimpleAccessorGetter, SimpleAccessorSetter); |
| 2065 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2065 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2066 LocalContext env; | 2066 LocalContext env; |
| 2067 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2067 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2068 CompileRun("var child = new Child;" | 2068 CompileRun("var child = new Child;" |
| 2069 "function setAge(i){ child.age = i; };" | 2069 "function setAge(i){ child.age = i; };" |
| 2070 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2070 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2071 // All i >= 10000 go to the accessor. | 2071 // All i >= 10000 go to the accessor. |
| 2072 ExpectInt32("child.accessor_age", 10000); | 2072 ExpectInt32("child.accessor_age", 10000); |
| 2073 // The last i goes to the interceptor. | 2073 // The last i goes to the interceptor. |
| 2074 ExpectInt32("child.interceptor_age", 9999); | 2074 ExpectInt32("child.interceptor_age", 9999); |
| 2075 } | 2075 } |
| 2076 | 2076 |
| 2077 | 2077 |
| 2078 THREADED_TEST(SwitchFromInterceptorToJSAccessor) { | 2078 THREADED_TEST(SwitchFromInterceptorToJSAccessor) { |
| 2079 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2079 v8::HandleScope scope(CcTest::isolate()); |
| 2080 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2080 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 2081 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2081 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2082 LocalContext env; | 2082 LocalContext env; |
| 2083 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2083 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2084 CompileRun("var obj = new Obj;" | 2084 CompileRun("var obj = new Obj;" |
| 2085 "function setter(i) { this.accessor_age = i; };" | 2085 "function setter(i) { this.accessor_age = i; };" |
| 2086 "function getter() { return this.accessor_age; };" | 2086 "function getter() { return this.accessor_age; };" |
| 2087 "function setAge(i) { obj.age = i; };" | 2087 "function setAge(i) { obj.age = i; };" |
| 2088 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" | 2088 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" |
| 2089 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2089 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2090 // All i < 10000 go to the interceptor. | 2090 // All i < 10000 go to the interceptor. |
| 2091 ExpectInt32("obj.interceptor_age", 9999); | 2091 ExpectInt32("obj.interceptor_age", 9999); |
| 2092 // The last i goes to the JavaScript accessor. | 2092 // The last i goes to the JavaScript accessor. |
| 2093 ExpectInt32("obj.accessor_age", 10000); | 2093 ExpectInt32("obj.accessor_age", 10000); |
| 2094 // The installed JavaScript getter is still intact. | 2094 // The installed JavaScript getter is still intact. |
| 2095 // This last part is a regression test for issue 1651 and relies on the fact | 2095 // This last part is a regression test for issue 1651 and relies on the fact |
| 2096 // that both interceptor and accessor are being installed on the same object. | 2096 // that both interceptor and accessor are being installed on the same object. |
| 2097 ExpectInt32("obj.age", 10000); | 2097 ExpectInt32("obj.age", 10000); |
| 2098 ExpectBoolean("obj.hasOwnProperty('age')", true); | 2098 ExpectBoolean("obj.hasOwnProperty('age')", true); |
| 2099 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); | 2099 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); |
| 2100 } | 2100 } |
| 2101 | 2101 |
| 2102 | 2102 |
| 2103 THREADED_TEST(SwitchFromJSAccessorToInterceptor) { | 2103 THREADED_TEST(SwitchFromJSAccessorToInterceptor) { |
| 2104 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2104 v8::HandleScope scope(CcTest::isolate()); |
| 2105 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 2105 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 2106 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 2106 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 2107 LocalContext env; | 2107 LocalContext env; |
| 2108 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 2108 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 2109 CompileRun("var obj = new Obj;" | 2109 CompileRun("var obj = new Obj;" |
| 2110 "function setter(i) { this.accessor_age = i; };" | 2110 "function setter(i) { this.accessor_age = i; };" |
| 2111 "function getter() { return this.accessor_age; };" | 2111 "function getter() { return this.accessor_age; };" |
| 2112 "function setAge(i) { obj.age = i; };" | 2112 "function setAge(i) { obj.age = i; };" |
| 2113 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" | 2113 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" |
| 2114 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2114 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2115 // All i >= 10000 go to the accessor. | 2115 // All i >= 10000 go to the accessor. |
| 2116 ExpectInt32("obj.accessor_age", 10000); | 2116 ExpectInt32("obj.accessor_age", 10000); |
| 2117 // The last i goes to the interceptor. | 2117 // The last i goes to the interceptor. |
| 2118 ExpectInt32("obj.interceptor_age", 9999); | 2118 ExpectInt32("obj.interceptor_age", 9999); |
| 2119 // The installed JavaScript getter is still intact. | 2119 // The installed JavaScript getter is still intact. |
| 2120 // This last part is a regression test for issue 1651 and relies on the fact | 2120 // This last part is a regression test for issue 1651 and relies on the fact |
| 2121 // that both interceptor and accessor are being installed on the same object. | 2121 // that both interceptor and accessor are being installed on the same object. |
| 2122 ExpectInt32("obj.age", 10000); | 2122 ExpectInt32("obj.age", 10000); |
| 2123 ExpectBoolean("obj.hasOwnProperty('age')", true); | 2123 ExpectBoolean("obj.hasOwnProperty('age')", true); |
| 2124 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); | 2124 ExpectUndefined("Object.getOwnPropertyDescriptor(obj, 'age').value"); |
| 2125 } | 2125 } |
| 2126 | 2126 |
| 2127 | 2127 |
| 2128 THREADED_TEST(SwitchFromInterceptorToProperty) { | 2128 THREADED_TEST(SwitchFromInterceptorToProperty) { |
| 2129 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2129 v8::HandleScope scope(CcTest::isolate()); |
| 2130 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2130 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 2131 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2131 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 2132 child->Inherit(parent); | 2132 child->Inherit(parent); |
| 2133 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2133 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2134 LocalContext env; | 2134 LocalContext env; |
| 2135 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2135 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2136 CompileRun("var child = new Child;" | 2136 CompileRun("var child = new Child;" |
| 2137 "function setAge(i){ child.age = i; };" | 2137 "function setAge(i){ child.age = i; };" |
| 2138 "for(var i = 0; i <= 10000; i++) setAge(i);"); | 2138 "for(var i = 0; i <= 10000; i++) setAge(i);"); |
| 2139 // All i < 10000 go to the interceptor. | 2139 // All i < 10000 go to the interceptor. |
| 2140 ExpectInt32("child.interceptor_age", 9999); | 2140 ExpectInt32("child.interceptor_age", 9999); |
| 2141 // The last i goes to child's own property. | 2141 // The last i goes to child's own property. |
| 2142 ExpectInt32("child.age", 10000); | 2142 ExpectInt32("child.age", 10000); |
| 2143 } | 2143 } |
| 2144 | 2144 |
| 2145 | 2145 |
| 2146 THREADED_TEST(SwitchFromPropertyToInterceptor) { | 2146 THREADED_TEST(SwitchFromPropertyToInterceptor) { |
| 2147 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2147 v8::HandleScope scope(CcTest::isolate()); |
| 2148 Handle<FunctionTemplate> parent = FunctionTemplate::New(); | 2148 Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
| 2149 Handle<FunctionTemplate> child = FunctionTemplate::New(); | 2149 Handle<FunctionTemplate> child = FunctionTemplate::New(); |
| 2150 child->Inherit(parent); | 2150 child->Inherit(parent); |
| 2151 AddInterceptor(child, InterceptorGetter, InterceptorSetter); | 2151 AddInterceptor(child, InterceptorGetter, InterceptorSetter); |
| 2152 LocalContext env; | 2152 LocalContext env; |
| 2153 env->Global()->Set(v8_str("Child"), child->GetFunction()); | 2153 env->Global()->Set(v8_str("Child"), child->GetFunction()); |
| 2154 CompileRun("var child = new Child;" | 2154 CompileRun("var child = new Child;" |
| 2155 "function setAge(i){ child.age = i; };" | 2155 "function setAge(i){ child.age = i; };" |
| 2156 "for(var i = 20000; i >= 9999; i--) setAge(i);"); | 2156 "for(var i = 20000; i >= 9999; i--) setAge(i);"); |
| 2157 // All i >= 10000 go to child's own property. | 2157 // All i >= 10000 go to child's own property. |
| 2158 ExpectInt32("child.age", 10000); | 2158 ExpectInt32("child.age", 10000); |
| 2159 // The last i goes to the interceptor. | 2159 // The last i goes to the interceptor. |
| 2160 ExpectInt32("child.interceptor_age", 9999); | 2160 ExpectInt32("child.interceptor_age", 9999); |
| 2161 } | 2161 } |
| 2162 | 2162 |
| 2163 | 2163 |
| 2164 THREADED_TEST(NamedPropertyHandlerGetter) { | 2164 THREADED_TEST(NamedPropertyHandlerGetter) { |
| 2165 echo_named_call_count = 0; | 2165 echo_named_call_count = 0; |
| 2166 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2166 v8::HandleScope scope(CcTest::isolate()); |
| 2167 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2167 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 2168 templ->InstanceTemplate()->SetNamedPropertyHandler(EchoNamedProperty, | 2168 templ->InstanceTemplate()->SetNamedPropertyHandler(EchoNamedProperty, |
| 2169 0, 0, 0, 0, | 2169 0, 0, 0, 0, |
| 2170 v8_str("data")); | 2170 v8_str("data")); |
| 2171 LocalContext env; | 2171 LocalContext env; |
| 2172 env->Global()->Set(v8_str("obj"), | 2172 env->Global()->Set(v8_str("obj"), |
| 2173 templ->GetFunction()->NewInstance()); | 2173 templ->GetFunction()->NewInstance()); |
| 2174 CHECK_EQ(echo_named_call_count, 0); | 2174 CHECK_EQ(echo_named_call_count, 0); |
| 2175 v8_compile("obj.x")->Run(); | 2175 v8_compile("obj.x")->Run(); |
| 2176 CHECK_EQ(echo_named_call_count, 1); | 2176 CHECK_EQ(echo_named_call_count, 1); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2192 uint32_t index, | 2192 uint32_t index, |
| 2193 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2193 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2194 ApiTestFuzzer::Fuzz(); | 2194 ApiTestFuzzer::Fuzz(); |
| 2195 CHECK_EQ(v8_num(637), info.Data()); | 2195 CHECK_EQ(v8_num(637), info.Data()); |
| 2196 echo_indexed_call_count++; | 2196 echo_indexed_call_count++; |
| 2197 info.GetReturnValue().Set(v8_num(index)); | 2197 info.GetReturnValue().Set(v8_num(index)); |
| 2198 } | 2198 } |
| 2199 | 2199 |
| 2200 | 2200 |
| 2201 THREADED_TEST(IndexedPropertyHandlerGetter) { | 2201 THREADED_TEST(IndexedPropertyHandlerGetter) { |
| 2202 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2202 v8::HandleScope scope(CcTest::isolate()); |
| 2203 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2203 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 2204 templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, | 2204 templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, |
| 2205 0, 0, 0, 0, | 2205 0, 0, 0, 0, |
| 2206 v8_num(637)); | 2206 v8_num(637)); |
| 2207 LocalContext env; | 2207 LocalContext env; |
| 2208 env->Global()->Set(v8_str("obj"), | 2208 env->Global()->Set(v8_str("obj"), |
| 2209 templ->GetFunction()->NewInstance()); | 2209 templ->GetFunction()->NewInstance()); |
| 2210 Local<Script> script = v8_compile("obj[900]"); | 2210 Local<Script> script = v8_compile("obj[900]"); |
| 2211 CHECK_EQ(script->Run()->Int32Value(), 900); | 2211 CHECK_EQ(script->Run()->Int32Value(), 900); |
| 2212 } | 2212 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2363 static void PrePropertyHandlerQuery( | 2363 static void PrePropertyHandlerQuery( |
| 2364 Local<String> key, | 2364 Local<String> key, |
| 2365 const v8::PropertyCallbackInfo<v8::Integer>& info) { | 2365 const v8::PropertyCallbackInfo<v8::Integer>& info) { |
| 2366 if (v8_str("pre")->Equals(key)) { | 2366 if (v8_str("pre")->Equals(key)) { |
| 2367 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); | 2367 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); |
| 2368 } | 2368 } |
| 2369 } | 2369 } |
| 2370 | 2370 |
| 2371 | 2371 |
| 2372 THREADED_TEST(PrePropertyHandler) { | 2372 THREADED_TEST(PrePropertyHandler) { |
| 2373 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2373 v8::HandleScope scope(CcTest::isolate()); |
| 2374 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); | 2374 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); |
| 2375 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, | 2375 desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, |
| 2376 0, | 2376 0, |
| 2377 PrePropertyHandlerQuery); | 2377 PrePropertyHandlerQuery); |
| 2378 LocalContext env(NULL, desc->InstanceTemplate()); | 2378 LocalContext env(NULL, desc->InstanceTemplate()); |
| 2379 Script::Compile(v8_str( | 2379 Script::Compile(v8_str( |
| 2380 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); | 2380 "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); |
| 2381 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); | 2381 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); |
| 2382 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); | 2382 CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); |
| 2383 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); | 2383 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 } | 2420 } |
| 2421 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); | 2421 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1)); |
| 2422 v8::Handle<Value> function = | 2422 v8::Handle<Value> function = |
| 2423 args.This()->Get(v8_str("callFunctionRecursively")); | 2423 args.This()->Get(v8_str("callFunctionRecursively")); |
| 2424 args.GetReturnValue().Set( | 2424 args.GetReturnValue().Set( |
| 2425 function.As<Function>()->Call(args.This(), 0, NULL)); | 2425 function.As<Function>()->Call(args.This(), 0, NULL)); |
| 2426 } | 2426 } |
| 2427 | 2427 |
| 2428 | 2428 |
| 2429 THREADED_TEST(DeepCrossLanguageRecursion) { | 2429 THREADED_TEST(DeepCrossLanguageRecursion) { |
| 2430 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2430 v8::HandleScope scope(CcTest::isolate()); |
| 2431 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 2431 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 2432 global->Set(v8_str("callScriptRecursively"), | 2432 global->Set(v8_str("callScriptRecursively"), |
| 2433 v8::FunctionTemplate::New(CallScriptRecursivelyCall)); | 2433 v8::FunctionTemplate::New(CallScriptRecursivelyCall)); |
| 2434 global->Set(v8_str("callFunctionRecursively"), | 2434 global->Set(v8_str("callFunctionRecursively"), |
| 2435 v8::FunctionTemplate::New(CallFunctionRecursivelyCall)); | 2435 v8::FunctionTemplate::New(CallFunctionRecursivelyCall)); |
| 2436 LocalContext env(NULL, global); | 2436 LocalContext env(NULL, global); |
| 2437 | 2437 |
| 2438 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); | 2438 env->Global()->Set(v8_str("depth"), v8::Integer::New(0)); |
| 2439 call_recursively_script = v8_compile("callScriptRecursively()"); | 2439 call_recursively_script = v8_compile("callScriptRecursively()"); |
| 2440 call_recursively_script->Run(); | 2440 call_recursively_script->Run(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2456 static void ThrowingPropertyHandlerSet( | 2456 static void ThrowingPropertyHandlerSet( |
| 2457 Local<String> key, | 2457 Local<String> key, |
| 2458 Local<Value>, | 2458 Local<Value>, |
| 2459 const v8::PropertyCallbackInfo<v8::Value>& info) { | 2459 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 2460 v8::ThrowException(key); | 2460 v8::ThrowException(key); |
| 2461 info.GetReturnValue().SetUndefined(); // not the same as empty handle | 2461 info.GetReturnValue().SetUndefined(); // not the same as empty handle |
| 2462 } | 2462 } |
| 2463 | 2463 |
| 2464 | 2464 |
| 2465 THREADED_TEST(CallbackExceptionRegression) { | 2465 THREADED_TEST(CallbackExceptionRegression) { |
| 2466 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2466 v8::HandleScope scope(CcTest::isolate()); |
| 2467 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 2467 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 2468 obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet, | 2468 obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet, |
| 2469 ThrowingPropertyHandlerSet); | 2469 ThrowingPropertyHandlerSet); |
| 2470 LocalContext env; | 2470 LocalContext env; |
| 2471 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 2471 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
| 2472 v8::Handle<Value> otto = Script::Compile(v8_str( | 2472 v8::Handle<Value> otto = Script::Compile(v8_str( |
| 2473 "try { with (obj) { otto; } } catch (e) { e; }"))->Run(); | 2473 "try { with (obj) { otto; } } catch (e) { e; }"))->Run(); |
| 2474 CHECK_EQ(v8_str("otto"), otto); | 2474 CHECK_EQ(v8_str("otto"), otto); |
| 2475 v8::Handle<Value> netto = Script::Compile(v8_str( | 2475 v8::Handle<Value> netto = Script::Compile(v8_str( |
| 2476 "try { with (obj) { netto = 4; } } catch (e) { e; }"))->Run(); | 2476 "try { with (obj) { netto = 4; } } catch (e) { e; }"))->Run(); |
| 2477 CHECK_EQ(v8_str("netto"), netto); | 2477 CHECK_EQ(v8_str("netto"), netto); |
| 2478 } | 2478 } |
| 2479 | 2479 |
| 2480 | 2480 |
| 2481 THREADED_TEST(FunctionPrototype) { | 2481 THREADED_TEST(FunctionPrototype) { |
| 2482 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2482 v8::HandleScope scope(CcTest::isolate()); |
| 2483 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(); | 2483 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(); |
| 2484 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); | 2484 Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); |
| 2485 LocalContext env; | 2485 LocalContext env; |
| 2486 env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); | 2486 env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); |
| 2487 Local<Script> script = Script::Compile(v8_str("Foo.prototype.plak")); | 2487 Local<Script> script = Script::Compile(v8_str("Foo.prototype.plak")); |
| 2488 CHECK_EQ(script->Run()->Int32Value(), 321); | 2488 CHECK_EQ(script->Run()->Int32Value(), 321); |
| 2489 } | 2489 } |
| 2490 | 2490 |
| 2491 | 2491 |
| 2492 THREADED_TEST(InternalFields) { | 2492 THREADED_TEST(InternalFields) { |
| 2493 LocalContext env; | 2493 LocalContext env; |
| 2494 v8::HandleScope scope(env->GetIsolate()); | 2494 v8::HandleScope scope(env->GetIsolate()); |
| 2495 | 2495 |
| 2496 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2496 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 2497 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 2497 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
| 2498 instance_templ->SetInternalFieldCount(1); | 2498 instance_templ->SetInternalFieldCount(1); |
| 2499 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); | 2499 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); |
| 2500 CHECK_EQ(1, obj->InternalFieldCount()); | 2500 CHECK_EQ(1, obj->InternalFieldCount()); |
| 2501 CHECK(obj->GetInternalField(0)->IsUndefined()); | 2501 CHECK(obj->GetInternalField(0)->IsUndefined()); |
| 2502 obj->SetInternalField(0, v8_num(17)); | 2502 obj->SetInternalField(0, v8_num(17)); |
| 2503 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); | 2503 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); |
| 2504 } | 2504 } |
| 2505 | 2505 |
| 2506 | 2506 |
| 2507 THREADED_TEST(GlobalObjectInternalFields) { | 2507 THREADED_TEST(GlobalObjectInternalFields) { |
| 2508 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2508 v8::HandleScope scope(CcTest::isolate()); |
| 2509 Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 2509 Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 2510 global_template->SetInternalFieldCount(1); | 2510 global_template->SetInternalFieldCount(1); |
| 2511 LocalContext env(NULL, global_template); | 2511 LocalContext env(NULL, global_template); |
| 2512 v8::Handle<v8::Object> global_proxy = env->Global(); | 2512 v8::Handle<v8::Object> global_proxy = env->Global(); |
| 2513 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); | 2513 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); |
| 2514 CHECK_EQ(1, global->InternalFieldCount()); | 2514 CHECK_EQ(1, global->InternalFieldCount()); |
| 2515 CHECK(global->GetInternalField(0)->IsUndefined()); | 2515 CHECK(global->GetInternalField(0)->IsUndefined()); |
| 2516 global->SetInternalField(0, v8_num(17)); | 2516 global->SetInternalField(0, v8_num(17)); |
| 2517 CHECK_EQ(17, global->GetInternalField(0)->Int32Value()); | 2517 CHECK_EQ(17, global->GetInternalField(0)->Int32Value()); |
| 2518 } | 2518 } |
| 2519 | 2519 |
| 2520 | 2520 |
| 2521 THREADED_TEST(GlobalObjectHasRealIndexedProperty) { | 2521 THREADED_TEST(GlobalObjectHasRealIndexedProperty) { |
| 2522 LocalContext env; | 2522 LocalContext env; |
| 2523 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 2523 v8::HandleScope scope(CcTest::isolate()); |
| 2524 | 2524 |
| 2525 v8::Local<v8::Object> global = env->Global(); | 2525 v8::Local<v8::Object> global = env->Global(); |
| 2526 global->Set(0, v8::String::New("value")); | 2526 global->Set(0, v8::String::New("value")); |
| 2527 CHECK(global->HasRealIndexedProperty(0)); | 2527 CHECK(global->HasRealIndexedProperty(0)); |
| 2528 } | 2528 } |
| 2529 | 2529 |
| 2530 | 2530 |
| 2531 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, | 2531 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, |
| 2532 void* value) { | 2532 void* value) { |
| 2533 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2533 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3112 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); | 3112 instance_templ->SetNamedPropertyHandler(InterceptorForHiddenProperties); |
| 3113 Local<v8::Function> function = fun_templ->GetFunction(); | 3113 Local<v8::Function> function = fun_templ->GetFunction(); |
| 3114 Local<v8::Object> obj = function->NewInstance(); | 3114 Local<v8::Object> obj = function->NewInstance(); |
| 3115 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); | 3115 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302))); |
| 3116 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); | 3116 CHECK_EQ(2302, obj->GetHiddenValue(key)->Int32Value()); |
| 3117 CHECK(!interceptor_for_hidden_properties_called); | 3117 CHECK(!interceptor_for_hidden_properties_called); |
| 3118 } | 3118 } |
| 3119 | 3119 |
| 3120 | 3120 |
| 3121 THREADED_TEST(External) { | 3121 THREADED_TEST(External) { |
| 3122 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3122 v8::HandleScope scope(CcTest::isolate()); |
| 3123 int x = 3; | 3123 int x = 3; |
| 3124 Local<v8::External> ext = v8::External::New(&x); | 3124 Local<v8::External> ext = v8::External::New(&x); |
| 3125 LocalContext env; | 3125 LocalContext env; |
| 3126 env->Global()->Set(v8_str("ext"), ext); | 3126 env->Global()->Set(v8_str("ext"), ext); |
| 3127 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); | 3127 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
| 3128 v8::Handle<v8::External> reext = reext_obj.As<v8::External>(); | 3128 v8::Handle<v8::External> reext = reext_obj.As<v8::External>(); |
| 3129 int* ptr = static_cast<int*>(reext->Value()); | 3129 int* ptr = static_cast<int*>(reext->Value()); |
| 3130 CHECK_EQ(x, 3); | 3130 CHECK_EQ(x, 3); |
| 3131 *ptr = 10; | 3131 *ptr = 10; |
| 3132 CHECK_EQ(x, 10); | 3132 CHECK_EQ(x, 10); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3144 CHECK_EQ('1', *char_ptr); | 3144 CHECK_EQ('1', *char_ptr); |
| 3145 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*two)->Value()); | 3145 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*two)->Value()); |
| 3146 CHECK_EQ('2', *char_ptr); | 3146 CHECK_EQ('2', *char_ptr); |
| 3147 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*three)->Value()); | 3147 char_ptr = reinterpret_cast<char*>(v8::External::Cast(*three)->Value()); |
| 3148 CHECK_EQ('3', *char_ptr); | 3148 CHECK_EQ('3', *char_ptr); |
| 3149 i::DeleteArray(data); | 3149 i::DeleteArray(data); |
| 3150 } | 3150 } |
| 3151 | 3151 |
| 3152 | 3152 |
| 3153 THREADED_TEST(GlobalHandle) { | 3153 THREADED_TEST(GlobalHandle) { |
| 3154 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3154 v8::Isolate* isolate = CcTest::isolate(); |
| 3155 v8::Persistent<String> global; | 3155 v8::Persistent<String> global; |
| 3156 { | 3156 { |
| 3157 v8::HandleScope scope(isolate); | 3157 v8::HandleScope scope(isolate); |
| 3158 global.Reset(isolate, v8_str("str")); | 3158 global.Reset(isolate, v8_str("str")); |
| 3159 } | 3159 } |
| 3160 { | 3160 { |
| 3161 v8::HandleScope scope(isolate); | 3161 v8::HandleScope scope(isolate); |
| 3162 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3162 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3163 } | 3163 } |
| 3164 global.Dispose(); | 3164 global.Dispose(); |
| 3165 global.Clear(); | 3165 global.Clear(); |
| 3166 { | 3166 { |
| 3167 v8::HandleScope scope(isolate); | 3167 v8::HandleScope scope(isolate); |
| 3168 global.Reset(isolate, v8_str("str")); | 3168 global.Reset(isolate, v8_str("str")); |
| 3169 } | 3169 } |
| 3170 { | 3170 { |
| 3171 v8::HandleScope scope(isolate); | 3171 v8::HandleScope scope(isolate); |
| 3172 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3172 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3173 } | 3173 } |
| 3174 global.Dispose(); | 3174 global.Dispose(); |
| 3175 } | 3175 } |
| 3176 | 3176 |
| 3177 | 3177 |
| 3178 THREADED_TEST(ResettingGlobalHandle) { | 3178 THREADED_TEST(ResettingGlobalHandle) { |
| 3179 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3179 v8::Isolate* isolate = CcTest::isolate(); |
| 3180 v8::Persistent<String> global; | 3180 v8::Persistent<String> global; |
| 3181 { | 3181 { |
| 3182 v8::HandleScope scope(isolate); | 3182 v8::HandleScope scope(isolate); |
| 3183 global.Reset(isolate, v8_str("str")); | 3183 global.Reset(isolate, v8_str("str")); |
| 3184 } | 3184 } |
| 3185 v8::internal::GlobalHandles* global_handles = | 3185 v8::internal::GlobalHandles* global_handles = |
| 3186 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 3186 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 3187 int initial_handle_count = global_handles->global_handles_count(); | 3187 int initial_handle_count = global_handles->global_handles_count(); |
| 3188 { | 3188 { |
| 3189 v8::HandleScope scope(isolate); | 3189 v8::HandleScope scope(isolate); |
| 3190 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3190 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3191 } | 3191 } |
| 3192 { | 3192 { |
| 3193 v8::HandleScope scope(isolate); | 3193 v8::HandleScope scope(isolate); |
| 3194 global.Reset(isolate, v8_str("longer")); | 3194 global.Reset(isolate, v8_str("longer")); |
| 3195 } | 3195 } |
| 3196 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); | 3196 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); |
| 3197 { | 3197 { |
| 3198 v8::HandleScope scope(isolate); | 3198 v8::HandleScope scope(isolate); |
| 3199 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6); | 3199 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 6); |
| 3200 } | 3200 } |
| 3201 global.Dispose(); | 3201 global.Dispose(); |
| 3202 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); | 3202 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); |
| 3203 } | 3203 } |
| 3204 | 3204 |
| 3205 | 3205 |
| 3206 THREADED_TEST(ResettingGlobalHandleToEmpty) { | 3206 THREADED_TEST(ResettingGlobalHandleToEmpty) { |
| 3207 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3207 v8::Isolate* isolate = CcTest::isolate(); |
| 3208 v8::Persistent<String> global; | 3208 v8::Persistent<String> global; |
| 3209 { | 3209 { |
| 3210 v8::HandleScope scope(isolate); | 3210 v8::HandleScope scope(isolate); |
| 3211 global.Reset(isolate, v8_str("str")); | 3211 global.Reset(isolate, v8_str("str")); |
| 3212 } | 3212 } |
| 3213 v8::internal::GlobalHandles* global_handles = | 3213 v8::internal::GlobalHandles* global_handles = |
| 3214 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 3214 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 3215 int initial_handle_count = global_handles->global_handles_count(); | 3215 int initial_handle_count = global_handles->global_handles_count(); |
| 3216 { | 3216 { |
| 3217 v8::HandleScope scope(isolate); | 3217 v8::HandleScope scope(isolate); |
| 3218 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); | 3218 CHECK_EQ(v8::Local<String>::New(isolate, global)->Length(), 3); |
| 3219 } | 3219 } |
| 3220 { | 3220 { |
| 3221 v8::HandleScope scope(isolate); | 3221 v8::HandleScope scope(isolate); |
| 3222 Local<String> empty; | 3222 Local<String> empty; |
| 3223 global.Reset(isolate, empty); | 3223 global.Reset(isolate, empty); |
| 3224 } | 3224 } |
| 3225 CHECK(global.IsEmpty()); | 3225 CHECK(global.IsEmpty()); |
| 3226 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); | 3226 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); |
| 3227 } | 3227 } |
| 3228 | 3228 |
| 3229 | 3229 |
| 3230 THREADED_TEST(ClearAndLeakGlobal) { | 3230 THREADED_TEST(ClearAndLeakGlobal) { |
| 3231 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3231 v8::Isolate* isolate = CcTest::isolate(); |
| 3232 v8::internal::GlobalHandles* global_handles = NULL; | 3232 v8::internal::GlobalHandles* global_handles = NULL; |
| 3233 int initial_handle_count = 0; | 3233 int initial_handle_count = 0; |
| 3234 v8::Persistent<String> global; | 3234 v8::Persistent<String> global; |
| 3235 { | 3235 { |
| 3236 v8::HandleScope scope(isolate); | 3236 v8::HandleScope scope(isolate); |
| 3237 Local<String> str = v8_str("str"); | 3237 Local<String> str = v8_str("str"); |
| 3238 global_handles = | 3238 global_handles = |
| 3239 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); | 3239 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 3240 initial_handle_count = global_handles->global_handles_count(); | 3240 initial_handle_count = global_handles->global_handles_count(); |
| 3241 global.Reset(isolate, str); | 3241 global.Reset(isolate, str); |
| 3242 } | 3242 } |
| 3243 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); | 3243 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); |
| 3244 String* str = global.ClearAndLeak(); | 3244 String* str = global.ClearAndLeak(); |
| 3245 CHECK(global.IsEmpty()); | 3245 CHECK(global.IsEmpty()); |
| 3246 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); | 3246 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count + 1); |
| 3247 global_handles->Destroy(reinterpret_cast<i::Object**>(str)); | 3247 global_handles->Destroy(reinterpret_cast<i::Object**>(str)); |
| 3248 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); | 3248 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count); |
| 3249 } | 3249 } |
| 3250 | 3250 |
| 3251 | 3251 |
| 3252 THREADED_TEST(GlobalHandleUpcast) { | 3252 THREADED_TEST(GlobalHandleUpcast) { |
| 3253 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3253 v8::Isolate* isolate = CcTest::isolate(); |
| 3254 v8::HandleScope scope(isolate); | 3254 v8::HandleScope scope(isolate); |
| 3255 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); | 3255 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); |
| 3256 v8::Persistent<String> global_string(isolate, local); | 3256 v8::Persistent<String> global_string(isolate, local); |
| 3257 v8::Persistent<Value>& global_value = | 3257 v8::Persistent<Value>& global_value = |
| 3258 v8::Persistent<Value>::Cast(global_string); | 3258 v8::Persistent<Value>::Cast(global_string); |
| 3259 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); | 3259 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); |
| 3260 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); | 3260 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); |
| 3261 global_string.Dispose(); | 3261 global_string.Dispose(); |
| 3262 } | 3262 } |
| 3263 | 3263 |
| 3264 | 3264 |
| 3265 THREADED_TEST(HandleEquality) { | 3265 THREADED_TEST(HandleEquality) { |
| 3266 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 3266 v8::Isolate* isolate = CcTest::isolate(); |
| 3267 v8::Persistent<String> global1; | 3267 v8::Persistent<String> global1; |
| 3268 v8::Persistent<String> global2; | 3268 v8::Persistent<String> global2; |
| 3269 { | 3269 { |
| 3270 v8::HandleScope scope(isolate); | 3270 v8::HandleScope scope(isolate); |
| 3271 global1.Reset(isolate, v8_str("str")); | 3271 global1.Reset(isolate, v8_str("str")); |
| 3272 global2.Reset(isolate, v8_str("str2")); | 3272 global2.Reset(isolate, v8_str("str2")); |
| 3273 } | 3273 } |
| 3274 CHECK_EQ(global1 == global1, true); | 3274 CHECK_EQ(global1 == global1, true); |
| 3275 CHECK_EQ(global1 != global1, false); | 3275 CHECK_EQ(global1 != global1, false); |
| 3276 { | 3276 { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3294 Local<String> anotherLocal1 = Local<String>::New(isolate, global1); | 3294 Local<String> anotherLocal1 = Local<String>::New(isolate, global1); |
| 3295 CHECK_EQ(local1 == anotherLocal1, true); | 3295 CHECK_EQ(local1 == anotherLocal1, true); |
| 3296 CHECK_EQ(local1 != anotherLocal1, false); | 3296 CHECK_EQ(local1 != anotherLocal1, false); |
| 3297 } | 3297 } |
| 3298 global1.Dispose(); | 3298 global1.Dispose(); |
| 3299 global2.Dispose(); | 3299 global2.Dispose(); |
| 3300 } | 3300 } |
| 3301 | 3301 |
| 3302 | 3302 |
| 3303 THREADED_TEST(LocalHandle) { | 3303 THREADED_TEST(LocalHandle) { |
| 3304 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3304 v8::HandleScope scope(CcTest::isolate()); |
| 3305 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); | 3305 v8::Local<String> local = v8::Local<String>::New(v8_str("str")); |
| 3306 CHECK_EQ(local->Length(), 3); | 3306 CHECK_EQ(local->Length(), 3); |
| 3307 | 3307 |
| 3308 local = v8::Local<String>::New(v8::Isolate::GetCurrent(), v8_str("str")); | 3308 local = v8::Local<String>::New(CcTest::isolate(), v8_str("str")); |
| 3309 CHECK_EQ(local->Length(), 3); | 3309 CHECK_EQ(local->Length(), 3); |
| 3310 } | 3310 } |
| 3311 | 3311 |
| 3312 | 3312 |
| 3313 class WeakCallCounter { | 3313 class WeakCallCounter { |
| 3314 public: | 3314 public: |
| 3315 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } | 3315 explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } |
| 3316 int id() { return id_; } | 3316 int id() { return id_; } |
| 3317 void increment() { number_of_weak_calls_++; } | 3317 void increment() { number_of_weak_calls_++; } |
| 3318 int NumberOfWeakCalls() { return number_of_weak_calls_; } | 3318 int NumberOfWeakCalls() { return number_of_weak_calls_; } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3676 CHECK_EQ(5.76, data->NumberValue()); | 3676 CHECK_EQ(5.76, data->NumberValue()); |
| 3677 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); | 3677 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
| 3678 CHECK_EQ(7.56, message->GetScriptData()->NumberValue()); | 3678 CHECK_EQ(7.56, message->GetScriptData()->NumberValue()); |
| 3679 CHECK(!message->IsSharedCrossOrigin()); | 3679 CHECK(!message->IsSharedCrossOrigin()); |
| 3680 message_received = true; | 3680 message_received = true; |
| 3681 } | 3681 } |
| 3682 | 3682 |
| 3683 | 3683 |
| 3684 THREADED_TEST(MessageHandler0) { | 3684 THREADED_TEST(MessageHandler0) { |
| 3685 message_received = false; | 3685 message_received = false; |
| 3686 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3686 v8::HandleScope scope(CcTest::isolate()); |
| 3687 CHECK(!message_received); | 3687 CHECK(!message_received); |
| 3688 v8::V8::AddMessageListener(check_message_0, v8_num(5.76)); | 3688 v8::V8::AddMessageListener(check_message_0, v8_num(5.76)); |
| 3689 LocalContext context; | 3689 LocalContext context; |
| 3690 v8::ScriptOrigin origin = | 3690 v8::ScriptOrigin origin = |
| 3691 v8::ScriptOrigin(v8_str("6.75")); | 3691 v8::ScriptOrigin(v8_str("6.75")); |
| 3692 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 3692 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 3693 &origin); | 3693 &origin); |
| 3694 script->SetData(v8_str("7.56")); | 3694 script->SetData(v8_str("7.56")); |
| 3695 script->Run(); | 3695 script->Run(); |
| 3696 CHECK(message_received); | 3696 CHECK(message_received); |
| 3697 // clear out the message listener | 3697 // clear out the message listener |
| 3698 v8::V8::RemoveMessageListeners(check_message_0); | 3698 v8::V8::RemoveMessageListeners(check_message_0); |
| 3699 } | 3699 } |
| 3700 | 3700 |
| 3701 | 3701 |
| 3702 static void check_message_1(v8::Handle<v8::Message> message, | 3702 static void check_message_1(v8::Handle<v8::Message> message, |
| 3703 v8::Handle<Value> data) { | 3703 v8::Handle<Value> data) { |
| 3704 CHECK(data->IsNumber()); | 3704 CHECK(data->IsNumber()); |
| 3705 CHECK_EQ(1337, data->Int32Value()); | 3705 CHECK_EQ(1337, data->Int32Value()); |
| 3706 CHECK(!message->IsSharedCrossOrigin()); | 3706 CHECK(!message->IsSharedCrossOrigin()); |
| 3707 message_received = true; | 3707 message_received = true; |
| 3708 } | 3708 } |
| 3709 | 3709 |
| 3710 | 3710 |
| 3711 TEST(MessageHandler1) { | 3711 TEST(MessageHandler1) { |
| 3712 message_received = false; | 3712 message_received = false; |
| 3713 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3713 v8::HandleScope scope(CcTest::isolate()); |
| 3714 CHECK(!message_received); | 3714 CHECK(!message_received); |
| 3715 v8::V8::AddMessageListener(check_message_1); | 3715 v8::V8::AddMessageListener(check_message_1); |
| 3716 LocalContext context; | 3716 LocalContext context; |
| 3717 CompileRun("throw 1337;"); | 3717 CompileRun("throw 1337;"); |
| 3718 CHECK(message_received); | 3718 CHECK(message_received); |
| 3719 // clear out the message listener | 3719 // clear out the message listener |
| 3720 v8::V8::RemoveMessageListeners(check_message_1); | 3720 v8::V8::RemoveMessageListeners(check_message_1); |
| 3721 } | 3721 } |
| 3722 | 3722 |
| 3723 | 3723 |
| 3724 static void check_message_2(v8::Handle<v8::Message> message, | 3724 static void check_message_2(v8::Handle<v8::Message> message, |
| 3725 v8::Handle<Value> data) { | 3725 v8::Handle<Value> data) { |
| 3726 LocalContext context; | 3726 LocalContext context; |
| 3727 CHECK(data->IsObject()); | 3727 CHECK(data->IsObject()); |
| 3728 v8::Local<v8::Value> hidden_property = | 3728 v8::Local<v8::Value> hidden_property = |
| 3729 v8::Object::Cast(*data)->GetHiddenValue(v8_str("hidden key")); | 3729 v8::Object::Cast(*data)->GetHiddenValue(v8_str("hidden key")); |
| 3730 CHECK(v8_str("hidden value")->Equals(hidden_property)); | 3730 CHECK(v8_str("hidden value")->Equals(hidden_property)); |
| 3731 CHECK(!message->IsSharedCrossOrigin()); | 3731 CHECK(!message->IsSharedCrossOrigin()); |
| 3732 message_received = true; | 3732 message_received = true; |
| 3733 } | 3733 } |
| 3734 | 3734 |
| 3735 | 3735 |
| 3736 TEST(MessageHandler2) { | 3736 TEST(MessageHandler2) { |
| 3737 message_received = false; | 3737 message_received = false; |
| 3738 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3738 v8::HandleScope scope(CcTest::isolate()); |
| 3739 CHECK(!message_received); | 3739 CHECK(!message_received); |
| 3740 v8::V8::AddMessageListener(check_message_2); | 3740 v8::V8::AddMessageListener(check_message_2); |
| 3741 LocalContext context; | 3741 LocalContext context; |
| 3742 v8::Local<v8::Value> error = v8::Exception::Error(v8_str("custom error")); | 3742 v8::Local<v8::Value> error = v8::Exception::Error(v8_str("custom error")); |
| 3743 v8::Object::Cast(*error)->SetHiddenValue(v8_str("hidden key"), | 3743 v8::Object::Cast(*error)->SetHiddenValue(v8_str("hidden key"), |
| 3744 v8_str("hidden value")); | 3744 v8_str("hidden value")); |
| 3745 context->Global()->Set(v8_str("error"), error); | 3745 context->Global()->Set(v8_str("error"), error); |
| 3746 CompileRun("throw error;"); | 3746 CompileRun("throw error;"); |
| 3747 CHECK(message_received); | 3747 CHECK(message_received); |
| 3748 // clear out the message listener | 3748 // clear out the message listener |
| 3749 v8::V8::RemoveMessageListeners(check_message_2); | 3749 v8::V8::RemoveMessageListeners(check_message_2); |
| 3750 } | 3750 } |
| 3751 | 3751 |
| 3752 | 3752 |
| 3753 static void check_message_3(v8::Handle<v8::Message> message, | 3753 static void check_message_3(v8::Handle<v8::Message> message, |
| 3754 v8::Handle<Value> data) { | 3754 v8::Handle<Value> data) { |
| 3755 CHECK(message->IsSharedCrossOrigin()); | 3755 CHECK(message->IsSharedCrossOrigin()); |
| 3756 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); | 3756 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
| 3757 message_received = true; | 3757 message_received = true; |
| 3758 } | 3758 } |
| 3759 | 3759 |
| 3760 | 3760 |
| 3761 TEST(MessageHandler3) { | 3761 TEST(MessageHandler3) { |
| 3762 message_received = false; | 3762 message_received = false; |
| 3763 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3763 v8::HandleScope scope(CcTest::isolate()); |
| 3764 CHECK(!message_received); | 3764 CHECK(!message_received); |
| 3765 v8::V8::AddMessageListener(check_message_3); | 3765 v8::V8::AddMessageListener(check_message_3); |
| 3766 LocalContext context; | 3766 LocalContext context; |
| 3767 v8::ScriptOrigin origin = | 3767 v8::ScriptOrigin origin = |
| 3768 v8::ScriptOrigin(v8_str("6.75"), | 3768 v8::ScriptOrigin(v8_str("6.75"), |
| 3769 v8::Integer::New(1), | 3769 v8::Integer::New(1), |
| 3770 v8::Integer::New(2), | 3770 v8::Integer::New(2), |
| 3771 v8::True()); | 3771 v8::True()); |
| 3772 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 3772 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 3773 &origin); | 3773 &origin); |
| 3774 script->Run(); | 3774 script->Run(); |
| 3775 CHECK(message_received); | 3775 CHECK(message_received); |
| 3776 // clear out the message listener | 3776 // clear out the message listener |
| 3777 v8::V8::RemoveMessageListeners(check_message_3); | 3777 v8::V8::RemoveMessageListeners(check_message_3); |
| 3778 } | 3778 } |
| 3779 | 3779 |
| 3780 | 3780 |
| 3781 static void check_message_4(v8::Handle<v8::Message> message, | 3781 static void check_message_4(v8::Handle<v8::Message> message, |
| 3782 v8::Handle<Value> data) { | 3782 v8::Handle<Value> data) { |
| 3783 CHECK(!message->IsSharedCrossOrigin()); | 3783 CHECK(!message->IsSharedCrossOrigin()); |
| 3784 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); | 3784 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
| 3785 message_received = true; | 3785 message_received = true; |
| 3786 } | 3786 } |
| 3787 | 3787 |
| 3788 | 3788 |
| 3789 TEST(MessageHandler4) { | 3789 TEST(MessageHandler4) { |
| 3790 message_received = false; | 3790 message_received = false; |
| 3791 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3791 v8::HandleScope scope(CcTest::isolate()); |
| 3792 CHECK(!message_received); | 3792 CHECK(!message_received); |
| 3793 v8::V8::AddMessageListener(check_message_4); | 3793 v8::V8::AddMessageListener(check_message_4); |
| 3794 LocalContext context; | 3794 LocalContext context; |
| 3795 v8::ScriptOrigin origin = | 3795 v8::ScriptOrigin origin = |
| 3796 v8::ScriptOrigin(v8_str("6.75"), | 3796 v8::ScriptOrigin(v8_str("6.75"), |
| 3797 v8::Integer::New(1), | 3797 v8::Integer::New(1), |
| 3798 v8::Integer::New(2), | 3798 v8::Integer::New(2), |
| 3799 v8::False()); | 3799 v8::False()); |
| 3800 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 3800 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 3801 &origin); | 3801 &origin); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3817 static void check_message_5b(v8::Handle<v8::Message> message, | 3817 static void check_message_5b(v8::Handle<v8::Message> message, |
| 3818 v8::Handle<Value> data) { | 3818 v8::Handle<Value> data) { |
| 3819 CHECK(!message->IsSharedCrossOrigin()); | 3819 CHECK(!message->IsSharedCrossOrigin()); |
| 3820 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); | 3820 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue()); |
| 3821 message_received = true; | 3821 message_received = true; |
| 3822 } | 3822 } |
| 3823 | 3823 |
| 3824 | 3824 |
| 3825 TEST(MessageHandler5) { | 3825 TEST(MessageHandler5) { |
| 3826 message_received = false; | 3826 message_received = false; |
| 3827 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3827 v8::HandleScope scope(CcTest::isolate()); |
| 3828 CHECK(!message_received); | 3828 CHECK(!message_received); |
| 3829 v8::V8::AddMessageListener(check_message_5a); | 3829 v8::V8::AddMessageListener(check_message_5a); |
| 3830 LocalContext context; | 3830 LocalContext context; |
| 3831 v8::ScriptOrigin origin = | 3831 v8::ScriptOrigin origin = |
| 3832 v8::ScriptOrigin(v8_str("6.75"), | 3832 v8::ScriptOrigin(v8_str("6.75"), |
| 3833 v8::Integer::New(1), | 3833 v8::Integer::New(1), |
| 3834 v8::Integer::New(2), | 3834 v8::Integer::New(2), |
| 3835 v8::True()); | 3835 v8::True()); |
| 3836 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), | 3836 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
| 3837 &origin); | 3837 &origin); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3959 v8::HandleScope scope(args.GetIsolate()); | 3959 v8::HandleScope scope(args.GetIsolate()); |
| 3960 ApiTestFuzzer::Fuzz(); | 3960 ApiTestFuzzer::Fuzz(); |
| 3961 Local<v8::Array> result = v8::Array::New(args.Length()); | 3961 Local<v8::Array> result = v8::Array::New(args.Length()); |
| 3962 for (int i = 0; i < args.Length(); i++) | 3962 for (int i = 0; i < args.Length(); i++) |
| 3963 result->Set(i, args[i]); | 3963 result->Set(i, args[i]); |
| 3964 args.GetReturnValue().Set(scope.Close(result)); | 3964 args.GetReturnValue().Set(scope.Close(result)); |
| 3965 } | 3965 } |
| 3966 | 3966 |
| 3967 | 3967 |
| 3968 THREADED_TEST(Vector) { | 3968 THREADED_TEST(Vector) { |
| 3969 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 3969 v8::HandleScope scope(CcTest::isolate()); |
| 3970 Local<ObjectTemplate> global = ObjectTemplate::New(); | 3970 Local<ObjectTemplate> global = ObjectTemplate::New(); |
| 3971 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); | 3971 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); |
| 3972 LocalContext context(0, global); | 3972 LocalContext context(0, global); |
| 3973 | 3973 |
| 3974 const char* fun = "f()"; | 3974 const char* fun = "f()"; |
| 3975 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>(); | 3975 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>(); |
| 3976 CHECK_EQ(0, a0->Length()); | 3976 CHECK_EQ(0, a0->Length()); |
| 3977 | 3977 |
| 3978 const char* fun2 = "f(11)"; | 3978 const char* fun2 = "f(11)"; |
| 3979 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>(); | 3979 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4105 TEST(OutOfMemoryNested) { | 4105 TEST(OutOfMemoryNested) { |
| 4106 // It's not possible to read a snapshot into a heap with different dimensions. | 4106 // It's not possible to read a snapshot into a heap with different dimensions. |
| 4107 if (i::Snapshot::IsEnabled()) return; | 4107 if (i::Snapshot::IsEnabled()) return; |
| 4108 // Set heap limits. | 4108 // Set heap limits. |
| 4109 static const int K = 1024; | 4109 static const int K = 1024; |
| 4110 v8::ResourceConstraints constraints; | 4110 v8::ResourceConstraints constraints; |
| 4111 constraints.set_max_young_space_size(256 * K); | 4111 constraints.set_max_young_space_size(256 * K); |
| 4112 constraints.set_max_old_space_size(5 * K * K); | 4112 constraints.set_max_old_space_size(5 * K * K); |
| 4113 v8::SetResourceConstraints(&constraints); | 4113 v8::SetResourceConstraints(&constraints); |
| 4114 | 4114 |
| 4115 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4115 v8::HandleScope scope(CcTest::isolate()); |
| 4116 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4116 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4117 templ->Set(v8_str("ProvokeOutOfMemory"), | 4117 templ->Set(v8_str("ProvokeOutOfMemory"), |
| 4118 v8::FunctionTemplate::New(ProvokeOutOfMemory)); | 4118 v8::FunctionTemplate::New(ProvokeOutOfMemory)); |
| 4119 LocalContext context(0, templ); | 4119 LocalContext context(0, templ); |
| 4120 v8::V8::IgnoreOutOfMemoryException(); | 4120 v8::V8::IgnoreOutOfMemoryException(); |
| 4121 Local<Value> result = CompileRun( | 4121 Local<Value> result = CompileRun( |
| 4122 "var thrown = false;" | 4122 "var thrown = false;" |
| 4123 "try {" | 4123 "try {" |
| 4124 " ProvokeOutOfMemory();" | 4124 " ProvokeOutOfMemory();" |
| 4125 "} catch (e) {" | 4125 "} catch (e) {" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4384 } | 4384 } |
| 4385 v8::HandleScope scope(args.GetIsolate()); | 4385 v8::HandleScope scope(args.GetIsolate()); |
| 4386 v8::TryCatch try_catch; | 4386 v8::TryCatch try_catch; |
| 4387 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); | 4387 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); |
| 4388 CHECK(!try_catch.HasCaught() || result.IsEmpty()); | 4388 CHECK(!try_catch.HasCaught() || result.IsEmpty()); |
| 4389 args.GetReturnValue().Set(try_catch.HasCaught()); | 4389 args.GetReturnValue().Set(try_catch.HasCaught()); |
| 4390 } | 4390 } |
| 4391 | 4391 |
| 4392 | 4392 |
| 4393 THREADED_TEST(APICatch) { | 4393 THREADED_TEST(APICatch) { |
| 4394 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4394 v8::HandleScope scope(CcTest::isolate()); |
| 4395 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4395 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4396 templ->Set(v8_str("ThrowFromC"), | 4396 templ->Set(v8_str("ThrowFromC"), |
| 4397 v8::FunctionTemplate::New(ThrowFromC)); | 4397 v8::FunctionTemplate::New(ThrowFromC)); |
| 4398 LocalContext context(0, templ); | 4398 LocalContext context(0, templ); |
| 4399 CompileRun( | 4399 CompileRun( |
| 4400 "var thrown = false;" | 4400 "var thrown = false;" |
| 4401 "try {" | 4401 "try {" |
| 4402 " ThrowFromC();" | 4402 " ThrowFromC();" |
| 4403 "} catch (e) {" | 4403 "} catch (e) {" |
| 4404 " thrown = true;" | 4404 " thrown = true;" |
| 4405 "}"); | 4405 "}"); |
| 4406 Local<Value> thrown = context->Global()->Get(v8_str("thrown")); | 4406 Local<Value> thrown = context->Global()->Get(v8_str("thrown")); |
| 4407 CHECK(thrown->BooleanValue()); | 4407 CHECK(thrown->BooleanValue()); |
| 4408 } | 4408 } |
| 4409 | 4409 |
| 4410 | 4410 |
| 4411 THREADED_TEST(APIThrowTryCatch) { | 4411 THREADED_TEST(APIThrowTryCatch) { |
| 4412 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4412 v8::HandleScope scope(CcTest::isolate()); |
| 4413 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4413 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4414 templ->Set(v8_str("ThrowFromC"), | 4414 templ->Set(v8_str("ThrowFromC"), |
| 4415 v8::FunctionTemplate::New(ThrowFromC)); | 4415 v8::FunctionTemplate::New(ThrowFromC)); |
| 4416 LocalContext context(0, templ); | 4416 LocalContext context(0, templ); |
| 4417 v8::TryCatch try_catch; | 4417 v8::TryCatch try_catch; |
| 4418 CompileRun("ThrowFromC();"); | 4418 CompileRun("ThrowFromC();"); |
| 4419 CHECK(try_catch.HasCaught()); | 4419 CHECK(try_catch.HasCaught()); |
| 4420 } | 4420 } |
| 4421 | 4421 |
| 4422 | 4422 |
| 4423 // Test that a try-finally block doesn't shadow a try-catch block | 4423 // Test that a try-finally block doesn't shadow a try-catch block |
| 4424 // when setting up an external handler. | 4424 // when setting up an external handler. |
| 4425 // | 4425 // |
| 4426 // BUG(271): Some of the exception propagation does not work on the | 4426 // BUG(271): Some of the exception propagation does not work on the |
| 4427 // ARM simulator because the simulator separates the C++ stack and the | 4427 // ARM simulator because the simulator separates the C++ stack and the |
| 4428 // JS stack. This test therefore fails on the simulator. The test is | 4428 // JS stack. This test therefore fails on the simulator. The test is |
| 4429 // not threaded to allow the threading tests to run on the simulator. | 4429 // not threaded to allow the threading tests to run on the simulator. |
| 4430 TEST(TryCatchInTryFinally) { | 4430 TEST(TryCatchInTryFinally) { |
| 4431 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4431 v8::HandleScope scope(CcTest::isolate()); |
| 4432 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4432 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4433 templ->Set(v8_str("CCatcher"), | 4433 templ->Set(v8_str("CCatcher"), |
| 4434 v8::FunctionTemplate::New(CCatcher)); | 4434 v8::FunctionTemplate::New(CCatcher)); |
| 4435 LocalContext context(0, templ); | 4435 LocalContext context(0, templ); |
| 4436 Local<Value> result = CompileRun("try {" | 4436 Local<Value> result = CompileRun("try {" |
| 4437 " try {" | 4437 " try {" |
| 4438 " CCatcher('throw 7;');" | 4438 " CCatcher('throw 7;');" |
| 4439 " } finally {" | 4439 " } finally {" |
| 4440 " }" | 4440 " }" |
| 4441 "} catch (e) {" | 4441 "} catch (e) {" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4455 static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4455 static void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4456 ApiTestFuzzer::Fuzz(); | 4456 ApiTestFuzzer::Fuzz(); |
| 4457 CHECK(false); | 4457 CHECK(false); |
| 4458 } | 4458 } |
| 4459 | 4459 |
| 4460 | 4460 |
| 4461 // Test that overwritten methods are not invoked on uncaught exception | 4461 // Test that overwritten methods are not invoked on uncaught exception |
| 4462 // formatting. However, they are invoked when performing normal error | 4462 // formatting. However, they are invoked when performing normal error |
| 4463 // string conversions. | 4463 // string conversions. |
| 4464 TEST(APIThrowMessageOverwrittenToString) { | 4464 TEST(APIThrowMessageOverwrittenToString) { |
| 4465 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4465 v8::HandleScope scope(CcTest::isolate()); |
| 4466 v8::V8::AddMessageListener(check_reference_error_message); | 4466 v8::V8::AddMessageListener(check_reference_error_message); |
| 4467 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4467 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4468 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail)); | 4468 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail)); |
| 4469 LocalContext context(NULL, templ); | 4469 LocalContext context(NULL, templ); |
| 4470 CompileRun("asdf;"); | 4470 CompileRun("asdf;"); |
| 4471 CompileRun("var limit = {};" | 4471 CompileRun("var limit = {};" |
| 4472 "limit.valueOf = fail;" | 4472 "limit.valueOf = fail;" |
| 4473 "Error.stackTraceLimit = limit;"); | 4473 "Error.stackTraceLimit = limit;"); |
| 4474 CompileRun("asdf"); | 4474 CompileRun("asdf"); |
| 4475 CompileRun("Array.prototype.pop = fail;"); | 4475 CompileRun("Array.prototype.pop = fail;"); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4579 | 4579 |
| 4580 static void receive_message(v8::Handle<v8::Message> message, | 4580 static void receive_message(v8::Handle<v8::Message> message, |
| 4581 v8::Handle<v8::Value> data) { | 4581 v8::Handle<v8::Value> data) { |
| 4582 message->Get(); | 4582 message->Get(); |
| 4583 message_received = true; | 4583 message_received = true; |
| 4584 } | 4584 } |
| 4585 | 4585 |
| 4586 | 4586 |
| 4587 TEST(APIThrowMessage) { | 4587 TEST(APIThrowMessage) { |
| 4588 message_received = false; | 4588 message_received = false; |
| 4589 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4589 v8::HandleScope scope(CcTest::isolate()); |
| 4590 v8::V8::AddMessageListener(receive_message); | 4590 v8::V8::AddMessageListener(receive_message); |
| 4591 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4591 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4592 templ->Set(v8_str("ThrowFromC"), | 4592 templ->Set(v8_str("ThrowFromC"), |
| 4593 v8::FunctionTemplate::New(ThrowFromC)); | 4593 v8::FunctionTemplate::New(ThrowFromC)); |
| 4594 LocalContext context(0, templ); | 4594 LocalContext context(0, templ); |
| 4595 CompileRun("ThrowFromC();"); | 4595 CompileRun("ThrowFromC();"); |
| 4596 CHECK(message_received); | 4596 CHECK(message_received); |
| 4597 v8::V8::RemoveMessageListeners(receive_message); | 4597 v8::V8::RemoveMessageListeners(receive_message); |
| 4598 } | 4598 } |
| 4599 | 4599 |
| 4600 | 4600 |
| 4601 TEST(APIThrowMessageAndVerboseTryCatch) { | 4601 TEST(APIThrowMessageAndVerboseTryCatch) { |
| 4602 message_received = false; | 4602 message_received = false; |
| 4603 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4603 v8::HandleScope scope(CcTest::isolate()); |
| 4604 v8::V8::AddMessageListener(receive_message); | 4604 v8::V8::AddMessageListener(receive_message); |
| 4605 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4605 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4606 templ->Set(v8_str("ThrowFromC"), | 4606 templ->Set(v8_str("ThrowFromC"), |
| 4607 v8::FunctionTemplate::New(ThrowFromC)); | 4607 v8::FunctionTemplate::New(ThrowFromC)); |
| 4608 LocalContext context(0, templ); | 4608 LocalContext context(0, templ); |
| 4609 v8::TryCatch try_catch; | 4609 v8::TryCatch try_catch; |
| 4610 try_catch.SetVerbose(true); | 4610 try_catch.SetVerbose(true); |
| 4611 Local<Value> result = CompileRun("ThrowFromC();"); | 4611 Local<Value> result = CompileRun("ThrowFromC();"); |
| 4612 CHECK(try_catch.HasCaught()); | 4612 CHECK(try_catch.HasCaught()); |
| 4613 CHECK(result.IsEmpty()); | 4613 CHECK(result.IsEmpty()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4625 try_catch.SetVerbose(true); | 4625 try_catch.SetVerbose(true); |
| 4626 Local<Value> result = CompileRun("function foo() { foo(); } foo();"); | 4626 Local<Value> result = CompileRun("function foo() { foo(); } foo();"); |
| 4627 CHECK(try_catch.HasCaught()); | 4627 CHECK(try_catch.HasCaught()); |
| 4628 CHECK(result.IsEmpty()); | 4628 CHECK(result.IsEmpty()); |
| 4629 CHECK(message_received); | 4629 CHECK(message_received); |
| 4630 v8::V8::RemoveMessageListeners(receive_message); | 4630 v8::V8::RemoveMessageListeners(receive_message); |
| 4631 } | 4631 } |
| 4632 | 4632 |
| 4633 | 4633 |
| 4634 THREADED_TEST(ExternalScriptException) { | 4634 THREADED_TEST(ExternalScriptException) { |
| 4635 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4635 v8::HandleScope scope(CcTest::isolate()); |
| 4636 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4636 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4637 templ->Set(v8_str("ThrowFromC"), | 4637 templ->Set(v8_str("ThrowFromC"), |
| 4638 v8::FunctionTemplate::New(ThrowFromC)); | 4638 v8::FunctionTemplate::New(ThrowFromC)); |
| 4639 LocalContext context(0, templ); | 4639 LocalContext context(0, templ); |
| 4640 | 4640 |
| 4641 v8::TryCatch try_catch; | 4641 v8::TryCatch try_catch; |
| 4642 Local<Script> script | 4642 Local<Script> script |
| 4643 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); | 4643 = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); |
| 4644 Local<Value> result = script->Run(); | 4644 Local<Value> result = script->Run(); |
| 4645 CHECK(result.IsEmpty()); | 4645 CHECK(result.IsEmpty()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4729 // | 4729 // |
| 4730 // Each entry is an activation, either JS or C. The index is the count at that | 4730 // Each entry is an activation, either JS or C. The index is the count at that |
| 4731 // level. Stars identify activations with exception handlers, the @ identifies | 4731 // level. Stars identify activations with exception handlers, the @ identifies |
| 4732 // the exception handler that should catch the exception. | 4732 // the exception handler that should catch the exception. |
| 4733 // | 4733 // |
| 4734 // BUG(271): Some of the exception propagation does not work on the | 4734 // BUG(271): Some of the exception propagation does not work on the |
| 4735 // ARM simulator because the simulator separates the C++ stack and the | 4735 // ARM simulator because the simulator separates the C++ stack and the |
| 4736 // JS stack. This test therefore fails on the simulator. The test is | 4736 // JS stack. This test therefore fails on the simulator. The test is |
| 4737 // not threaded to allow the threading tests to run on the simulator. | 4737 // not threaded to allow the threading tests to run on the simulator. |
| 4738 TEST(ExceptionOrder) { | 4738 TEST(ExceptionOrder) { |
| 4739 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4739 v8::HandleScope scope(CcTest::isolate()); |
| 4740 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4740 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4741 templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck)); | 4741 templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck)); |
| 4742 templ->Set(v8_str("CThrowCountDown"), | 4742 templ->Set(v8_str("CThrowCountDown"), |
| 4743 v8::FunctionTemplate::New(CThrowCountDown)); | 4743 v8::FunctionTemplate::New(CThrowCountDown)); |
| 4744 LocalContext context(0, templ); | 4744 LocalContext context(0, templ); |
| 4745 CompileRun( | 4745 CompileRun( |
| 4746 "function JSThrowCountDown(count, jsInterval, cInterval, expected) {" | 4746 "function JSThrowCountDown(count, jsInterval, cInterval, expected) {" |
| 4747 " if (count == 0) throw 'FromJS';" | 4747 " if (count == 0) throw 'FromJS';" |
| 4748 " if (count % jsInterval == 0) {" | 4748 " if (count % jsInterval == 0) {" |
| 4749 " try {" | 4749 " try {" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4793 | 4793 |
| 4794 | 4794 |
| 4795 void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4795 void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4796 ApiTestFuzzer::Fuzz(); | 4796 ApiTestFuzzer::Fuzz(); |
| 4797 CHECK_EQ(1, args.Length()); | 4797 CHECK_EQ(1, args.Length()); |
| 4798 v8::ThrowException(args[0]); | 4798 v8::ThrowException(args[0]); |
| 4799 } | 4799 } |
| 4800 | 4800 |
| 4801 | 4801 |
| 4802 THREADED_TEST(ThrowValues) { | 4802 THREADED_TEST(ThrowValues) { |
| 4803 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4803 v8::HandleScope scope(CcTest::isolate()); |
| 4804 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4804 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4805 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue)); | 4805 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue)); |
| 4806 LocalContext context(0, templ); | 4806 LocalContext context(0, templ); |
| 4807 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 4807 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
| 4808 "function Run(obj) {" | 4808 "function Run(obj) {" |
| 4809 " try {" | 4809 " try {" |
| 4810 " Throw(obj);" | 4810 " Throw(obj);" |
| 4811 " } catch (e) {" | 4811 " } catch (e) {" |
| 4812 " return e;" | 4812 " return e;" |
| 4813 " }" | 4813 " }" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4931 try_catch.ReThrow(); | 4931 try_catch.ReThrow(); |
| 4932 } | 4932 } |
| 4933 | 4933 |
| 4934 | 4934 |
| 4935 // This test ensures that an outer TryCatch in the following situation: | 4935 // This test ensures that an outer TryCatch in the following situation: |
| 4936 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError | 4936 // C++/TryCatch -> JS -> C++/TryCatch -> JS w/ SyntaxError |
| 4937 // does not clobber the Message object generated for the inner TryCatch. | 4937 // does not clobber the Message object generated for the inner TryCatch. |
| 4938 // This exercises the ability of TryCatch.ReThrow() to restore the | 4938 // This exercises the ability of TryCatch.ReThrow() to restore the |
| 4939 // inner pending Message before throwing the exception again. | 4939 // inner pending Message before throwing the exception again. |
| 4940 TEST(TryCatchMixedNesting) { | 4940 TEST(TryCatchMixedNesting) { |
| 4941 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 4941 v8::HandleScope scope(CcTest::isolate()); |
| 4942 v8::V8::Initialize(); | 4942 v8::V8::Initialize(); |
| 4943 v8::TryCatch try_catch; | 4943 v8::TryCatch try_catch; |
| 4944 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 4944 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 4945 templ->Set(v8_str("TryCatchMixedNestingHelper"), | 4945 templ->Set(v8_str("TryCatchMixedNestingHelper"), |
| 4946 v8::FunctionTemplate::New(TryCatchMixedNestingHelper)); | 4946 v8::FunctionTemplate::New(TryCatchMixedNestingHelper)); |
| 4947 LocalContext context(0, templ); | 4947 LocalContext context(0, templ); |
| 4948 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); | 4948 CompileRunWithOrigin("TryCatchMixedNestingHelper();\n", "outer", 1, 1); |
| 4949 TryCatchMixedNestingCheck(&try_catch); | 4949 TryCatchMixedNestingCheck(&try_catch); |
| 4950 } | 4950 } |
| 4951 | 4951 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5057 // Make sure that it is not possible to redefine again | 5057 // Make sure that it is not possible to redefine again |
| 5058 v8::TryCatch try_catch; | 5058 v8::TryCatch try_catch; |
| 5059 result = script_define->Run(); | 5059 result = script_define->Run(); |
| 5060 CHECK(try_catch.HasCaught()); | 5060 CHECK(try_catch.HasCaught()); |
| 5061 String::Utf8Value exception_value(try_catch.Exception()); | 5061 String::Utf8Value exception_value(try_catch.Exception()); |
| 5062 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); | 5062 CHECK_EQ(*exception_value, "TypeError: Cannot redefine property: x"); |
| 5063 } | 5063 } |
| 5064 | 5064 |
| 5065 | 5065 |
| 5066 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { | 5066 THREADED_TEST(DefinePropertyOnDefineGetterSetter) { |
| 5067 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5067 v8::HandleScope scope(CcTest::isolate()); |
| 5068 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5068 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5069 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); | 5069 templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
| 5070 LocalContext context; | 5070 LocalContext context; |
| 5071 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5071 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5072 | 5072 |
| 5073 Local<Script> script_desc = Script::Compile(v8_str("var prop =" | 5073 Local<Script> script_desc = Script::Compile(v8_str("var prop =" |
| 5074 "Object.getOwnPropertyDescriptor( " | 5074 "Object.getOwnPropertyDescriptor( " |
| 5075 "obj, 'x');" | 5075 "obj, 'x');" |
| 5076 "prop.configurable;")); | 5076 "prop.configurable;")); |
| 5077 Local<Value> result = script_desc->Run(); | 5077 Local<Value> result = script_desc->Run(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5109 } | 5109 } |
| 5110 | 5110 |
| 5111 | 5111 |
| 5112 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, | 5112 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context, |
| 5113 char const* name) { | 5113 char const* name) { |
| 5114 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); | 5114 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name))); |
| 5115 } | 5115 } |
| 5116 | 5116 |
| 5117 | 5117 |
| 5118 THREADED_TEST(DefineAPIAccessorOnObject) { | 5118 THREADED_TEST(DefineAPIAccessorOnObject) { |
| 5119 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5119 v8::HandleScope scope(CcTest::isolate()); |
| 5120 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5120 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5121 LocalContext context; | 5121 LocalContext context; |
| 5122 | 5122 |
| 5123 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); | 5123 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); |
| 5124 CompileRun("var obj2 = {};"); | 5124 CompileRun("var obj2 = {};"); |
| 5125 | 5125 |
| 5126 CHECK(CompileRun("obj1.x")->IsUndefined()); | 5126 CHECK(CompileRun("obj1.x")->IsUndefined()); |
| 5127 CHECK(CompileRun("obj2.x")->IsUndefined()); | 5127 CHECK(CompileRun("obj2.x")->IsUndefined()); |
| 5128 | 5128 |
| 5129 CHECK(GetGlobalProperty(&context, "obj1")-> | 5129 CHECK(GetGlobalProperty(&context, "obj1")-> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5183 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 5183 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
| 5184 CHECK(!GetGlobalProperty(&context, "obj2")-> | 5184 CHECK(!GetGlobalProperty(&context, "obj2")-> |
| 5185 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); | 5185 SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"))); |
| 5186 | 5186 |
| 5187 ExpectString("obj1.x", "z"); | 5187 ExpectString("obj1.x", "z"); |
| 5188 ExpectString("obj2.x", "z"); | 5188 ExpectString("obj2.x", "z"); |
| 5189 } | 5189 } |
| 5190 | 5190 |
| 5191 | 5191 |
| 5192 THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) { | 5192 THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) { |
| 5193 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5193 v8::HandleScope scope(CcTest::isolate()); |
| 5194 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5194 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5195 LocalContext context; | 5195 LocalContext context; |
| 5196 | 5196 |
| 5197 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); | 5197 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); |
| 5198 CompileRun("var obj2 = {};"); | 5198 CompileRun("var obj2 = {};"); |
| 5199 | 5199 |
| 5200 CHECK(GetGlobalProperty(&context, "obj1")->SetAccessor( | 5200 CHECK(GetGlobalProperty(&context, "obj1")->SetAccessor( |
| 5201 v8_str("x"), | 5201 v8_str("x"), |
| 5202 GetXValue, NULL, | 5202 GetXValue, NULL, |
| 5203 v8_str("donut"), v8::DEFAULT, v8::DontDelete)); | 5203 v8_str("donut"), v8::DEFAULT, v8::DontDelete)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5239 static void Get239Value(Local<String> name, | 5239 static void Get239Value(Local<String> name, |
| 5240 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5240 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5241 ApiTestFuzzer::Fuzz(); | 5241 ApiTestFuzzer::Fuzz(); |
| 5242 CHECK_EQ(info.Data(), v8_str("donut")); | 5242 CHECK_EQ(info.Data(), v8_str("donut")); |
| 5243 CHECK_EQ(name, v8_str("239")); | 5243 CHECK_EQ(name, v8_str("239")); |
| 5244 info.GetReturnValue().Set(name); | 5244 info.GetReturnValue().Set(name); |
| 5245 } | 5245 } |
| 5246 | 5246 |
| 5247 | 5247 |
| 5248 THREADED_TEST(ElementAPIAccessor) { | 5248 THREADED_TEST(ElementAPIAccessor) { |
| 5249 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5249 v8::HandleScope scope(CcTest::isolate()); |
| 5250 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5250 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5251 LocalContext context; | 5251 LocalContext context; |
| 5252 | 5252 |
| 5253 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); | 5253 context->Global()->Set(v8_str("obj1"), templ->NewInstance()); |
| 5254 CompileRun("var obj2 = {};"); | 5254 CompileRun("var obj2 = {};"); |
| 5255 | 5255 |
| 5256 CHECK(GetGlobalProperty(&context, "obj1")->SetAccessor( | 5256 CHECK(GetGlobalProperty(&context, "obj1")->SetAccessor( |
| 5257 v8_str("239"), | 5257 v8_str("239"), |
| 5258 Get239Value, NULL, | 5258 Get239Value, NULL, |
| 5259 v8_str("donut"))); | 5259 v8_str("donut"))); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5277 const v8::PropertyCallbackInfo<void>& info) { | 5277 const v8::PropertyCallbackInfo<void>& info) { |
| 5278 CHECK_EQ(value, v8_num(4)); | 5278 CHECK_EQ(value, v8_num(4)); |
| 5279 CHECK_EQ(info.Data(), v8_str("donut")); | 5279 CHECK_EQ(info.Data(), v8_str("donut")); |
| 5280 CHECK_EQ(name, v8_str("x")); | 5280 CHECK_EQ(name, v8_str("x")); |
| 5281 CHECK(xValue.IsEmpty()); | 5281 CHECK(xValue.IsEmpty()); |
| 5282 xValue.Reset(info.GetIsolate(), value); | 5282 xValue.Reset(info.GetIsolate(), value); |
| 5283 } | 5283 } |
| 5284 | 5284 |
| 5285 | 5285 |
| 5286 THREADED_TEST(SimplePropertyWrite) { | 5286 THREADED_TEST(SimplePropertyWrite) { |
| 5287 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5287 v8::HandleScope scope(CcTest::isolate()); |
| 5288 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5288 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5289 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); | 5289 templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); |
| 5290 LocalContext context; | 5290 LocalContext context; |
| 5291 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5291 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5292 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); | 5292 Local<Script> script = Script::Compile(v8_str("obj.x = 4")); |
| 5293 for (int i = 0; i < 10; i++) { | 5293 for (int i = 0; i < 10; i++) { |
| 5294 CHECK(xValue.IsEmpty()); | 5294 CHECK(xValue.IsEmpty()); |
| 5295 script->Run(); | 5295 script->Run(); |
| 5296 CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue)); | 5296 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); |
| 5297 xValue.Dispose(); | 5297 xValue.Dispose(); |
| 5298 xValue.Clear(); | 5298 xValue.Clear(); |
| 5299 } | 5299 } |
| 5300 } | 5300 } |
| 5301 | 5301 |
| 5302 | 5302 |
| 5303 THREADED_TEST(SetterOnly) { | 5303 THREADED_TEST(SetterOnly) { |
| 5304 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5304 v8::HandleScope scope(CcTest::isolate()); |
| 5305 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5305 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5306 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); | 5306 templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |
| 5307 LocalContext context; | 5307 LocalContext context; |
| 5308 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5308 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5309 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); | 5309 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
| 5310 for (int i = 0; i < 10; i++) { | 5310 for (int i = 0; i < 10; i++) { |
| 5311 CHECK(xValue.IsEmpty()); | 5311 CHECK(xValue.IsEmpty()); |
| 5312 script->Run(); | 5312 script->Run(); |
| 5313 CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue)); | 5313 CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue)); |
| 5314 xValue.Dispose(); | 5314 xValue.Dispose(); |
| 5315 xValue.Clear(); | 5315 xValue.Clear(); |
| 5316 } | 5316 } |
| 5317 } | 5317 } |
| 5318 | 5318 |
| 5319 | 5319 |
| 5320 THREADED_TEST(NoAccessors) { | 5320 THREADED_TEST(NoAccessors) { |
| 5321 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5321 v8::HandleScope scope(CcTest::isolate()); |
| 5322 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5322 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5323 templ->SetAccessor(v8_str("x"), | 5323 templ->SetAccessor(v8_str("x"), |
| 5324 static_cast<v8::AccessorGetterCallback>(NULL), | 5324 static_cast<v8::AccessorGetterCallback>(NULL), |
| 5325 NULL, | 5325 NULL, |
| 5326 v8_str("donut")); | 5326 v8_str("donut")); |
| 5327 LocalContext context; | 5327 LocalContext context; |
| 5328 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5328 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5329 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); | 5329 Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
| 5330 for (int i = 0; i < 10; i++) { | 5330 for (int i = 0; i < 10; i++) { |
| 5331 script->Run(); | 5331 script->Run(); |
| 5332 } | 5332 } |
| 5333 } | 5333 } |
| 5334 | 5334 |
| 5335 | 5335 |
| 5336 static void XPropertyGetter(Local<String> property, | 5336 static void XPropertyGetter(Local<String> property, |
| 5337 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5337 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5338 ApiTestFuzzer::Fuzz(); | 5338 ApiTestFuzzer::Fuzz(); |
| 5339 CHECK(info.Data()->IsUndefined()); | 5339 CHECK(info.Data()->IsUndefined()); |
| 5340 info.GetReturnValue().Set(property); | 5340 info.GetReturnValue().Set(property); |
| 5341 } | 5341 } |
| 5342 | 5342 |
| 5343 | 5343 |
| 5344 THREADED_TEST(NamedInterceptorPropertyRead) { | 5344 THREADED_TEST(NamedInterceptorPropertyRead) { |
| 5345 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5345 v8::HandleScope scope(CcTest::isolate()); |
| 5346 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5346 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5347 templ->SetNamedPropertyHandler(XPropertyGetter); | 5347 templ->SetNamedPropertyHandler(XPropertyGetter); |
| 5348 LocalContext context; | 5348 LocalContext context; |
| 5349 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5349 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5350 Local<Script> script = Script::Compile(v8_str("obj.x")); | 5350 Local<Script> script = Script::Compile(v8_str("obj.x")); |
| 5351 for (int i = 0; i < 10; i++) { | 5351 for (int i = 0; i < 10; i++) { |
| 5352 Local<Value> result = script->Run(); | 5352 Local<Value> result = script->Run(); |
| 5353 CHECK_EQ(result, v8_str("x")); | 5353 CHECK_EQ(result, v8_str("x")); |
| 5354 } | 5354 } |
| 5355 } | 5355 } |
| 5356 | 5356 |
| 5357 | 5357 |
| 5358 THREADED_TEST(NamedInterceptorDictionaryIC) { | 5358 THREADED_TEST(NamedInterceptorDictionaryIC) { |
| 5359 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5359 v8::HandleScope scope(CcTest::isolate()); |
| 5360 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5360 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5361 templ->SetNamedPropertyHandler(XPropertyGetter); | 5361 templ->SetNamedPropertyHandler(XPropertyGetter); |
| 5362 LocalContext context; | 5362 LocalContext context; |
| 5363 // Create an object with a named interceptor. | 5363 // Create an object with a named interceptor. |
| 5364 context->Global()->Set(v8_str("interceptor_obj"), templ->NewInstance()); | 5364 context->Global()->Set(v8_str("interceptor_obj"), templ->NewInstance()); |
| 5365 Local<Script> script = Script::Compile(v8_str("interceptor_obj.x")); | 5365 Local<Script> script = Script::Compile(v8_str("interceptor_obj.x")); |
| 5366 for (int i = 0; i < 10; i++) { | 5366 for (int i = 0; i < 10; i++) { |
| 5367 Local<Value> result = script->Run(); | 5367 Local<Value> result = script->Run(); |
| 5368 CHECK_EQ(result, v8_str("x")); | 5368 CHECK_EQ(result, v8_str("x")); |
| 5369 } | 5369 } |
| 5370 // Create a slow case object and a function accessing a property in | 5370 // Create a slow case object and a function accessing a property in |
| 5371 // that slow case object (with dictionary probing in generated | 5371 // that slow case object (with dictionary probing in generated |
| 5372 // code). Then force object with a named interceptor into slow-case, | 5372 // code). Then force object with a named interceptor into slow-case, |
| 5373 // pass it to the function, and check that the interceptor is called | 5373 // pass it to the function, and check that the interceptor is called |
| 5374 // instead of accessing the local property. | 5374 // instead of accessing the local property. |
| 5375 Local<Value> result = | 5375 Local<Value> result = |
| 5376 CompileRun("function get_x(o) { return o.x; };" | 5376 CompileRun("function get_x(o) { return o.x; };" |
| 5377 "var obj = { x : 42, y : 0 };" | 5377 "var obj = { x : 42, y : 0 };" |
| 5378 "delete obj.y;" | 5378 "delete obj.y;" |
| 5379 "for (var i = 0; i < 10; i++) get_x(obj);" | 5379 "for (var i = 0; i < 10; i++) get_x(obj);" |
| 5380 "interceptor_obj.x = 42;" | 5380 "interceptor_obj.x = 42;" |
| 5381 "interceptor_obj.y = 10;" | 5381 "interceptor_obj.y = 10;" |
| 5382 "delete interceptor_obj.y;" | 5382 "delete interceptor_obj.y;" |
| 5383 "get_x(interceptor_obj)"); | 5383 "get_x(interceptor_obj)"); |
| 5384 CHECK_EQ(result, v8_str("x")); | 5384 CHECK_EQ(result, v8_str("x")); |
| 5385 } | 5385 } |
| 5386 | 5386 |
| 5387 | 5387 |
| 5388 THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) { | 5388 THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) { |
| 5389 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 5389 v8::Isolate* isolate = CcTest::isolate(); |
| 5390 v8::HandleScope scope(isolate); | 5390 v8::HandleScope scope(isolate); |
| 5391 v8::Local<Context> context1 = Context::New(isolate); | 5391 v8::Local<Context> context1 = Context::New(isolate); |
| 5392 | 5392 |
| 5393 context1->Enter(); | 5393 context1->Enter(); |
| 5394 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5394 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5395 templ->SetNamedPropertyHandler(XPropertyGetter); | 5395 templ->SetNamedPropertyHandler(XPropertyGetter); |
| 5396 // Create an object with a named interceptor. | 5396 // Create an object with a named interceptor. |
| 5397 v8::Local<v8::Object> object = templ->NewInstance(); | 5397 v8::Local<v8::Object> object = templ->NewInstance(); |
| 5398 context1->Global()->Set(v8_str("interceptor_obj"), object); | 5398 context1->Global()->Set(v8_str("interceptor_obj"), object); |
| 5399 | 5399 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5431 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5431 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5432 // Set x on the prototype object and do not handle the get request. | 5432 // Set x on the prototype object and do not handle the get request. |
| 5433 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); | 5433 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype(); |
| 5434 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); | 5434 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23)); |
| 5435 } | 5435 } |
| 5436 | 5436 |
| 5437 | 5437 |
| 5438 // This is a regression test for http://crbug.com/20104. Map | 5438 // This is a regression test for http://crbug.com/20104. Map |
| 5439 // transitions should not interfere with post interceptor lookup. | 5439 // transitions should not interfere with post interceptor lookup. |
| 5440 THREADED_TEST(NamedInterceptorMapTransitionRead) { | 5440 THREADED_TEST(NamedInterceptorMapTransitionRead) { |
| 5441 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5441 v8::HandleScope scope(CcTest::isolate()); |
| 5442 Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(); | 5442 Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(); |
| 5443 Local<v8::ObjectTemplate> instance_template | 5443 Local<v8::ObjectTemplate> instance_template |
| 5444 = function_template->InstanceTemplate(); | 5444 = function_template->InstanceTemplate(); |
| 5445 instance_template->SetNamedPropertyHandler(SetXOnPrototypeGetter); | 5445 instance_template->SetNamedPropertyHandler(SetXOnPrototypeGetter); |
| 5446 LocalContext context; | 5446 LocalContext context; |
| 5447 context->Global()->Set(v8_str("F"), function_template->GetFunction()); | 5447 context->Global()->Set(v8_str("F"), function_template->GetFunction()); |
| 5448 // Create an instance of F and introduce a map transition for x. | 5448 // Create an instance of F and introduce a map transition for x. |
| 5449 CompileRun("var o = new F(); o.x = 23;"); | 5449 CompileRun("var o = new F(); o.x = 23;"); |
| 5450 // Create an instance of F and invoke the getter. The result should be 23. | 5450 // Create an instance of F and invoke the getter. The result should be 23. |
| 5451 Local<Value> result = CompileRun("o = new F(); o.x"); | 5451 Local<Value> result = CompileRun("o = new F(); o.x"); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5468 Local<Value> value, | 5468 Local<Value> value, |
| 5469 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5469 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5470 ApiTestFuzzer::Fuzz(); | 5470 ApiTestFuzzer::Fuzz(); |
| 5471 if (index == 39) { | 5471 if (index == 39) { |
| 5472 info.GetReturnValue().Set(value); | 5472 info.GetReturnValue().Set(value); |
| 5473 } | 5473 } |
| 5474 } | 5474 } |
| 5475 | 5475 |
| 5476 | 5476 |
| 5477 THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { | 5477 THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { |
| 5478 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5478 v8::HandleScope scope(CcTest::isolate()); |
| 5479 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5479 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5480 templ->SetIndexedPropertyHandler(IndexedPropertyGetter, | 5480 templ->SetIndexedPropertyHandler(IndexedPropertyGetter, |
| 5481 IndexedPropertySetter); | 5481 IndexedPropertySetter); |
| 5482 LocalContext context; | 5482 LocalContext context; |
| 5483 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5483 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5484 Local<Script> getter_script = Script::Compile(v8_str( | 5484 Local<Script> getter_script = Script::Compile(v8_str( |
| 5485 "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];")); | 5485 "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];")); |
| 5486 Local<Script> setter_script = Script::Compile(v8_str( | 5486 Local<Script> setter_script = Script::Compile(v8_str( |
| 5487 "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" | 5487 "obj.__defineSetter__(\"17\", function(val){this.foo = val;});" |
| 5488 "obj[17] = 23;" | 5488 "obj[17] = 23;" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5533 "for(i = 0; i < 80000; i++) { keys[i] = i; };" | 5533 "for(i = 0; i < 80000; i++) { keys[i] = i; };" |
| 5534 "keys.length = 25; keys;")); | 5534 "keys.length = 25; keys;")); |
| 5535 Local<Value> result = indexed_property_names_script->Run(); | 5535 Local<Value> result = indexed_property_names_script->Run(); |
| 5536 info.GetReturnValue().Set(Local<v8::Array>::Cast(result)); | 5536 info.GetReturnValue().Set(Local<v8::Array>::Cast(result)); |
| 5537 } | 5537 } |
| 5538 | 5538 |
| 5539 | 5539 |
| 5540 // Make sure that the the interceptor code in the runtime properly handles | 5540 // Make sure that the the interceptor code in the runtime properly handles |
| 5541 // merging property name lists for double-array-backed arrays. | 5541 // merging property name lists for double-array-backed arrays. |
| 5542 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { | 5542 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { |
| 5543 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5543 v8::HandleScope scope(CcTest::isolate()); |
| 5544 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5544 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5545 templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter, | 5545 templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter, |
| 5546 UnboxedDoubleIndexedPropertySetter, | 5546 UnboxedDoubleIndexedPropertySetter, |
| 5547 0, | 5547 0, |
| 5548 0, | 5548 0, |
| 5549 UnboxedDoubleIndexedPropertyEnumerator); | 5549 UnboxedDoubleIndexedPropertyEnumerator); |
| 5550 LocalContext context; | 5550 LocalContext context; |
| 5551 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5551 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5552 // When obj is created, force it to be Stored in a FastDoubleArray. | 5552 // When obj is created, force it to be Stored in a FastDoubleArray. |
| 5553 Local<Script> create_unboxed_double_script = Script::Compile(v8_str( | 5553 Local<Script> create_unboxed_double_script = Script::Compile(v8_str( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5589 ApiTestFuzzer::Fuzz(); | 5589 ApiTestFuzzer::Fuzz(); |
| 5590 if (index < 4) { | 5590 if (index < 4) { |
| 5591 info.GetReturnValue().Set(v8_num(index)); | 5591 info.GetReturnValue().Set(v8_num(index)); |
| 5592 } | 5592 } |
| 5593 } | 5593 } |
| 5594 | 5594 |
| 5595 | 5595 |
| 5596 // Make sure that the the interceptor code in the runtime properly handles | 5596 // Make sure that the the interceptor code in the runtime properly handles |
| 5597 // merging property name lists for non-string arguments arrays. | 5597 // merging property name lists for non-string arguments arrays. |
| 5598 THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) { | 5598 THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) { |
| 5599 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5599 v8::HandleScope scope(CcTest::isolate()); |
| 5600 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5600 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5601 templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter, | 5601 templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter, |
| 5602 0, | 5602 0, |
| 5603 0, | 5603 0, |
| 5604 0, | 5604 0, |
| 5605 NonStrictArgsIndexedPropertyEnumerator); | 5605 NonStrictArgsIndexedPropertyEnumerator); |
| 5606 LocalContext context; | 5606 LocalContext context; |
| 5607 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5607 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5608 Local<Script> create_args_script = | 5608 Local<Script> create_args_script = |
| 5609 Script::Compile(v8_str( | 5609 Script::Compile(v8_str( |
| 5610 "var key_count = 0;" | 5610 "var key_count = 0;" |
| 5611 "for (x in obj) {key_count++;} key_count;")); | 5611 "for (x in obj) {key_count++;} key_count;")); |
| 5612 Local<Value> result = create_args_script->Run(); | 5612 Local<Value> result = create_args_script->Run(); |
| 5613 CHECK_EQ(v8_num(4), result); | 5613 CHECK_EQ(v8_num(4), result); |
| 5614 } | 5614 } |
| 5615 | 5615 |
| 5616 | 5616 |
| 5617 static void IdentityIndexedPropertyGetter( | 5617 static void IdentityIndexedPropertyGetter( |
| 5618 uint32_t index, | 5618 uint32_t index, |
| 5619 const v8::PropertyCallbackInfo<v8::Value>& info) { | 5619 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 5620 info.GetReturnValue().Set(index); | 5620 info.GetReturnValue().Set(index); |
| 5621 } | 5621 } |
| 5622 | 5622 |
| 5623 | 5623 |
| 5624 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { | 5624 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { |
| 5625 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5625 v8::HandleScope scope(CcTest::isolate()); |
| 5626 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5626 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5627 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5627 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5628 | 5628 |
| 5629 LocalContext context; | 5629 LocalContext context; |
| 5630 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5630 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5631 | 5631 |
| 5632 // Check fast object case. | 5632 // Check fast object case. |
| 5633 const char* fast_case_code = | 5633 const char* fast_case_code = |
| 5634 "Object.getOwnPropertyDescriptor(obj, 0).value.toString()"; | 5634 "Object.getOwnPropertyDescriptor(obj, 0).value.toString()"; |
| 5635 ExpectString(fast_case_code, "0"); | 5635 ExpectString(fast_case_code, "0"); |
| 5636 | 5636 |
| 5637 // Check slow case. | 5637 // Check slow case. |
| 5638 const char* slow_case_code = | 5638 const char* slow_case_code = |
| 5639 "obj.x = 1; delete obj.x;" | 5639 "obj.x = 1; delete obj.x;" |
| 5640 "Object.getOwnPropertyDescriptor(obj, 1).value.toString()"; | 5640 "Object.getOwnPropertyDescriptor(obj, 1).value.toString()"; |
| 5641 ExpectString(slow_case_code, "1"); | 5641 ExpectString(slow_case_code, "1"); |
| 5642 } | 5642 } |
| 5643 | 5643 |
| 5644 | 5644 |
| 5645 THREADED_TEST(IndexedInterceptorWithNoSetter) { | 5645 THREADED_TEST(IndexedInterceptorWithNoSetter) { |
| 5646 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5646 v8::HandleScope scope(CcTest::isolate()); |
| 5647 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5647 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5648 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5648 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5649 | 5649 |
| 5650 LocalContext context; | 5650 LocalContext context; |
| 5651 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 5651 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 5652 | 5652 |
| 5653 const char* code = | 5653 const char* code = |
| 5654 "try {" | 5654 "try {" |
| 5655 " obj[0] = 239;" | 5655 " obj[0] = 239;" |
| 5656 " for (var i = 0; i < 100; i++) {" | 5656 " for (var i = 0; i < 100; i++) {" |
| 5657 " var v = obj[0];" | 5657 " var v = obj[0];" |
| 5658 " if (v != 0) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5658 " if (v != 0) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5659 " }" | 5659 " }" |
| 5660 " 'PASSED'" | 5660 " 'PASSED'" |
| 5661 "} catch(e) {" | 5661 "} catch(e) {" |
| 5662 " e" | 5662 " e" |
| 5663 "}"; | 5663 "}"; |
| 5664 ExpectString(code, "PASSED"); | 5664 ExpectString(code, "PASSED"); |
| 5665 } | 5665 } |
| 5666 | 5666 |
| 5667 | 5667 |
| 5668 THREADED_TEST(IndexedInterceptorWithAccessorCheck) { | 5668 THREADED_TEST(IndexedInterceptorWithAccessorCheck) { |
| 5669 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5669 v8::HandleScope scope(CcTest::isolate()); |
| 5670 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5670 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5671 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5671 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5672 | 5672 |
| 5673 LocalContext context; | 5673 LocalContext context; |
| 5674 Local<v8::Object> obj = templ->NewInstance(); | 5674 Local<v8::Object> obj = templ->NewInstance(); |
| 5675 obj->TurnOnAccessCheck(); | 5675 obj->TurnOnAccessCheck(); |
| 5676 context->Global()->Set(v8_str("obj"), obj); | 5676 context->Global()->Set(v8_str("obj"), obj); |
| 5677 | 5677 |
| 5678 const char* code = | 5678 const char* code = |
| 5679 "try {" | 5679 "try {" |
| 5680 " for (var i = 0; i < 100; i++) {" | 5680 " for (var i = 0; i < 100; i++) {" |
| 5681 " var v = obj[0];" | 5681 " var v = obj[0];" |
| 5682 " if (v != undefined) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5682 " if (v != undefined) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5683 " }" | 5683 " }" |
| 5684 " 'PASSED'" | 5684 " 'PASSED'" |
| 5685 "} catch(e) {" | 5685 "} catch(e) {" |
| 5686 " e" | 5686 " e" |
| 5687 "}"; | 5687 "}"; |
| 5688 ExpectString(code, "PASSED"); | 5688 ExpectString(code, "PASSED"); |
| 5689 } | 5689 } |
| 5690 | 5690 |
| 5691 | 5691 |
| 5692 THREADED_TEST(IndexedInterceptorWithAccessorCheckSwitchedOn) { | 5692 THREADED_TEST(IndexedInterceptorWithAccessorCheckSwitchedOn) { |
| 5693 i::FLAG_allow_natives_syntax = true; | 5693 i::FLAG_allow_natives_syntax = true; |
| 5694 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5694 v8::HandleScope scope(CcTest::isolate()); |
| 5695 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5695 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5696 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5696 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5697 | 5697 |
| 5698 LocalContext context; | 5698 LocalContext context; |
| 5699 Local<v8::Object> obj = templ->NewInstance(); | 5699 Local<v8::Object> obj = templ->NewInstance(); |
| 5700 context->Global()->Set(v8_str("obj"), obj); | 5700 context->Global()->Set(v8_str("obj"), obj); |
| 5701 | 5701 |
| 5702 const char* code = | 5702 const char* code = |
| 5703 "try {" | 5703 "try {" |
| 5704 " for (var i = 0; i < 100; i++) {" | 5704 " for (var i = 0; i < 100; i++) {" |
| 5705 " var expected = i;" | 5705 " var expected = i;" |
| 5706 " if (i == 5) {" | 5706 " if (i == 5) {" |
| 5707 " %EnableAccessChecks(obj);" | 5707 " %EnableAccessChecks(obj);" |
| 5708 " expected = undefined;" | 5708 " expected = undefined;" |
| 5709 " }" | 5709 " }" |
| 5710 " var v = obj[i];" | 5710 " var v = obj[i];" |
| 5711 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5711 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5712 " if (i == 5) %DisableAccessChecks(obj);" | 5712 " if (i == 5) %DisableAccessChecks(obj);" |
| 5713 " }" | 5713 " }" |
| 5714 " 'PASSED'" | 5714 " 'PASSED'" |
| 5715 "} catch(e) {" | 5715 "} catch(e) {" |
| 5716 " e" | 5716 " e" |
| 5717 "}"; | 5717 "}"; |
| 5718 ExpectString(code, "PASSED"); | 5718 ExpectString(code, "PASSED"); |
| 5719 } | 5719 } |
| 5720 | 5720 |
| 5721 | 5721 |
| 5722 THREADED_TEST(IndexedInterceptorWithDifferentIndices) { | 5722 THREADED_TEST(IndexedInterceptorWithDifferentIndices) { |
| 5723 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5723 v8::HandleScope scope(CcTest::isolate()); |
| 5724 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5724 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5725 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5725 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5726 | 5726 |
| 5727 LocalContext context; | 5727 LocalContext context; |
| 5728 Local<v8::Object> obj = templ->NewInstance(); | 5728 Local<v8::Object> obj = templ->NewInstance(); |
| 5729 context->Global()->Set(v8_str("obj"), obj); | 5729 context->Global()->Set(v8_str("obj"), obj); |
| 5730 | 5730 |
| 5731 const char* code = | 5731 const char* code = |
| 5732 "try {" | 5732 "try {" |
| 5733 " for (var i = 0; i < 100; i++) {" | 5733 " for (var i = 0; i < 100; i++) {" |
| 5734 " var v = obj[i];" | 5734 " var v = obj[i];" |
| 5735 " if (v != i) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5735 " if (v != i) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5736 " }" | 5736 " }" |
| 5737 " 'PASSED'" | 5737 " 'PASSED'" |
| 5738 "} catch(e) {" | 5738 "} catch(e) {" |
| 5739 " e" | 5739 " e" |
| 5740 "}"; | 5740 "}"; |
| 5741 ExpectString(code, "PASSED"); | 5741 ExpectString(code, "PASSED"); |
| 5742 } | 5742 } |
| 5743 | 5743 |
| 5744 | 5744 |
| 5745 THREADED_TEST(IndexedInterceptorWithNegativeIndices) { | 5745 THREADED_TEST(IndexedInterceptorWithNegativeIndices) { |
| 5746 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5746 v8::HandleScope scope(CcTest::isolate()); |
| 5747 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5747 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5748 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5748 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5749 | 5749 |
| 5750 LocalContext context; | 5750 LocalContext context; |
| 5751 Local<v8::Object> obj = templ->NewInstance(); | 5751 Local<v8::Object> obj = templ->NewInstance(); |
| 5752 context->Global()->Set(v8_str("obj"), obj); | 5752 context->Global()->Set(v8_str("obj"), obj); |
| 5753 | 5753 |
| 5754 const char* code = | 5754 const char* code = |
| 5755 "try {" | 5755 "try {" |
| 5756 " for (var i = 0; i < 100; i++) {" | 5756 " for (var i = 0; i < 100; i++) {" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5775 " }" | 5775 " }" |
| 5776 " 'PASSED'" | 5776 " 'PASSED'" |
| 5777 "} catch(e) {" | 5777 "} catch(e) {" |
| 5778 " e" | 5778 " e" |
| 5779 "}"; | 5779 "}"; |
| 5780 ExpectString(code, "PASSED"); | 5780 ExpectString(code, "PASSED"); |
| 5781 } | 5781 } |
| 5782 | 5782 |
| 5783 | 5783 |
| 5784 THREADED_TEST(IndexedInterceptorWithNotSmiLookup) { | 5784 THREADED_TEST(IndexedInterceptorWithNotSmiLookup) { |
| 5785 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5785 v8::HandleScope scope(CcTest::isolate()); |
| 5786 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5786 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5787 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5787 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5788 | 5788 |
| 5789 LocalContext context; | 5789 LocalContext context; |
| 5790 Local<v8::Object> obj = templ->NewInstance(); | 5790 Local<v8::Object> obj = templ->NewInstance(); |
| 5791 context->Global()->Set(v8_str("obj"), obj); | 5791 context->Global()->Set(v8_str("obj"), obj); |
| 5792 | 5792 |
| 5793 const char* code = | 5793 const char* code = |
| 5794 "try {" | 5794 "try {" |
| 5795 " for (var i = 0; i < 100; i++) {" | 5795 " for (var i = 0; i < 100; i++) {" |
| 5796 " var expected = i;" | 5796 " var expected = i;" |
| 5797 " var key = i;" | 5797 " var key = i;" |
| 5798 " if (i == 50) {" | 5798 " if (i == 50) {" |
| 5799 " key = 'foobar';" | 5799 " key = 'foobar';" |
| 5800 " expected = undefined;" | 5800 " expected = undefined;" |
| 5801 " }" | 5801 " }" |
| 5802 " var v = obj[key];" | 5802 " var v = obj[key];" |
| 5803 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5803 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5804 " }" | 5804 " }" |
| 5805 " 'PASSED'" | 5805 " 'PASSED'" |
| 5806 "} catch(e) {" | 5806 "} catch(e) {" |
| 5807 " e" | 5807 " e" |
| 5808 "}"; | 5808 "}"; |
| 5809 ExpectString(code, "PASSED"); | 5809 ExpectString(code, "PASSED"); |
| 5810 } | 5810 } |
| 5811 | 5811 |
| 5812 | 5812 |
| 5813 THREADED_TEST(IndexedInterceptorGoingMegamorphic) { | 5813 THREADED_TEST(IndexedInterceptorGoingMegamorphic) { |
| 5814 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5814 v8::HandleScope scope(CcTest::isolate()); |
| 5815 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5815 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5816 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5816 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5817 | 5817 |
| 5818 LocalContext context; | 5818 LocalContext context; |
| 5819 Local<v8::Object> obj = templ->NewInstance(); | 5819 Local<v8::Object> obj = templ->NewInstance(); |
| 5820 context->Global()->Set(v8_str("obj"), obj); | 5820 context->Global()->Set(v8_str("obj"), obj); |
| 5821 | 5821 |
| 5822 const char* code = | 5822 const char* code = |
| 5823 "var original = obj;" | 5823 "var original = obj;" |
| 5824 "try {" | 5824 "try {" |
| 5825 " for (var i = 0; i < 100; i++) {" | 5825 " for (var i = 0; i < 100; i++) {" |
| 5826 " var expected = i;" | 5826 " var expected = i;" |
| 5827 " if (i == 50) {" | 5827 " if (i == 50) {" |
| 5828 " obj = {50: 'foobar'};" | 5828 " obj = {50: 'foobar'};" |
| 5829 " expected = 'foobar';" | 5829 " expected = 'foobar';" |
| 5830 " }" | 5830 " }" |
| 5831 " var v = obj[i];" | 5831 " var v = obj[i];" |
| 5832 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5832 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5833 " if (i == 50) obj = original;" | 5833 " if (i == 50) obj = original;" |
| 5834 " }" | 5834 " }" |
| 5835 " 'PASSED'" | 5835 " 'PASSED'" |
| 5836 "} catch(e) {" | 5836 "} catch(e) {" |
| 5837 " e" | 5837 " e" |
| 5838 "}"; | 5838 "}"; |
| 5839 ExpectString(code, "PASSED"); | 5839 ExpectString(code, "PASSED"); |
| 5840 } | 5840 } |
| 5841 | 5841 |
| 5842 | 5842 |
| 5843 THREADED_TEST(IndexedInterceptorReceiverTurningSmi) { | 5843 THREADED_TEST(IndexedInterceptorReceiverTurningSmi) { |
| 5844 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5844 v8::HandleScope scope(CcTest::isolate()); |
| 5845 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5845 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5846 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5846 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5847 | 5847 |
| 5848 LocalContext context; | 5848 LocalContext context; |
| 5849 Local<v8::Object> obj = templ->NewInstance(); | 5849 Local<v8::Object> obj = templ->NewInstance(); |
| 5850 context->Global()->Set(v8_str("obj"), obj); | 5850 context->Global()->Set(v8_str("obj"), obj); |
| 5851 | 5851 |
| 5852 const char* code = | 5852 const char* code = |
| 5853 "var original = obj;" | 5853 "var original = obj;" |
| 5854 "try {" | 5854 "try {" |
| 5855 " for (var i = 0; i < 100; i++) {" | 5855 " for (var i = 0; i < 100; i++) {" |
| 5856 " var expected = i;" | 5856 " var expected = i;" |
| 5857 " if (i == 5) {" | 5857 " if (i == 5) {" |
| 5858 " obj = 239;" | 5858 " obj = 239;" |
| 5859 " expected = undefined;" | 5859 " expected = undefined;" |
| 5860 " }" | 5860 " }" |
| 5861 " var v = obj[i];" | 5861 " var v = obj[i];" |
| 5862 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5862 " if (v != expected) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5863 " if (i == 5) obj = original;" | 5863 " if (i == 5) obj = original;" |
| 5864 " }" | 5864 " }" |
| 5865 " 'PASSED'" | 5865 " 'PASSED'" |
| 5866 "} catch(e) {" | 5866 "} catch(e) {" |
| 5867 " e" | 5867 " e" |
| 5868 "}"; | 5868 "}"; |
| 5869 ExpectString(code, "PASSED"); | 5869 ExpectString(code, "PASSED"); |
| 5870 } | 5870 } |
| 5871 | 5871 |
| 5872 | 5872 |
| 5873 THREADED_TEST(IndexedInterceptorOnProto) { | 5873 THREADED_TEST(IndexedInterceptorOnProto) { |
| 5874 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5874 v8::HandleScope scope(CcTest::isolate()); |
| 5875 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 5875 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5876 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 5876 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 5877 | 5877 |
| 5878 LocalContext context; | 5878 LocalContext context; |
| 5879 Local<v8::Object> obj = templ->NewInstance(); | 5879 Local<v8::Object> obj = templ->NewInstance(); |
| 5880 context->Global()->Set(v8_str("obj"), obj); | 5880 context->Global()->Set(v8_str("obj"), obj); |
| 5881 | 5881 |
| 5882 const char* code = | 5882 const char* code = |
| 5883 "var o = {__proto__: obj};" | 5883 "var o = {__proto__: obj};" |
| 5884 "try {" | 5884 "try {" |
| 5885 " for (var i = 0; i < 100; i++) {" | 5885 " for (var i = 0; i < 100; i++) {" |
| 5886 " var v = o[i];" | 5886 " var v = o[i];" |
| 5887 " if (v != i) throw 'Wrong value ' + v + ' at iteration ' + i;" | 5887 " if (v != i) throw 'Wrong value ' + v + ' at iteration ' + i;" |
| 5888 " }" | 5888 " }" |
| 5889 " 'PASSED'" | 5889 " 'PASSED'" |
| 5890 "} catch(e) {" | 5890 "} catch(e) {" |
| 5891 " e" | 5891 " e" |
| 5892 "}"; | 5892 "}"; |
| 5893 ExpectString(code, "PASSED"); | 5893 ExpectString(code, "PASSED"); |
| 5894 } | 5894 } |
| 5895 | 5895 |
| 5896 | 5896 |
| 5897 THREADED_TEST(MultiContexts) { | 5897 THREADED_TEST(MultiContexts) { |
| 5898 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5898 v8::HandleScope scope(CcTest::isolate()); |
| 5899 v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(); | 5899 v8::Handle<ObjectTemplate> templ = ObjectTemplate::New(); |
| 5900 templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(DummyCallHandler)); | 5900 templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(DummyCallHandler)); |
| 5901 | 5901 |
| 5902 Local<String> password = v8_str("Password"); | 5902 Local<String> password = v8_str("Password"); |
| 5903 | 5903 |
| 5904 // Create an environment | 5904 // Create an environment |
| 5905 LocalContext context0(0, templ); | 5905 LocalContext context0(0, templ); |
| 5906 context0->SetSecurityToken(password); | 5906 context0->SetSecurityToken(password); |
| 5907 v8::Handle<v8::Object> global0 = context0->Global(); | 5907 v8::Handle<v8::Object> global0 = context0->Global(); |
| 5908 global0->Set(v8_str("custom"), v8_num(1234)); | 5908 global0->Set(v8_str("custom"), v8_num(1234)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5924 CHECK_EQ(global1, global2); | 5924 CHECK_EQ(global1, global2); |
| 5925 CHECK_EQ(0, global1->Get(v8_str("custom"))->Int32Value()); | 5925 CHECK_EQ(0, global1->Get(v8_str("custom"))->Int32Value()); |
| 5926 CHECK_EQ(0, global2->Get(v8_str("custom"))->Int32Value()); | 5926 CHECK_EQ(0, global2->Get(v8_str("custom"))->Int32Value()); |
| 5927 } | 5927 } |
| 5928 | 5928 |
| 5929 | 5929 |
| 5930 THREADED_TEST(FunctionPrototypeAcrossContexts) { | 5930 THREADED_TEST(FunctionPrototypeAcrossContexts) { |
| 5931 // Make sure that functions created by cloning boilerplates cannot | 5931 // Make sure that functions created by cloning boilerplates cannot |
| 5932 // communicate through their __proto__ field. | 5932 // communicate through their __proto__ field. |
| 5933 | 5933 |
| 5934 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5934 v8::HandleScope scope(CcTest::isolate()); |
| 5935 | 5935 |
| 5936 LocalContext env0; | 5936 LocalContext env0; |
| 5937 v8::Handle<v8::Object> global0 = | 5937 v8::Handle<v8::Object> global0 = |
| 5938 env0->Global(); | 5938 env0->Global(); |
| 5939 v8::Handle<v8::Object> object0 = | 5939 v8::Handle<v8::Object> object0 = |
| 5940 global0->Get(v8_str("Object")).As<v8::Object>(); | 5940 global0->Get(v8_str("Object")).As<v8::Object>(); |
| 5941 v8::Handle<v8::Object> tostring0 = | 5941 v8::Handle<v8::Object> tostring0 = |
| 5942 object0->Get(v8_str("toString")).As<v8::Object>(); | 5942 object0->Get(v8_str("toString")).As<v8::Object>(); |
| 5943 v8::Handle<v8::Object> proto0 = | 5943 v8::Handle<v8::Object> proto0 = |
| 5944 tostring0->Get(v8_str("__proto__")).As<v8::Object>(); | 5944 tostring0->Get(v8_str("__proto__")).As<v8::Object>(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5957 } | 5957 } |
| 5958 | 5958 |
| 5959 | 5959 |
| 5960 THREADED_TEST(Regress892105) { | 5960 THREADED_TEST(Regress892105) { |
| 5961 // Make sure that object and array literals created by cloning | 5961 // Make sure that object and array literals created by cloning |
| 5962 // boilerplates cannot communicate through their __proto__ | 5962 // boilerplates cannot communicate through their __proto__ |
| 5963 // field. This is rather difficult to check, but we try to add stuff | 5963 // field. This is rather difficult to check, but we try to add stuff |
| 5964 // to Object.prototype and Array.prototype and create a new | 5964 // to Object.prototype and Array.prototype and create a new |
| 5965 // environment. This should succeed. | 5965 // environment. This should succeed. |
| 5966 | 5966 |
| 5967 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 5967 v8::HandleScope scope(CcTest::isolate()); |
| 5968 | 5968 |
| 5969 Local<String> source = v8_str("Object.prototype.obj = 1234;" | 5969 Local<String> source = v8_str("Object.prototype.obj = 1234;" |
| 5970 "Array.prototype.arr = 4567;" | 5970 "Array.prototype.arr = 4567;" |
| 5971 "8901"); | 5971 "8901"); |
| 5972 | 5972 |
| 5973 LocalContext env0; | 5973 LocalContext env0; |
| 5974 Local<Script> script0 = Script::Compile(source); | 5974 Local<Script> script0 = Script::Compile(source); |
| 5975 CHECK_EQ(8901.0, script0->Run()->NumberValue()); | 5975 CHECK_EQ(8901.0, script0->Run()->NumberValue()); |
| 5976 | 5976 |
| 5977 LocalContext env1; | 5977 LocalContext env1; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6188 } | 6188 } |
| 6189 | 6189 |
| 6190 | 6190 |
| 6191 static void HandleLogDelegator( | 6191 static void HandleLogDelegator( |
| 6192 const v8::FunctionCallbackInfo<v8::Value>& args) { | 6192 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6193 ApiTestFuzzer::Fuzz(); | 6193 ApiTestFuzzer::Fuzz(); |
| 6194 } | 6194 } |
| 6195 | 6195 |
| 6196 | 6196 |
| 6197 THREADED_TEST(GlobalObjectTemplate) { | 6197 THREADED_TEST(GlobalObjectTemplate) { |
| 6198 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 6198 v8::Isolate* isolate = CcTest::isolate(); |
| 6199 v8::HandleScope handle_scope(isolate); | 6199 v8::HandleScope handle_scope(isolate); |
| 6200 Local<ObjectTemplate> global_template = ObjectTemplate::New(); | 6200 Local<ObjectTemplate> global_template = ObjectTemplate::New(); |
| 6201 global_template->Set(v8_str("JSNI_Log"), | 6201 global_template->Set(v8_str("JSNI_Log"), |
| 6202 v8::FunctionTemplate::New(HandleLogDelegator)); | 6202 v8::FunctionTemplate::New(HandleLogDelegator)); |
| 6203 v8::Local<Context> context = Context::New(isolate, 0, global_template); | 6203 v8::Local<Context> context = Context::New(isolate, 0, global_template); |
| 6204 Context::Scope context_scope(context); | 6204 Context::Scope context_scope(context); |
| 6205 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); | 6205 Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); |
| 6206 } | 6206 } |
| 6207 | 6207 |
| 6208 | 6208 |
| 6209 static const char* kSimpleExtensionSource = | 6209 static const char* kSimpleExtensionSource = |
| 6210 "function Foo() {" | 6210 "function Foo() {" |
| 6211 " return 4;" | 6211 " return 4;" |
| 6212 "}"; | 6212 "}"; |
| 6213 | 6213 |
| 6214 | 6214 |
| 6215 THREADED_TEST(SimpleExtensions) { | 6215 THREADED_TEST(SimpleExtensions) { |
| 6216 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6216 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6217 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); | 6217 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource)); |
| 6218 const char* extension_names[] = { "simpletest" }; | 6218 const char* extension_names[] = { "simpletest" }; |
| 6219 v8::ExtensionConfiguration extensions(1, extension_names); | 6219 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6220 v8::Handle<Context> context = | 6220 v8::Handle<Context> context = |
| 6221 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6221 Context::New(CcTest::isolate(), &extensions); |
| 6222 Context::Scope lock(context); | 6222 Context::Scope lock(context); |
| 6223 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6223 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 6224 CHECK_EQ(result, v8::Integer::New(4)); | 6224 CHECK_EQ(result, v8::Integer::New(4)); |
| 6225 } | 6225 } |
| 6226 | 6226 |
| 6227 | 6227 |
| 6228 THREADED_TEST(NullExtensions) { | 6228 THREADED_TEST(NullExtensions) { |
| 6229 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6229 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6230 v8::RegisterExtension(new Extension("nulltest", NULL)); | 6230 v8::RegisterExtension(new Extension("nulltest", NULL)); |
| 6231 const char* extension_names[] = { "nulltest" }; | 6231 const char* extension_names[] = { "nulltest" }; |
| 6232 v8::ExtensionConfiguration extensions(1, extension_names); | 6232 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6233 v8::Handle<Context> context = | 6233 v8::Handle<Context> context = |
| 6234 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6234 Context::New(CcTest::isolate(), &extensions); |
| 6235 Context::Scope lock(context); | 6235 Context::Scope lock(context); |
| 6236 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); | 6236 v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); |
| 6237 CHECK_EQ(result, v8::Integer::New(4)); | 6237 CHECK_EQ(result, v8::Integer::New(4)); |
| 6238 } | 6238 } |
| 6239 | 6239 |
| 6240 | 6240 |
| 6241 static const char* kEmbeddedExtensionSource = | 6241 static const char* kEmbeddedExtensionSource = |
| 6242 "function Ret54321(){return 54321;}~~@@$" | 6242 "function Ret54321(){return 54321;}~~@@$" |
| 6243 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; | 6243 "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; |
| 6244 static const int kEmbeddedExtensionSourceValidLen = 34; | 6244 static const int kEmbeddedExtensionSourceValidLen = 34; |
| 6245 | 6245 |
| 6246 | 6246 |
| 6247 THREADED_TEST(ExtensionMissingSourceLength) { | 6247 THREADED_TEST(ExtensionMissingSourceLength) { |
| 6248 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6248 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6249 v8::RegisterExtension(new Extension("srclentest_fail", | 6249 v8::RegisterExtension(new Extension("srclentest_fail", |
| 6250 kEmbeddedExtensionSource)); | 6250 kEmbeddedExtensionSource)); |
| 6251 const char* extension_names[] = { "srclentest_fail" }; | 6251 const char* extension_names[] = { "srclentest_fail" }; |
| 6252 v8::ExtensionConfiguration extensions(1, extension_names); | 6252 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6253 v8::Handle<Context> context = | 6253 v8::Handle<Context> context = |
| 6254 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6254 Context::New(CcTest::isolate(), &extensions); |
| 6255 CHECK_EQ(0, *context); | 6255 CHECK_EQ(0, *context); |
| 6256 } | 6256 } |
| 6257 | 6257 |
| 6258 | 6258 |
| 6259 THREADED_TEST(ExtensionWithSourceLength) { | 6259 THREADED_TEST(ExtensionWithSourceLength) { |
| 6260 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; | 6260 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; |
| 6261 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { | 6261 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { |
| 6262 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6262 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6263 i::ScopedVector<char> extension_name(32); | 6263 i::ScopedVector<char> extension_name(32); |
| 6264 i::OS::SNPrintF(extension_name, "ext #%d", source_len); | 6264 i::OS::SNPrintF(extension_name, "ext #%d", source_len); |
| 6265 v8::RegisterExtension(new Extension(extension_name.start(), | 6265 v8::RegisterExtension(new Extension(extension_name.start(), |
| 6266 kEmbeddedExtensionSource, 0, 0, | 6266 kEmbeddedExtensionSource, 0, 0, |
| 6267 source_len)); | 6267 source_len)); |
| 6268 const char* extension_names[1] = { extension_name.start() }; | 6268 const char* extension_names[1] = { extension_name.start() }; |
| 6269 v8::ExtensionConfiguration extensions(1, extension_names); | 6269 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6270 v8::Handle<Context> context = | 6270 v8::Handle<Context> context = |
| 6271 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6271 Context::New(CcTest::isolate(), &extensions); |
| 6272 if (source_len == kEmbeddedExtensionSourceValidLen) { | 6272 if (source_len == kEmbeddedExtensionSourceValidLen) { |
| 6273 Context::Scope lock(context); | 6273 Context::Scope lock(context); |
| 6274 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); | 6274 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); |
| 6275 CHECK_EQ(v8::Integer::New(54321), result); | 6275 CHECK_EQ(v8::Integer::New(54321), result); |
| 6276 } else { | 6276 } else { |
| 6277 // Anything but exactly the right length should fail to compile. | 6277 // Anything but exactly the right length should fail to compile. |
| 6278 CHECK_EQ(0, *context); | 6278 CHECK_EQ(0, *context); |
| 6279 } | 6279 } |
| 6280 } | 6280 } |
| 6281 } | 6281 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6292 "(function() {" | 6292 "(function() {" |
| 6293 " var x = 42;" | 6293 " var x = 42;" |
| 6294 " function e() {" | 6294 " function e() {" |
| 6295 " return eval('x');" | 6295 " return eval('x');" |
| 6296 " }" | 6296 " }" |
| 6297 " this.UseEval2 = e;" | 6297 " this.UseEval2 = e;" |
| 6298 "})()"; | 6298 "})()"; |
| 6299 | 6299 |
| 6300 | 6300 |
| 6301 THREADED_TEST(UseEvalFromExtension) { | 6301 THREADED_TEST(UseEvalFromExtension) { |
| 6302 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6302 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6303 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); | 6303 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1)); |
| 6304 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); | 6304 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2)); |
| 6305 const char* extension_names[] = { "evaltest1", "evaltest2" }; | 6305 const char* extension_names[] = { "evaltest1", "evaltest2" }; |
| 6306 v8::ExtensionConfiguration extensions(2, extension_names); | 6306 v8::ExtensionConfiguration extensions(2, extension_names); |
| 6307 v8::Handle<Context> context = | 6307 v8::Handle<Context> context = |
| 6308 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6308 Context::New(CcTest::isolate(), &extensions); |
| 6309 Context::Scope lock(context); | 6309 Context::Scope lock(context); |
| 6310 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); | 6310 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); |
| 6311 CHECK_EQ(result, v8::Integer::New(42)); | 6311 CHECK_EQ(result, v8::Integer::New(42)); |
| 6312 result = Script::Compile(v8_str("UseEval2()"))->Run(); | 6312 result = Script::Compile(v8_str("UseEval2()"))->Run(); |
| 6313 CHECK_EQ(result, v8::Integer::New(42)); | 6313 CHECK_EQ(result, v8::Integer::New(42)); |
| 6314 } | 6314 } |
| 6315 | 6315 |
| 6316 | 6316 |
| 6317 static const char* kWithExtensionSource1 = | 6317 static const char* kWithExtensionSource1 = |
| 6318 "function UseWith1() {" | 6318 "function UseWith1() {" |
| 6319 " var x = 42;" | 6319 " var x = 42;" |
| 6320 " with({x:87}) { return x; }" | 6320 " with({x:87}) { return x; }" |
| 6321 "}"; | 6321 "}"; |
| 6322 | 6322 |
| 6323 | 6323 |
| 6324 | 6324 |
| 6325 static const char* kWithExtensionSource2 = | 6325 static const char* kWithExtensionSource2 = |
| 6326 "(function() {" | 6326 "(function() {" |
| 6327 " var x = 42;" | 6327 " var x = 42;" |
| 6328 " function e() {" | 6328 " function e() {" |
| 6329 " with ({x:87}) { return x; }" | 6329 " with ({x:87}) { return x; }" |
| 6330 " }" | 6330 " }" |
| 6331 " this.UseWith2 = e;" | 6331 " this.UseWith2 = e;" |
| 6332 "})()"; | 6332 "})()"; |
| 6333 | 6333 |
| 6334 | 6334 |
| 6335 THREADED_TEST(UseWithFromExtension) { | 6335 THREADED_TEST(UseWithFromExtension) { |
| 6336 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6336 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6337 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); | 6337 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1)); |
| 6338 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); | 6338 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2)); |
| 6339 const char* extension_names[] = { "withtest1", "withtest2" }; | 6339 const char* extension_names[] = { "withtest1", "withtest2" }; |
| 6340 v8::ExtensionConfiguration extensions(2, extension_names); | 6340 v8::ExtensionConfiguration extensions(2, extension_names); |
| 6341 v8::Handle<Context> context = | 6341 v8::Handle<Context> context = |
| 6342 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6342 Context::New(CcTest::isolate(), &extensions); |
| 6343 Context::Scope lock(context); | 6343 Context::Scope lock(context); |
| 6344 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); | 6344 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); |
| 6345 CHECK_EQ(result, v8::Integer::New(87)); | 6345 CHECK_EQ(result, v8::Integer::New(87)); |
| 6346 result = Script::Compile(v8_str("UseWith2()"))->Run(); | 6346 result = Script::Compile(v8_str("UseWith2()"))->Run(); |
| 6347 CHECK_EQ(result, v8::Integer::New(87)); | 6347 CHECK_EQ(result, v8::Integer::New(87)); |
| 6348 } | 6348 } |
| 6349 | 6349 |
| 6350 | 6350 |
| 6351 THREADED_TEST(AutoExtensions) { | 6351 THREADED_TEST(AutoExtensions) { |
| 6352 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6352 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6353 Extension* extension = new Extension("autotest", kSimpleExtensionSource); | 6353 Extension* extension = new Extension("autotest", kSimpleExtensionSource); |
| 6354 extension->set_auto_enable(true); | 6354 extension->set_auto_enable(true); |
| 6355 v8::RegisterExtension(extension); | 6355 v8::RegisterExtension(extension); |
| 6356 v8::Handle<Context> context = | 6356 v8::Handle<Context> context = |
| 6357 Context::New(v8::Isolate::GetCurrent()); | 6357 Context::New(CcTest::isolate()); |
| 6358 Context::Scope lock(context); | 6358 Context::Scope lock(context); |
| 6359 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); | 6359 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
| 6360 CHECK_EQ(result, v8::Integer::New(4)); | 6360 CHECK_EQ(result, v8::Integer::New(4)); |
| 6361 } | 6361 } |
| 6362 | 6362 |
| 6363 | 6363 |
| 6364 static const char* kSyntaxErrorInExtensionSource = | 6364 static const char* kSyntaxErrorInExtensionSource = |
| 6365 "["; | 6365 "["; |
| 6366 | 6366 |
| 6367 | 6367 |
| 6368 // Test that a syntax error in an extension does not cause a fatal | 6368 // Test that a syntax error in an extension does not cause a fatal |
| 6369 // error but results in an empty context. | 6369 // error but results in an empty context. |
| 6370 THREADED_TEST(SyntaxErrorExtensions) { | 6370 THREADED_TEST(SyntaxErrorExtensions) { |
| 6371 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6371 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6372 v8::RegisterExtension(new Extension("syntaxerror", | 6372 v8::RegisterExtension(new Extension("syntaxerror", |
| 6373 kSyntaxErrorInExtensionSource)); | 6373 kSyntaxErrorInExtensionSource)); |
| 6374 const char* extension_names[] = { "syntaxerror" }; | 6374 const char* extension_names[] = { "syntaxerror" }; |
| 6375 v8::ExtensionConfiguration extensions(1, extension_names); | 6375 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6376 v8::Handle<Context> context = | 6376 v8::Handle<Context> context = |
| 6377 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6377 Context::New(CcTest::isolate(), &extensions); |
| 6378 CHECK(context.IsEmpty()); | 6378 CHECK(context.IsEmpty()); |
| 6379 } | 6379 } |
| 6380 | 6380 |
| 6381 | 6381 |
| 6382 static const char* kExceptionInExtensionSource = | 6382 static const char* kExceptionInExtensionSource = |
| 6383 "throw 42"; | 6383 "throw 42"; |
| 6384 | 6384 |
| 6385 | 6385 |
| 6386 // Test that an exception when installing an extension does not cause | 6386 // Test that an exception when installing an extension does not cause |
| 6387 // a fatal error but results in an empty context. | 6387 // a fatal error but results in an empty context. |
| 6388 THREADED_TEST(ExceptionExtensions) { | 6388 THREADED_TEST(ExceptionExtensions) { |
| 6389 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6389 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6390 v8::RegisterExtension(new Extension("exception", | 6390 v8::RegisterExtension(new Extension("exception", |
| 6391 kExceptionInExtensionSource)); | 6391 kExceptionInExtensionSource)); |
| 6392 const char* extension_names[] = { "exception" }; | 6392 const char* extension_names[] = { "exception" }; |
| 6393 v8::ExtensionConfiguration extensions(1, extension_names); | 6393 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6394 v8::Handle<Context> context = | 6394 v8::Handle<Context> context = |
| 6395 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6395 Context::New(CcTest::isolate(), &extensions); |
| 6396 CHECK(context.IsEmpty()); | 6396 CHECK(context.IsEmpty()); |
| 6397 } | 6397 } |
| 6398 | 6398 |
| 6399 | 6399 |
| 6400 static const char* kNativeCallInExtensionSource = | 6400 static const char* kNativeCallInExtensionSource = |
| 6401 "function call_runtime_last_index_of(x) {" | 6401 "function call_runtime_last_index_of(x) {" |
| 6402 " return %StringLastIndexOf(x, 'bob', 10);" | 6402 " return %StringLastIndexOf(x, 'bob', 10);" |
| 6403 "}"; | 6403 "}"; |
| 6404 | 6404 |
| 6405 | 6405 |
| 6406 static const char* kNativeCallTest = | 6406 static const char* kNativeCallTest = |
| 6407 "call_runtime_last_index_of('bobbobboellebobboellebobbob');"; | 6407 "call_runtime_last_index_of('bobbobboellebobboellebobbob');"; |
| 6408 | 6408 |
| 6409 // Test that a native runtime calls are supported in extensions. | 6409 // Test that a native runtime calls are supported in extensions. |
| 6410 THREADED_TEST(NativeCallInExtensions) { | 6410 THREADED_TEST(NativeCallInExtensions) { |
| 6411 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6411 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6412 v8::RegisterExtension(new Extension("nativecall", | 6412 v8::RegisterExtension(new Extension("nativecall", |
| 6413 kNativeCallInExtensionSource)); | 6413 kNativeCallInExtensionSource)); |
| 6414 const char* extension_names[] = { "nativecall" }; | 6414 const char* extension_names[] = { "nativecall" }; |
| 6415 v8::ExtensionConfiguration extensions(1, extension_names); | 6415 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6416 v8::Handle<Context> context = | 6416 v8::Handle<Context> context = |
| 6417 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6417 Context::New(CcTest::isolate(), &extensions); |
| 6418 Context::Scope lock(context); | 6418 Context::Scope lock(context); |
| 6419 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); | 6419 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); |
| 6420 CHECK_EQ(result, v8::Integer::New(3)); | 6420 CHECK_EQ(result, v8::Integer::New(3)); |
| 6421 } | 6421 } |
| 6422 | 6422 |
| 6423 | 6423 |
| 6424 class NativeFunctionExtension : public Extension { | 6424 class NativeFunctionExtension : public Extension { |
| 6425 public: | 6425 public: |
| 6426 NativeFunctionExtension(const char* name, | 6426 NativeFunctionExtension(const char* name, |
| 6427 const char* source, | 6427 const char* source, |
| 6428 v8::FunctionCallback fun = &Echo) | 6428 v8::FunctionCallback fun = &Echo) |
| 6429 : Extension(name, source), | 6429 : Extension(name, source), |
| 6430 function_(fun) { } | 6430 function_(fun) { } |
| 6431 | 6431 |
| 6432 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 6432 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
| 6433 v8::Handle<v8::String> name) { | 6433 v8::Handle<v8::String> name) { |
| 6434 return v8::FunctionTemplate::New(function_); | 6434 return v8::FunctionTemplate::New(function_); |
| 6435 } | 6435 } |
| 6436 | 6436 |
| 6437 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { | 6437 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6438 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); | 6438 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); |
| 6439 } | 6439 } |
| 6440 private: | 6440 private: |
| 6441 v8::FunctionCallback function_; | 6441 v8::FunctionCallback function_; |
| 6442 }; | 6442 }; |
| 6443 | 6443 |
| 6444 | 6444 |
| 6445 THREADED_TEST(NativeFunctionDeclaration) { | 6445 THREADED_TEST(NativeFunctionDeclaration) { |
| 6446 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6446 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6447 const char* name = "nativedecl"; | 6447 const char* name = "nativedecl"; |
| 6448 v8::RegisterExtension(new NativeFunctionExtension(name, | 6448 v8::RegisterExtension(new NativeFunctionExtension(name, |
| 6449 "native function foo();")); | 6449 "native function foo();")); |
| 6450 const char* extension_names[] = { name }; | 6450 const char* extension_names[] = { name }; |
| 6451 v8::ExtensionConfiguration extensions(1, extension_names); | 6451 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6452 v8::Handle<Context> context = | 6452 v8::Handle<Context> context = |
| 6453 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6453 Context::New(CcTest::isolate(), &extensions); |
| 6454 Context::Scope lock(context); | 6454 Context::Scope lock(context); |
| 6455 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); | 6455 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); |
| 6456 CHECK_EQ(result, v8::Integer::New(42)); | 6456 CHECK_EQ(result, v8::Integer::New(42)); |
| 6457 } | 6457 } |
| 6458 | 6458 |
| 6459 | 6459 |
| 6460 THREADED_TEST(NativeFunctionDeclarationError) { | 6460 THREADED_TEST(NativeFunctionDeclarationError) { |
| 6461 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6461 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6462 const char* name = "nativedeclerr"; | 6462 const char* name = "nativedeclerr"; |
| 6463 // Syntax error in extension code. | 6463 // Syntax error in extension code. |
| 6464 v8::RegisterExtension(new NativeFunctionExtension(name, | 6464 v8::RegisterExtension(new NativeFunctionExtension(name, |
| 6465 "native\nfunction foo();")); | 6465 "native\nfunction foo();")); |
| 6466 const char* extension_names[] = { name }; | 6466 const char* extension_names[] = { name }; |
| 6467 v8::ExtensionConfiguration extensions(1, extension_names); | 6467 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6468 v8::Handle<Context> context = | 6468 v8::Handle<Context> context = |
| 6469 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6469 Context::New(CcTest::isolate(), &extensions); |
| 6470 CHECK(context.IsEmpty()); | 6470 CHECK(context.IsEmpty()); |
| 6471 } | 6471 } |
| 6472 | 6472 |
| 6473 | 6473 |
| 6474 THREADED_TEST(NativeFunctionDeclarationErrorEscape) { | 6474 THREADED_TEST(NativeFunctionDeclarationErrorEscape) { |
| 6475 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6475 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6476 const char* name = "nativedeclerresc"; | 6476 const char* name = "nativedeclerresc"; |
| 6477 // Syntax error in extension code - escape code in "native" means that | 6477 // Syntax error in extension code - escape code in "native" means that |
| 6478 // it's not treated as a keyword. | 6478 // it's not treated as a keyword. |
| 6479 v8::RegisterExtension(new NativeFunctionExtension( | 6479 v8::RegisterExtension(new NativeFunctionExtension( |
| 6480 name, | 6480 name, |
| 6481 "nativ\\u0065 function foo();")); | 6481 "nativ\\u0065 function foo();")); |
| 6482 const char* extension_names[] = { name }; | 6482 const char* extension_names[] = { name }; |
| 6483 v8::ExtensionConfiguration extensions(1, extension_names); | 6483 v8::ExtensionConfiguration extensions(1, extension_names); |
| 6484 v8::Handle<Context> context = | 6484 v8::Handle<Context> context = |
| 6485 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6485 Context::New(CcTest::isolate(), &extensions); |
| 6486 CHECK(context.IsEmpty()); | 6486 CHECK(context.IsEmpty()); |
| 6487 } | 6487 } |
| 6488 | 6488 |
| 6489 | 6489 |
| 6490 static void CheckDependencies(const char* name, const char* expected) { | 6490 static void CheckDependencies(const char* name, const char* expected) { |
| 6491 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6491 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6492 v8::ExtensionConfiguration config(1, &name); | 6492 v8::ExtensionConfiguration config(1, &name); |
| 6493 LocalContext context(&config); | 6493 LocalContext context(&config); |
| 6494 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); | 6494 CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded"))); |
| 6495 } | 6495 } |
| 6496 | 6496 |
| 6497 | 6497 |
| 6498 /* | 6498 /* |
| 6499 * Configuration: | 6499 * Configuration: |
| 6500 * | 6500 * |
| 6501 * /-- B <--\ | 6501 * /-- B <--\ |
| 6502 * A <- -- D <-- E | 6502 * A <- -- D <-- E |
| 6503 * \-- C <--/ | 6503 * \-- C <--/ |
| 6504 */ | 6504 */ |
| 6505 THREADED_TEST(ExtensionDependency) { | 6505 THREADED_TEST(ExtensionDependency) { |
| 6506 static const char* kEDeps[] = { "D" }; | 6506 static const char* kEDeps[] = { "D" }; |
| 6507 v8::RegisterExtension(new Extension("E", "this.loaded += 'E';", 1, kEDeps)); | 6507 v8::RegisterExtension(new Extension("E", "this.loaded += 'E';", 1, kEDeps)); |
| 6508 static const char* kDDeps[] = { "B", "C" }; | 6508 static const char* kDDeps[] = { "B", "C" }; |
| 6509 v8::RegisterExtension(new Extension("D", "this.loaded += 'D';", 2, kDDeps)); | 6509 v8::RegisterExtension(new Extension("D", "this.loaded += 'D';", 2, kDDeps)); |
| 6510 static const char* kBCDeps[] = { "A" }; | 6510 static const char* kBCDeps[] = { "A" }; |
| 6511 v8::RegisterExtension(new Extension("B", "this.loaded += 'B';", 1, kBCDeps)); | 6511 v8::RegisterExtension(new Extension("B", "this.loaded += 'B';", 1, kBCDeps)); |
| 6512 v8::RegisterExtension(new Extension("C", "this.loaded += 'C';", 1, kBCDeps)); | 6512 v8::RegisterExtension(new Extension("C", "this.loaded += 'C';", 1, kBCDeps)); |
| 6513 v8::RegisterExtension(new Extension("A", "this.loaded += 'A';")); | 6513 v8::RegisterExtension(new Extension("A", "this.loaded += 'A';")); |
| 6514 CheckDependencies("A", "undefinedA"); | 6514 CheckDependencies("A", "undefinedA"); |
| 6515 CheckDependencies("B", "undefinedAB"); | 6515 CheckDependencies("B", "undefinedAB"); |
| 6516 CheckDependencies("C", "undefinedAC"); | 6516 CheckDependencies("C", "undefinedAC"); |
| 6517 CheckDependencies("D", "undefinedABCD"); | 6517 CheckDependencies("D", "undefinedABCD"); |
| 6518 CheckDependencies("E", "undefinedABCDE"); | 6518 CheckDependencies("E", "undefinedABCDE"); |
| 6519 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6519 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6520 static const char* exts[2] = { "C", "E" }; | 6520 static const char* exts[2] = { "C", "E" }; |
| 6521 v8::ExtensionConfiguration config(2, exts); | 6521 v8::ExtensionConfiguration config(2, exts); |
| 6522 LocalContext context(&config); | 6522 LocalContext context(&config); |
| 6523 CHECK_EQ(v8_str("undefinedACBDE"), context->Global()->Get(v8_str("loaded"))); | 6523 CHECK_EQ(v8_str("undefinedACBDE"), context->Global()->Get(v8_str("loaded"))); |
| 6524 } | 6524 } |
| 6525 | 6525 |
| 6526 | 6526 |
| 6527 static const char* kExtensionTestScript = | 6527 static const char* kExtensionTestScript = |
| 6528 "native function A();" | 6528 "native function A();" |
| 6529 "native function B();" | 6529 "native function B();" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6565 } else if (name->Equals(v8_str("C"))) { | 6565 } else if (name->Equals(v8_str("C"))) { |
| 6566 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6)); | 6566 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6)); |
| 6567 } else { | 6567 } else { |
| 6568 return v8::Handle<v8::FunctionTemplate>(); | 6568 return v8::Handle<v8::FunctionTemplate>(); |
| 6569 } | 6569 } |
| 6570 } | 6570 } |
| 6571 | 6571 |
| 6572 | 6572 |
| 6573 THREADED_TEST(FunctionLookup) { | 6573 THREADED_TEST(FunctionLookup) { |
| 6574 v8::RegisterExtension(new FunctionExtension()); | 6574 v8::RegisterExtension(new FunctionExtension()); |
| 6575 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6575 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6576 static const char* exts[1] = { "functiontest" }; | 6576 static const char* exts[1] = { "functiontest" }; |
| 6577 v8::ExtensionConfiguration config(1, exts); | 6577 v8::ExtensionConfiguration config(1, exts); |
| 6578 LocalContext context(&config); | 6578 LocalContext context(&config); |
| 6579 CHECK_EQ(3, lookup_count); | 6579 CHECK_EQ(3, lookup_count); |
| 6580 CHECK_EQ(v8::Integer::New(8), Script::Compile(v8_str("Foo(0)"))->Run()); | 6580 CHECK_EQ(v8::Integer::New(8), Script::Compile(v8_str("Foo(0)"))->Run()); |
| 6581 CHECK_EQ(v8::Integer::New(7), Script::Compile(v8_str("Foo(1)"))->Run()); | 6581 CHECK_EQ(v8::Integer::New(7), Script::Compile(v8_str("Foo(1)"))->Run()); |
| 6582 CHECK_EQ(v8::Integer::New(6), Script::Compile(v8_str("Foo(2)"))->Run()); | 6582 CHECK_EQ(v8::Integer::New(6), Script::Compile(v8_str("Foo(2)"))->Run()); |
| 6583 } | 6583 } |
| 6584 | 6584 |
| 6585 | 6585 |
| 6586 THREADED_TEST(NativeFunctionConstructCall) { | 6586 THREADED_TEST(NativeFunctionConstructCall) { |
| 6587 v8::RegisterExtension(new FunctionExtension()); | 6587 v8::RegisterExtension(new FunctionExtension()); |
| 6588 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6588 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6589 static const char* exts[1] = { "functiontest" }; | 6589 static const char* exts[1] = { "functiontest" }; |
| 6590 v8::ExtensionConfiguration config(1, exts); | 6590 v8::ExtensionConfiguration config(1, exts); |
| 6591 LocalContext context(&config); | 6591 LocalContext context(&config); |
| 6592 for (int i = 0; i < 10; i++) { | 6592 for (int i = 0; i < 10; i++) { |
| 6593 // Run a few times to ensure that allocation of objects doesn't | 6593 // Run a few times to ensure that allocation of objects doesn't |
| 6594 // change behavior of a constructor function. | 6594 // change behavior of a constructor function. |
| 6595 CHECK_EQ(v8::Integer::New(8), | 6595 CHECK_EQ(v8::Integer::New(8), |
| 6596 Script::Compile(v8_str("(new A()).data"))->Run()); | 6596 Script::Compile(v8_str("(new A()).data"))->Run()); |
| 6597 CHECK_EQ(v8::Integer::New(7), | 6597 CHECK_EQ(v8::Integer::New(7), |
| 6598 Script::Compile(v8_str("(new B()).data"))->Run()); | 6598 Script::Compile(v8_str("(new B()).data"))->Run()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6617 // unusable and therefore this test cannot be run in parallel. | 6617 // unusable and therefore this test cannot be run in parallel. |
| 6618 TEST(ErrorReporting) { | 6618 TEST(ErrorReporting) { |
| 6619 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 6619 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
| 6620 static const char* aDeps[] = { "B" }; | 6620 static const char* aDeps[] = { "B" }; |
| 6621 v8::RegisterExtension(new Extension("A", "", 1, aDeps)); | 6621 v8::RegisterExtension(new Extension("A", "", 1, aDeps)); |
| 6622 static const char* bDeps[] = { "A" }; | 6622 static const char* bDeps[] = { "A" }; |
| 6623 v8::RegisterExtension(new Extension("B", "", 1, bDeps)); | 6623 v8::RegisterExtension(new Extension("B", "", 1, bDeps)); |
| 6624 last_location = NULL; | 6624 last_location = NULL; |
| 6625 v8::ExtensionConfiguration config(1, bDeps); | 6625 v8::ExtensionConfiguration config(1, bDeps); |
| 6626 v8::Handle<Context> context = | 6626 v8::Handle<Context> context = |
| 6627 Context::New(v8::Isolate::GetCurrent(), &config); | 6627 Context::New(CcTest::isolate(), &config); |
| 6628 CHECK(context.IsEmpty()); | 6628 CHECK(context.IsEmpty()); |
| 6629 CHECK_NE(last_location, NULL); | 6629 CHECK_NE(last_location, NULL); |
| 6630 } | 6630 } |
| 6631 | 6631 |
| 6632 | 6632 |
| 6633 static const char* js_code_causing_huge_string_flattening = | 6633 static const char* js_code_causing_huge_string_flattening = |
| 6634 "var str = 'X';" | 6634 "var str = 'X';" |
| 6635 "for (var i = 0; i < 30; i++) {" | 6635 "for (var i = 0; i < 30; i++) {" |
| 6636 " str = str + str;" | 6636 " str = str + str;" |
| 6637 "}" | 6637 "}" |
| 6638 "str.match(/X/);"; | 6638 "str.match(/X/);"; |
| 6639 | 6639 |
| 6640 | 6640 |
| 6641 void OOMCallback(const char* location, const char* message) { | 6641 void OOMCallback(const char* location, const char* message) { |
| 6642 exit(0); | 6642 exit(0); |
| 6643 } | 6643 } |
| 6644 | 6644 |
| 6645 | 6645 |
| 6646 TEST(RegexpOutOfMemory) { | 6646 TEST(RegexpOutOfMemory) { |
| 6647 // Execute a script that causes out of memory when flattening a string. | 6647 // Execute a script that causes out of memory when flattening a string. |
| 6648 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6648 v8::HandleScope scope(CcTest::isolate()); |
| 6649 v8::V8::SetFatalErrorHandler(OOMCallback); | 6649 v8::V8::SetFatalErrorHandler(OOMCallback); |
| 6650 LocalContext context; | 6650 LocalContext context; |
| 6651 Local<Script> script = | 6651 Local<Script> script = |
| 6652 Script::Compile(String::New(js_code_causing_huge_string_flattening)); | 6652 Script::Compile(String::New(js_code_causing_huge_string_flattening)); |
| 6653 last_location = NULL; | 6653 last_location = NULL; |
| 6654 script->Run(); | 6654 script->Run(); |
| 6655 | 6655 |
| 6656 CHECK(false); // Should not return. | 6656 CHECK(false); // Should not return. |
| 6657 } | 6657 } |
| 6658 | 6658 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6721 prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference); | 6721 prev.MakeWeak<Value, Snorkel>(new Snorkel(), &HandleWeakReference); |
| 6722 whammy->objects_[whammy->cursor_].Clear(); | 6722 whammy->objects_[whammy->cursor_].Clear(); |
| 6723 } | 6723 } |
| 6724 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); | 6724 whammy->objects_[whammy->cursor_].Reset(info.GetIsolate(), obj); |
| 6725 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; | 6725 whammy->cursor_ = (whammy->cursor_ + 1) % Whammy::kObjectCount; |
| 6726 info.GetReturnValue().Set(whammy->getScript()->Run()); | 6726 info.GetReturnValue().Set(whammy->getScript()->Run()); |
| 6727 } | 6727 } |
| 6728 | 6728 |
| 6729 | 6729 |
| 6730 THREADED_TEST(WeakReference) { | 6730 THREADED_TEST(WeakReference) { |
| 6731 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 6731 v8::HandleScope handle_scope(CcTest::isolate()); |
| 6732 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); | 6732 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New(); |
| 6733 Whammy* whammy = new Whammy(v8::Isolate::GetCurrent()); | 6733 Whammy* whammy = new Whammy(CcTest::isolate()); |
| 6734 templ->SetNamedPropertyHandler(WhammyPropertyGetter, | 6734 templ->SetNamedPropertyHandler(WhammyPropertyGetter, |
| 6735 0, 0, 0, 0, | 6735 0, 0, 0, 0, |
| 6736 v8::External::New(whammy)); | 6736 v8::External::New(whammy)); |
| 6737 const char* extension_list[] = { "v8/gc" }; | 6737 const char* extension_list[] = { "v8/gc" }; |
| 6738 v8::ExtensionConfiguration extensions(1, extension_list); | 6738 v8::ExtensionConfiguration extensions(1, extension_list); |
| 6739 v8::Handle<Context> context = | 6739 v8::Handle<Context> context = |
| 6740 Context::New(v8::Isolate::GetCurrent(), &extensions); | 6740 Context::New(CcTest::isolate(), &extensions); |
| 6741 Context::Scope context_scope(context); | 6741 Context::Scope context_scope(context); |
| 6742 | 6742 |
| 6743 v8::Handle<v8::Object> interceptor = templ->NewInstance(); | 6743 v8::Handle<v8::Object> interceptor = templ->NewInstance(); |
| 6744 context->Global()->Set(v8_str("whammy"), interceptor); | 6744 context->Global()->Set(v8_str("whammy"), interceptor); |
| 6745 const char* code = | 6745 const char* code = |
| 6746 "var last;" | 6746 "var last;" |
| 6747 "for (var i = 0; i < 10000; i++) {" | 6747 "for (var i = 0; i < 10000; i++) {" |
| 6748 " var obj = whammy.length;" | 6748 " var obj = whammy.length;" |
| 6749 " if (last) last.next = obj;" | 6749 " if (last) last.next = obj;" |
| 6750 " last = obj;" | 6750 " last = obj;" |
| 6751 "}" | 6751 "}" |
| 6752 "gc();" | 6752 "gc();" |
| 6753 "4"; | 6753 "4"; |
| 6754 v8::Handle<Value> result = CompileRun(code); | 6754 v8::Handle<Value> result = CompileRun(code); |
| 6755 CHECK_EQ(4.0, result->NumberValue()); | 6755 CHECK_EQ(4.0, result->NumberValue()); |
| 6756 delete whammy; | 6756 delete whammy; |
| 6757 } | 6757 } |
| 6758 | 6758 |
| 6759 | 6759 |
| 6760 static void DisposeAndSetFlag(v8::Isolate* isolate, | 6760 static void DisposeAndSetFlag(v8::Isolate* isolate, |
| 6761 v8::Persistent<v8::Object>* obj, | 6761 v8::Persistent<v8::Object>* obj, |
| 6762 bool* data) { | 6762 bool* data) { |
| 6763 obj->Dispose(); | 6763 obj->Dispose(); |
| 6764 *(data) = true; | 6764 *(data) = true; |
| 6765 } | 6765 } |
| 6766 | 6766 |
| 6767 | 6767 |
| 6768 THREADED_TEST(IndependentWeakHandle) { | 6768 THREADED_TEST(IndependentWeakHandle) { |
| 6769 v8::Isolate* iso = v8::Isolate::GetCurrent(); | 6769 v8::Isolate* iso = CcTest::isolate(); |
| 6770 v8::HandleScope scope(iso); | 6770 v8::HandleScope scope(iso); |
| 6771 v8::Handle<Context> context = Context::New(iso); | 6771 v8::Handle<Context> context = Context::New(iso); |
| 6772 Context::Scope context_scope(context); | 6772 Context::Scope context_scope(context); |
| 6773 | 6773 |
| 6774 v8::Persistent<v8::Object> object_a, object_b; | 6774 v8::Persistent<v8::Object> object_a, object_b; |
| 6775 | 6775 |
| 6776 { | 6776 { |
| 6777 v8::HandleScope handle_scope(iso); | 6777 v8::HandleScope handle_scope(iso); |
| 6778 object_a.Reset(iso, v8::Object::New()); | 6778 object_a.Reset(iso, v8::Object::New()); |
| 6779 object_b.Reset(iso, v8::Object::New()); | 6779 object_b.Reset(iso, v8::Object::New()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6815 static void ForceMarkSweep(v8::Isolate* isolate, | 6815 static void ForceMarkSweep(v8::Isolate* isolate, |
| 6816 v8::Persistent<v8::Object>* obj, | 6816 v8::Persistent<v8::Object>* obj, |
| 6817 bool* data) { | 6817 bool* data) { |
| 6818 obj->Dispose(); | 6818 obj->Dispose(); |
| 6819 *(data) = true; | 6819 *(data) = true; |
| 6820 InvokeMarkSweep(); | 6820 InvokeMarkSweep(); |
| 6821 } | 6821 } |
| 6822 | 6822 |
| 6823 | 6823 |
| 6824 THREADED_TEST(GCFromWeakCallbacks) { | 6824 THREADED_TEST(GCFromWeakCallbacks) { |
| 6825 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 6825 v8::Isolate* isolate = CcTest::isolate(); |
| 6826 v8::HandleScope scope(isolate); | 6826 v8::HandleScope scope(isolate); |
| 6827 v8::Handle<Context> context = Context::New(isolate); | 6827 v8::Handle<Context> context = Context::New(isolate); |
| 6828 Context::Scope context_scope(context); | 6828 Context::Scope context_scope(context); |
| 6829 | 6829 |
| 6830 static const int kNumberOfGCTypes = 2; | 6830 static const int kNumberOfGCTypes = 2; |
| 6831 typedef v8::WeakReferenceCallbacks<v8::Object, bool>::Revivable Callback; | 6831 typedef v8::WeakReferenceCallbacks<v8::Object, bool>::Revivable Callback; |
| 6832 Callback gc_forcing_callback[kNumberOfGCTypes] = | 6832 Callback gc_forcing_callback[kNumberOfGCTypes] = |
| 6833 {&ForceScavenge, &ForceMarkSweep}; | 6833 {&ForceScavenge, &ForceMarkSweep}; |
| 6834 | 6834 |
| 6835 typedef void (*GCInvoker)(); | 6835 typedef void (*GCInvoker)(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6854 | 6854 |
| 6855 static void RevivingCallback(v8::Isolate* isolate, | 6855 static void RevivingCallback(v8::Isolate* isolate, |
| 6856 v8::Persistent<v8::Object>* obj, | 6856 v8::Persistent<v8::Object>* obj, |
| 6857 bool* data) { | 6857 bool* data) { |
| 6858 obj->ClearWeak(); | 6858 obj->ClearWeak(); |
| 6859 *(data) = true; | 6859 *(data) = true; |
| 6860 } | 6860 } |
| 6861 | 6861 |
| 6862 | 6862 |
| 6863 THREADED_TEST(IndependentHandleRevival) { | 6863 THREADED_TEST(IndependentHandleRevival) { |
| 6864 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 6864 v8::Isolate* isolate = CcTest::isolate(); |
| 6865 v8::HandleScope scope(isolate); | 6865 v8::HandleScope scope(isolate); |
| 6866 v8::Handle<Context> context = Context::New(isolate); | 6866 v8::Handle<Context> context = Context::New(isolate); |
| 6867 Context::Scope context_scope(context); | 6867 Context::Scope context_scope(context); |
| 6868 | 6868 |
| 6869 v8::Persistent<v8::Object> object; | 6869 v8::Persistent<v8::Object> object; |
| 6870 { | 6870 { |
| 6871 v8::HandleScope handle_scope(isolate); | 6871 v8::HandleScope handle_scope(isolate); |
| 6872 v8::Local<v8::Object> o = v8::Object::New(); | 6872 v8::Local<v8::Object> o = v8::Object::New(); |
| 6873 object.Reset(isolate, o); | 6873 object.Reset(isolate, o); |
| 6874 o->Set(v8_str("x"), v8::Integer::New(1)); | 6874 o->Set(v8_str("x"), v8::Integer::New(1)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6902 CHECK_EQ(v8::Integer::New(1), args[0]); | 6902 CHECK_EQ(v8::Integer::New(1), args[0]); |
| 6903 CHECK_EQ(v8::Integer::New(2), args[1]); | 6903 CHECK_EQ(v8::Integer::New(2), args[1]); |
| 6904 CHECK_EQ(v8::Integer::New(3), args[2]); | 6904 CHECK_EQ(v8::Integer::New(3), args[2]); |
| 6905 CHECK_EQ(v8::Undefined(), args[3]); | 6905 CHECK_EQ(v8::Undefined(), args[3]); |
| 6906 v8::HandleScope scope(args.GetIsolate()); | 6906 v8::HandleScope scope(args.GetIsolate()); |
| 6907 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 6907 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 6908 } | 6908 } |
| 6909 | 6909 |
| 6910 | 6910 |
| 6911 THREADED_TEST(Arguments) { | 6911 THREADED_TEST(Arguments) { |
| 6912 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6912 v8::HandleScope scope(CcTest::isolate()); |
| 6913 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 6913 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
| 6914 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); | 6914 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); |
| 6915 LocalContext context(NULL, global); | 6915 LocalContext context(NULL, global); |
| 6916 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); | 6916 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); |
| 6917 v8_compile("f(1, 2, 3)")->Run(); | 6917 v8_compile("f(1, 2, 3)")->Run(); |
| 6918 } | 6918 } |
| 6919 | 6919 |
| 6920 | 6920 |
| 6921 static void NoBlockGetterX(Local<String> name, | 6921 static void NoBlockGetterX(Local<String> name, |
| 6922 const v8::PropertyCallbackInfo<v8::Value>&) { | 6922 const v8::PropertyCallbackInfo<v8::Value>&) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6942 const v8::PropertyCallbackInfo<v8::Boolean>& info) { | 6942 const v8::PropertyCallbackInfo<v8::Boolean>& info) { |
| 6943 if (index != 2) { | 6943 if (index != 2) { |
| 6944 return; // not intercepted | 6944 return; // not intercepted |
| 6945 } | 6945 } |
| 6946 | 6946 |
| 6947 info.GetReturnValue().Set(false); // intercepted, don't delete the property | 6947 info.GetReturnValue().Set(false); // intercepted, don't delete the property |
| 6948 } | 6948 } |
| 6949 | 6949 |
| 6950 | 6950 |
| 6951 THREADED_TEST(Deleter) { | 6951 THREADED_TEST(Deleter) { |
| 6952 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 6952 v8::HandleScope scope(CcTest::isolate()); |
| 6953 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 6953 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 6954 obj->SetNamedPropertyHandler(NoBlockGetterX, NULL, NULL, PDeleter, NULL); | 6954 obj->SetNamedPropertyHandler(NoBlockGetterX, NULL, NULL, PDeleter, NULL); |
| 6955 obj->SetIndexedPropertyHandler(NoBlockGetterI, NULL, NULL, IDeleter, NULL); | 6955 obj->SetIndexedPropertyHandler(NoBlockGetterI, NULL, NULL, IDeleter, NULL); |
| 6956 LocalContext context; | 6956 LocalContext context; |
| 6957 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 6957 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
| 6958 CompileRun( | 6958 CompileRun( |
| 6959 "k.foo = 'foo';" | 6959 "k.foo = 'foo';" |
| 6960 "k.bar = 'bar';" | 6960 "k.bar = 'bar';" |
| 6961 "k[2] = 2;" | 6961 "k[2] = 2;" |
| 6962 "k[4] = 4;"); | 6962 "k[4] = 4;"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7005 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 7005 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 7006 ApiTestFuzzer::Fuzz(); | 7006 ApiTestFuzzer::Fuzz(); |
| 7007 v8::Handle<v8::Array> result = v8::Array::New(2); | 7007 v8::Handle<v8::Array> result = v8::Array::New(2); |
| 7008 result->Set(v8::Integer::New(0), v8_str("0")); | 7008 result->Set(v8::Integer::New(0), v8_str("0")); |
| 7009 result->Set(v8::Integer::New(1), v8_str("1")); | 7009 result->Set(v8::Integer::New(1), v8_str("1")); |
| 7010 info.GetReturnValue().Set(result); | 7010 info.GetReturnValue().Set(result); |
| 7011 } | 7011 } |
| 7012 | 7012 |
| 7013 | 7013 |
| 7014 THREADED_TEST(Enumerators) { | 7014 THREADED_TEST(Enumerators) { |
| 7015 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7015 v8::HandleScope scope(CcTest::isolate()); |
| 7016 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7016 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 7017 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); | 7017 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); |
| 7018 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); | 7018 obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum); |
| 7019 LocalContext context; | 7019 LocalContext context; |
| 7020 context->Global()->Set(v8_str("k"), obj->NewInstance()); | 7020 context->Global()->Set(v8_str("k"), obj->NewInstance()); |
| 7021 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 7021 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
| 7022 "k[10] = 0;" | 7022 "k[10] = 0;" |
| 7023 "k.a = 0;" | 7023 "k.a = 0;" |
| 7024 "k[5] = 0;" | 7024 "k[5] = 0;" |
| 7025 "k.b = 0;" | 7025 "k.b = 0;" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7118 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); | 7118 CHECK_EQ(info.This(), global->Get(v8_str("o2"))); |
| 7119 } else if (name->Equals(v8_str("p3"))) { | 7119 } else if (name->Equals(v8_str("p3"))) { |
| 7120 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); | 7120 CHECK_EQ(info.This(), global->Get(v8_str("o3"))); |
| 7121 } else if (name->Equals(v8_str("p4"))) { | 7121 } else if (name->Equals(v8_str("p4"))) { |
| 7122 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); | 7122 CHECK_EQ(info.This(), global->Get(v8_str("o4"))); |
| 7123 } | 7123 } |
| 7124 } | 7124 } |
| 7125 | 7125 |
| 7126 | 7126 |
| 7127 THREADED_TEST(GetterHolders) { | 7127 THREADED_TEST(GetterHolders) { |
| 7128 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7128 v8::HandleScope scope(CcTest::isolate()); |
| 7129 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7129 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 7130 obj->SetAccessor(v8_str("p1"), PGetter); | 7130 obj->SetAccessor(v8_str("p1"), PGetter); |
| 7131 obj->SetAccessor(v8_str("p2"), PGetter); | 7131 obj->SetAccessor(v8_str("p2"), PGetter); |
| 7132 obj->SetAccessor(v8_str("p3"), PGetter); | 7132 obj->SetAccessor(v8_str("p3"), PGetter); |
| 7133 obj->SetAccessor(v8_str("p4"), PGetter); | 7133 obj->SetAccessor(v8_str("p4"), PGetter); |
| 7134 p_getter_count = 0; | 7134 p_getter_count = 0; |
| 7135 RunHolderTest(obj); | 7135 RunHolderTest(obj); |
| 7136 CHECK_EQ(40, p_getter_count); | 7136 CHECK_EQ(40, p_getter_count); |
| 7137 } | 7137 } |
| 7138 | 7138 |
| 7139 | 7139 |
| 7140 THREADED_TEST(PreInterceptorHolders) { | 7140 THREADED_TEST(PreInterceptorHolders) { |
| 7141 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7141 v8::HandleScope scope(CcTest::isolate()); |
| 7142 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7142 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 7143 obj->SetNamedPropertyHandler(PGetter2); | 7143 obj->SetNamedPropertyHandler(PGetter2); |
| 7144 p_getter_count2 = 0; | 7144 p_getter_count2 = 0; |
| 7145 RunHolderTest(obj); | 7145 RunHolderTest(obj); |
| 7146 CHECK_EQ(40, p_getter_count2); | 7146 CHECK_EQ(40, p_getter_count2); |
| 7147 } | 7147 } |
| 7148 | 7148 |
| 7149 | 7149 |
| 7150 THREADED_TEST(ObjectInstantiation) { | 7150 THREADED_TEST(ObjectInstantiation) { |
| 7151 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7151 v8::HandleScope scope(CcTest::isolate()); |
| 7152 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 7152 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 7153 templ->SetAccessor(v8_str("t"), PGetter2); | 7153 templ->SetAccessor(v8_str("t"), PGetter2); |
| 7154 LocalContext context; | 7154 LocalContext context; |
| 7155 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 7155 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 7156 for (int i = 0; i < 100; i++) { | 7156 for (int i = 0; i < 100; i++) { |
| 7157 v8::HandleScope inner_scope(v8::Isolate::GetCurrent()); | 7157 v8::HandleScope inner_scope(CcTest::isolate()); |
| 7158 v8::Handle<v8::Object> obj = templ->NewInstance(); | 7158 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 7159 CHECK_NE(obj, context->Global()->Get(v8_str("o"))); | 7159 CHECK_NE(obj, context->Global()->Get(v8_str("o"))); |
| 7160 context->Global()->Set(v8_str("o2"), obj); | 7160 context->Global()->Set(v8_str("o2"), obj); |
| 7161 v8::Handle<Value> value = | 7161 v8::Handle<Value> value = |
| 7162 Script::Compile(v8_str("o.__proto__ === o2.__proto__"))->Run(); | 7162 Script::Compile(v8_str("o.__proto__ === o2.__proto__"))->Run(); |
| 7163 CHECK_EQ(v8::True(), value); | 7163 CHECK_EQ(v8::True(), value); |
| 7164 context->Global()->Set(v8_str("o"), obj); | 7164 context->Global()->Set(v8_str("o"), obj); |
| 7165 } | 7165 } |
| 7166 } | 7166 } |
| 7167 | 7167 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7725 Local<Value> value, | 7725 Local<Value> value, |
| 7726 const v8::PropertyCallbackInfo<void>& info) { | 7726 const v8::PropertyCallbackInfo<void>& info) { |
| 7727 if (info.This()->Has(name)) { | 7727 if (info.This()->Has(name)) { |
| 7728 info.This()->Delete(name); | 7728 info.This()->Delete(name); |
| 7729 } | 7729 } |
| 7730 info.This()->Set(name, value); | 7730 info.This()->Set(name, value); |
| 7731 } | 7731 } |
| 7732 | 7732 |
| 7733 | 7733 |
| 7734 THREADED_TEST(DeleteAccessor) { | 7734 THREADED_TEST(DeleteAccessor) { |
| 7735 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7735 v8::HandleScope scope(CcTest::isolate()); |
| 7736 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7736 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 7737 obj->SetAccessor(v8_str("y"), YGetter, YSetter); | 7737 obj->SetAccessor(v8_str("y"), YGetter, YSetter); |
| 7738 LocalContext context; | 7738 LocalContext context; |
| 7739 v8::Handle<v8::Object> holder = obj->NewInstance(); | 7739 v8::Handle<v8::Object> holder = obj->NewInstance(); |
| 7740 context->Global()->Set(v8_str("holder"), holder); | 7740 context->Global()->Set(v8_str("holder"), holder); |
| 7741 v8::Handle<Value> result = CompileRun( | 7741 v8::Handle<Value> result = CompileRun( |
| 7742 "holder.y = 11; holder.y = 12; holder.y"); | 7742 "holder.y = 11; holder.y = 12; holder.y"); |
| 7743 CHECK_EQ(12, result->Uint32Value()); | 7743 CHECK_EQ(12, result->Uint32Value()); |
| 7744 } | 7744 } |
| 7745 | 7745 |
| 7746 | 7746 |
| 7747 THREADED_TEST(TypeSwitch) { | 7747 THREADED_TEST(TypeSwitch) { |
| 7748 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 7748 v8::HandleScope scope(CcTest::isolate()); |
| 7749 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(); | 7749 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New(); |
| 7750 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(); | 7750 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New(); |
| 7751 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(); | 7751 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New(); |
| 7752 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; | 7752 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 }; |
| 7753 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); | 7753 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs); |
| 7754 LocalContext context; | 7754 LocalContext context; |
| 7755 v8::Handle<v8::Object> obj0 = v8::Object::New(); | 7755 v8::Handle<v8::Object> obj0 = v8::Object::New(); |
| 7756 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); | 7756 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance(); |
| 7757 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); | 7757 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance(); |
| 7758 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); | 7758 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7908 CHECK(!try_catch.HasCaught()); | 7908 CHECK(!try_catch.HasCaught()); |
| 7909 Script::Compile(v8_str("(function()" | 7909 Script::Compile(v8_str("(function()" |
| 7910 " { try { throw ''; } finally { throw 0; }" | 7910 " { try { throw ''; } finally { throw 0; }" |
| 7911 "})()"))->Run(); | 7911 "})()"))->Run(); |
| 7912 CHECK(try_catch.HasCaught()); | 7912 CHECK(try_catch.HasCaught()); |
| 7913 } | 7913 } |
| 7914 | 7914 |
| 7915 | 7915 |
| 7916 // SecurityHandler can't be run twice | 7916 // SecurityHandler can't be run twice |
| 7917 TEST(SecurityHandler) { | 7917 TEST(SecurityHandler) { |
| 7918 v8::HandleScope scope0(v8::Isolate::GetCurrent()); | 7918 v8::HandleScope scope0(CcTest::isolate()); |
| 7919 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 7919 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 7920 global_template->SetAccessCheckCallbacks(NamedSecurityTestCallback, | 7920 global_template->SetAccessCheckCallbacks(NamedSecurityTestCallback, |
| 7921 IndexedSecurityTestCallback); | 7921 IndexedSecurityTestCallback); |
| 7922 // Create an environment | 7922 // Create an environment |
| 7923 v8::Handle<Context> context0 = | 7923 v8::Handle<Context> context0 = |
| 7924 Context::New(v8::Isolate::GetCurrent(), NULL, global_template); | 7924 Context::New(CcTest::isolate(), NULL, global_template); |
| 7925 context0->Enter(); | 7925 context0->Enter(); |
| 7926 | 7926 |
| 7927 v8::Handle<v8::Object> global0 = context0->Global(); | 7927 v8::Handle<v8::Object> global0 = context0->Global(); |
| 7928 v8::Handle<Script> script0 = v8_compile("foo = 111"); | 7928 v8::Handle<Script> script0 = v8_compile("foo = 111"); |
| 7929 script0->Run(); | 7929 script0->Run(); |
| 7930 global0->Set(v8_str("0"), v8_num(999)); | 7930 global0->Set(v8_str("0"), v8_num(999)); |
| 7931 v8::Handle<Value> foo0 = global0->Get(v8_str("foo")); | 7931 v8::Handle<Value> foo0 = global0->Get(v8_str("foo")); |
| 7932 CHECK_EQ(111, foo0->Int32Value()); | 7932 CHECK_EQ(111, foo0->Int32Value()); |
| 7933 v8::Handle<Value> z0 = global0->Get(v8_str("0")); | 7933 v8::Handle<Value> z0 = global0->Get(v8_str("0")); |
| 7934 CHECK_EQ(999, z0->Int32Value()); | 7934 CHECK_EQ(999, z0->Int32Value()); |
| 7935 | 7935 |
| 7936 // Create another environment, should fail security checks. | 7936 // Create another environment, should fail security checks. |
| 7937 v8::HandleScope scope1(v8::Isolate::GetCurrent()); | 7937 v8::HandleScope scope1(CcTest::isolate()); |
| 7938 | 7938 |
| 7939 v8::Handle<Context> context1 = | 7939 v8::Handle<Context> context1 = |
| 7940 Context::New(v8::Isolate::GetCurrent(), NULL, global_template); | 7940 Context::New(CcTest::isolate(), NULL, global_template); |
| 7941 context1->Enter(); | 7941 context1->Enter(); |
| 7942 | 7942 |
| 7943 v8::Handle<v8::Object> global1 = context1->Global(); | 7943 v8::Handle<v8::Object> global1 = context1->Global(); |
| 7944 global1->Set(v8_str("othercontext"), global0); | 7944 global1->Set(v8_str("othercontext"), global0); |
| 7945 // This set will fail the security check. | 7945 // This set will fail the security check. |
| 7946 v8::Handle<Script> script1 = | 7946 v8::Handle<Script> script1 = |
| 7947 v8_compile("othercontext.foo = 222; othercontext[0] = 888;"); | 7947 v8_compile("othercontext.foo = 222; othercontext[0] = 888;"); |
| 7948 script1->Run(); | 7948 script1->Run(); |
| 7949 // This read will pass the security check. | 7949 // This read will pass the security check. |
| 7950 v8::Handle<Value> foo1 = global0->Get(v8_str("foo")); | 7950 v8::Handle<Value> foo1 = global0->Get(v8_str("foo")); |
| 7951 CHECK_EQ(111, foo1->Int32Value()); | 7951 CHECK_EQ(111, foo1->Int32Value()); |
| 7952 // This read will pass the security check. | 7952 // This read will pass the security check. |
| 7953 v8::Handle<Value> z1 = global0->Get(v8_str("0")); | 7953 v8::Handle<Value> z1 = global0->Get(v8_str("0")); |
| 7954 CHECK_EQ(999, z1->Int32Value()); | 7954 CHECK_EQ(999, z1->Int32Value()); |
| 7955 | 7955 |
| 7956 // Create another environment, should pass security checks. | 7956 // Create another environment, should pass security checks. |
| 7957 { g_security_callback_result = true; // allow security handler to pass. | 7957 { g_security_callback_result = true; // allow security handler to pass. |
| 7958 v8::HandleScope scope2(v8::Isolate::GetCurrent()); | 7958 v8::HandleScope scope2(CcTest::isolate()); |
| 7959 LocalContext context2; | 7959 LocalContext context2; |
| 7960 v8::Handle<v8::Object> global2 = context2->Global(); | 7960 v8::Handle<v8::Object> global2 = context2->Global(); |
| 7961 global2->Set(v8_str("othercontext"), global0); | 7961 global2->Set(v8_str("othercontext"), global0); |
| 7962 v8::Handle<Script> script2 = | 7962 v8::Handle<Script> script2 = |
| 7963 v8_compile("othercontext.foo = 333; othercontext[0] = 888;"); | 7963 v8_compile("othercontext.foo = 333; othercontext[0] = 888;"); |
| 7964 script2->Run(); | 7964 script2->Run(); |
| 7965 v8::Handle<Value> foo2 = global0->Get(v8_str("foo")); | 7965 v8::Handle<Value> foo2 = global0->Get(v8_str("foo")); |
| 7966 CHECK_EQ(333, foo2->Int32Value()); | 7966 CHECK_EQ(333, foo2->Int32Value()); |
| 7967 v8::Handle<Value> z2 = global0->Get(v8_str("0")); | 7967 v8::Handle<Value> z2 = global0->Get(v8_str("0")); |
| 7968 CHECK_EQ(888, z2->Int32Value()); | 7968 CHECK_EQ(888, z2->Int32Value()); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8384 } | 8384 } |
| 8385 | 8385 |
| 8386 | 8386 |
| 8387 static void UnreachableFunction( | 8387 static void UnreachableFunction( |
| 8388 const v8::FunctionCallbackInfo<v8::Value>& info) { | 8388 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 8389 CHECK(false); // This function should not be called.. | 8389 CHECK(false); // This function should not be called.. |
| 8390 } | 8390 } |
| 8391 | 8391 |
| 8392 | 8392 |
| 8393 TEST(AccessControl) { | 8393 TEST(AccessControl) { |
| 8394 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 8394 v8::Isolate* isolate = CcTest::isolate(); |
| 8395 v8::HandleScope handle_scope(isolate); | 8395 v8::HandleScope handle_scope(isolate); |
| 8396 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 8396 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 8397 | 8397 |
| 8398 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, | 8398 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, |
| 8399 IndexedAccessBlocker); | 8399 IndexedAccessBlocker); |
| 8400 | 8400 |
| 8401 // Add an accessor accessible by cross-domain JS code. | 8401 // Add an accessor accessible by cross-domain JS code. |
| 8402 global_template->SetAccessor( | 8402 global_template->SetAccessor( |
| 8403 v8_str("accessible_prop"), | 8403 v8_str("accessible_prop"), |
| 8404 EchoGetter, EchoSetter, | 8404 EchoGetter, EchoSetter, |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8663 " }" | 8663 " }" |
| 8664 "return true;})()"); | 8664 "return true;})()"); |
| 8665 CHECK(value->IsTrue()); | 8665 CHECK(value->IsTrue()); |
| 8666 | 8666 |
| 8667 context1->Exit(); | 8667 context1->Exit(); |
| 8668 context0->Exit(); | 8668 context0->Exit(); |
| 8669 } | 8669 } |
| 8670 | 8670 |
| 8671 | 8671 |
| 8672 TEST(AccessControlES5) { | 8672 TEST(AccessControlES5) { |
| 8673 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 8673 v8::Isolate* isolate = CcTest::isolate(); |
| 8674 v8::HandleScope handle_scope(isolate); | 8674 v8::HandleScope handle_scope(isolate); |
| 8675 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 8675 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 8676 | 8676 |
| 8677 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, | 8677 global_template->SetAccessCheckCallbacks(NamedAccessBlocker, |
| 8678 IndexedAccessBlocker); | 8678 IndexedAccessBlocker); |
| 8679 | 8679 |
| 8680 // Add accessible accessor. | 8680 // Add accessible accessor. |
| 8681 global_template->SetAccessor( | 8681 global_template->SetAccessor( |
| 8682 v8_str("accessible_prop"), | 8682 v8_str("accessible_prop"), |
| 8683 EchoGetter, EchoSetter, | 8683 EchoGetter, EchoSetter, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8750 | 8750 |
| 8751 static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global, | 8751 static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global, |
| 8752 uint32_t key, | 8752 uint32_t key, |
| 8753 v8::AccessType type, | 8753 v8::AccessType type, |
| 8754 Local<Value> data) { | 8754 Local<Value> data) { |
| 8755 return false; | 8755 return false; |
| 8756 } | 8756 } |
| 8757 | 8757 |
| 8758 | 8758 |
| 8759 THREADED_TEST(AccessControlGetOwnPropertyNames) { | 8759 THREADED_TEST(AccessControlGetOwnPropertyNames) { |
| 8760 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 8760 v8::Isolate* isolate = CcTest::isolate(); |
| 8761 v8::HandleScope handle_scope(isolate); | 8761 v8::HandleScope handle_scope(isolate); |
| 8762 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 8762 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 8763 | 8763 |
| 8764 obj_template->Set(v8_str("x"), v8::Integer::New(42)); | 8764 obj_template->Set(v8_str("x"), v8::Integer::New(42)); |
| 8765 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, | 8765 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, |
| 8766 GetOwnPropertyNamesIndexedBlocker); | 8766 GetOwnPropertyNamesIndexedBlocker); |
| 8767 | 8767 |
| 8768 // Create an environment | 8768 // Create an environment |
| 8769 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); | 8769 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); |
| 8770 context0->Enter(); | 8770 context0->Enter(); |
| 8771 | 8771 |
| 8772 v8::Handle<v8::Object> global0 = context0->Global(); | 8772 v8::Handle<v8::Object> global0 = context0->Global(); |
| 8773 | 8773 |
| 8774 v8::HandleScope scope1(v8::Isolate::GetCurrent()); | 8774 v8::HandleScope scope1(CcTest::isolate()); |
| 8775 | 8775 |
| 8776 v8::Local<Context> context1 = Context::New(isolate); | 8776 v8::Local<Context> context1 = Context::New(isolate); |
| 8777 context1->Enter(); | 8777 context1->Enter(); |
| 8778 | 8778 |
| 8779 v8::Handle<v8::Object> global1 = context1->Global(); | 8779 v8::Handle<v8::Object> global1 = context1->Global(); |
| 8780 global1->Set(v8_str("other"), global0); | 8780 global1->Set(v8_str("other"), global0); |
| 8781 global1->Set(v8_str("object"), obj_template->NewInstance()); | 8781 global1->Set(v8_str("object"), obj_template->NewInstance()); |
| 8782 | 8782 |
| 8783 v8::Handle<Value> value; | 8783 v8::Handle<Value> value; |
| 8784 | 8784 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 8810 static void NamedPropertyEnumerator( | 8810 static void NamedPropertyEnumerator( |
| 8811 const v8::PropertyCallbackInfo<v8::Array>& info) { | 8811 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 8812 v8::Handle<v8::Array> result = v8::Array::New(2); | 8812 v8::Handle<v8::Array> result = v8::Array::New(2); |
| 8813 result->Set(0, v8_str("x")); | 8813 result->Set(0, v8_str("x")); |
| 8814 result->Set(1, v8::Object::New()); | 8814 result->Set(1, v8::Object::New()); |
| 8815 info.GetReturnValue().Set(result); | 8815 info.GetReturnValue().Set(result); |
| 8816 } | 8816 } |
| 8817 | 8817 |
| 8818 | 8818 |
| 8819 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { | 8819 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
| 8820 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 8820 v8::HandleScope handle_scope(CcTest::isolate()); |
| 8821 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 8821 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 8822 | 8822 |
| 8823 obj_template->Set(v8_str("7"), v8::Integer::New(7)); | 8823 obj_template->Set(v8_str("7"), v8::Integer::New(7)); |
| 8824 obj_template->Set(v8_str("x"), v8::Integer::New(42)); | 8824 obj_template->Set(v8_str("x"), v8::Integer::New(42)); |
| 8825 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, | 8825 obj_template->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, |
| 8826 IndexedPropertyEnumerator); | 8826 IndexedPropertyEnumerator); |
| 8827 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, | 8827 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, |
| 8828 NamedPropertyEnumerator); | 8828 NamedPropertyEnumerator); |
| 8829 | 8829 |
| 8830 LocalContext context; | 8830 LocalContext context; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8845 } | 8845 } |
| 8846 | 8846 |
| 8847 | 8847 |
| 8848 static void ConstTenGetter(Local<String> name, | 8848 static void ConstTenGetter(Local<String> name, |
| 8849 const v8::PropertyCallbackInfo<v8::Value>& info) { | 8849 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 8850 info.GetReturnValue().Set(v8_num(10)); | 8850 info.GetReturnValue().Set(v8_num(10)); |
| 8851 } | 8851 } |
| 8852 | 8852 |
| 8853 | 8853 |
| 8854 THREADED_TEST(CrossDomainAccessors) { | 8854 THREADED_TEST(CrossDomainAccessors) { |
| 8855 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 8855 v8::Isolate* isolate = CcTest::isolate(); |
| 8856 v8::HandleScope handle_scope(isolate); | 8856 v8::HandleScope handle_scope(isolate); |
| 8857 | 8857 |
| 8858 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 8858 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
| 8859 | 8859 |
| 8860 v8::Handle<v8::ObjectTemplate> global_template = | 8860 v8::Handle<v8::ObjectTemplate> global_template = |
| 8861 func_template->InstanceTemplate(); | 8861 func_template->InstanceTemplate(); |
| 8862 | 8862 |
| 8863 v8::Handle<v8::ObjectTemplate> proto_template = | 8863 v8::Handle<v8::ObjectTemplate> proto_template = |
| 8864 func_template->PrototypeTemplate(); | 8864 func_template->PrototypeTemplate(); |
| 8865 | 8865 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8876 v8::DEFAULT); | 8876 v8::DEFAULT); |
| 8877 | 8877 |
| 8878 v8::Local<Context> context0 = Context::New(isolate, NULL, global_template); | 8878 v8::Local<Context> context0 = Context::New(isolate, NULL, global_template); |
| 8879 context0->Enter(); | 8879 context0->Enter(); |
| 8880 | 8880 |
| 8881 Local<v8::Object> global = context0->Global(); | 8881 Local<v8::Object> global = context0->Global(); |
| 8882 // Add a normal property that shadows 'accessible' | 8882 // Add a normal property that shadows 'accessible' |
| 8883 global->Set(v8_str("accessible"), v8_num(11)); | 8883 global->Set(v8_str("accessible"), v8_num(11)); |
| 8884 | 8884 |
| 8885 // Enter a new context. | 8885 // Enter a new context. |
| 8886 v8::HandleScope scope1(v8::Isolate::GetCurrent()); | 8886 v8::HandleScope scope1(CcTest::isolate()); |
| 8887 v8::Local<Context> context1 = Context::New(isolate); | 8887 v8::Local<Context> context1 = Context::New(isolate); |
| 8888 context1->Enter(); | 8888 context1->Enter(); |
| 8889 | 8889 |
| 8890 v8::Handle<v8::Object> global1 = context1->Global(); | 8890 v8::Handle<v8::Object> global1 = context1->Global(); |
| 8891 global1->Set(v8_str("other"), global); | 8891 global1->Set(v8_str("other"), global); |
| 8892 | 8892 |
| 8893 // Should return 10, instead of 11 | 8893 // Should return 10, instead of 11 |
| 8894 v8::Handle<Value> value = v8_compile("other.accessible")->Run(); | 8894 v8::Handle<Value> value = v8_compile("other.accessible")->Run(); |
| 8895 CHECK(value->IsNumber()); | 8895 CHECK(value->IsNumber()); |
| 8896 CHECK_EQ(10, value->Int32Value()); | 8896 CHECK_EQ(10, value->Int32Value()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 8922 indexed_access_count++; | 8922 indexed_access_count++; |
| 8923 return true; | 8923 return true; |
| 8924 } | 8924 } |
| 8925 | 8925 |
| 8926 | 8926 |
| 8927 // This one is too easily disturbed by other tests. | 8927 // This one is too easily disturbed by other tests. |
| 8928 TEST(AccessControlIC) { | 8928 TEST(AccessControlIC) { |
| 8929 named_access_count = 0; | 8929 named_access_count = 0; |
| 8930 indexed_access_count = 0; | 8930 indexed_access_count = 0; |
| 8931 | 8931 |
| 8932 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 8932 v8::Isolate* isolate = CcTest::isolate(); |
| 8933 v8::HandleScope handle_scope(isolate); | 8933 v8::HandleScope handle_scope(isolate); |
| 8934 | 8934 |
| 8935 // Create an environment. | 8935 // Create an environment. |
| 8936 v8::Local<Context> context0 = Context::New(isolate); | 8936 v8::Local<Context> context0 = Context::New(isolate); |
| 8937 context0->Enter(); | 8937 context0->Enter(); |
| 8938 | 8938 |
| 8939 // Create an object that requires access-check functions to be | 8939 // Create an object that requires access-check functions to be |
| 8940 // called for cross-domain access. | 8940 // called for cross-domain access. |
| 8941 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 8941 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 8942 object_template->SetAccessCheckCallbacks(NamedAccessCounter, | 8942 object_template->SetAccessCheckCallbacks(NamedAccessCounter, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9070 | 9070 |
| 9071 // Regression test. In access checks, operations that may cause | 9071 // Regression test. In access checks, operations that may cause |
| 9072 // garbage collection are not allowed. It used to be the case that | 9072 // garbage collection are not allowed. It used to be the case that |
| 9073 // using the Write operation on a string could cause a garbage | 9073 // using the Write operation on a string could cause a garbage |
| 9074 // collection due to flattening of the string. This is no longer the | 9074 // collection due to flattening of the string. This is no longer the |
| 9075 // case. | 9075 // case. |
| 9076 THREADED_TEST(AccessControlFlatten) { | 9076 THREADED_TEST(AccessControlFlatten) { |
| 9077 named_access_count = 0; | 9077 named_access_count = 0; |
| 9078 indexed_access_count = 0; | 9078 indexed_access_count = 0; |
| 9079 | 9079 |
| 9080 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 9080 v8::Isolate* isolate = CcTest::isolate(); |
| 9081 v8::HandleScope handle_scope(isolate); | 9081 v8::HandleScope handle_scope(isolate); |
| 9082 | 9082 |
| 9083 // Create an environment. | 9083 // Create an environment. |
| 9084 v8::Local<Context> context0 = Context::New(isolate); | 9084 v8::Local<Context> context0 = Context::New(isolate); |
| 9085 context0->Enter(); | 9085 context0->Enter(); |
| 9086 | 9086 |
| 9087 // Create an object that requires access-check functions to be | 9087 // Create an object that requires access-check functions to be |
| 9088 // called for cross-domain access. | 9088 // called for cross-domain access. |
| 9089 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 9089 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 9090 object_template->SetAccessCheckCallbacks(NamedAccessFlatten, | 9090 object_template->SetAccessCheckCallbacks(NamedAccessFlatten, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9138 Local<Value> value, | 9138 Local<Value> value, |
| 9139 const v8::PropertyCallbackInfo<v8::Value>& info) { | 9139 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 9140 info.GetReturnValue().Set(value); | 9140 info.GetReturnValue().Set(value); |
| 9141 } | 9141 } |
| 9142 | 9142 |
| 9143 | 9143 |
| 9144 THREADED_TEST(AccessControlInterceptorIC) { | 9144 THREADED_TEST(AccessControlInterceptorIC) { |
| 9145 named_access_count = 0; | 9145 named_access_count = 0; |
| 9146 indexed_access_count = 0; | 9146 indexed_access_count = 0; |
| 9147 | 9147 |
| 9148 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 9148 v8::Isolate* isolate = CcTest::isolate(); |
| 9149 v8::HandleScope handle_scope(isolate); | 9149 v8::HandleScope handle_scope(isolate); |
| 9150 | 9150 |
| 9151 // Create an environment. | 9151 // Create an environment. |
| 9152 v8::Local<Context> context0 = Context::New(isolate); | 9152 v8::Local<Context> context0 = Context::New(isolate); |
| 9153 context0->Enter(); | 9153 context0->Enter(); |
| 9154 | 9154 |
| 9155 // Create an object that requires access-check functions to be | 9155 // Create an object that requires access-check functions to be |
| 9156 // called for cross-domain access. The object also has interceptors | 9156 // called for cross-domain access. The object also has interceptors |
| 9157 // interceptor. | 9157 // interceptor. |
| 9158 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 9158 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9242 | 9242 |
| 9243 | 9243 |
| 9244 static void GlobalObjectInstancePropertiesGet( | 9244 static void GlobalObjectInstancePropertiesGet( |
| 9245 Local<String> key, | 9245 Local<String> key, |
| 9246 const v8::PropertyCallbackInfo<v8::Value>&) { | 9246 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 9247 ApiTestFuzzer::Fuzz(); | 9247 ApiTestFuzzer::Fuzz(); |
| 9248 } | 9248 } |
| 9249 | 9249 |
| 9250 | 9250 |
| 9251 THREADED_TEST(GlobalObjectInstanceProperties) { | 9251 THREADED_TEST(GlobalObjectInstanceProperties) { |
| 9252 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 9252 v8::HandleScope handle_scope(CcTest::isolate()); |
| 9253 | 9253 |
| 9254 Local<Value> global_object; | 9254 Local<Value> global_object; |
| 9255 | 9255 |
| 9256 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9256 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
| 9257 t->InstanceTemplate()->SetNamedPropertyHandler( | 9257 t->InstanceTemplate()->SetNamedPropertyHandler( |
| 9258 GlobalObjectInstancePropertiesGet); | 9258 GlobalObjectInstancePropertiesGet); |
| 9259 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 9259 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 9260 instance_template->Set(v8_str("x"), v8_num(42)); | 9260 instance_template->Set(v8_str("x"), v8_num(42)); |
| 9261 instance_template->Set(v8_str("f"), | 9261 instance_template->Set(v8_str("f"), |
| 9262 v8::FunctionTemplate::New(InstanceFunctionCallback)); | 9262 v8::FunctionTemplate::New(InstanceFunctionCallback)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9298 CHECK_EQ(42, value->Int32Value()); | 9298 CHECK_EQ(42, value->Int32Value()); |
| 9299 value = Script::Compile(v8_str("f()"))->Run(); | 9299 value = Script::Compile(v8_str("f()"))->Run(); |
| 9300 CHECK_EQ(12, value->Int32Value()); | 9300 CHECK_EQ(12, value->Int32Value()); |
| 9301 value = Script::Compile(v8_str(script))->Run(); | 9301 value = Script::Compile(v8_str(script))->Run(); |
| 9302 CHECK_EQ(1, value->Int32Value()); | 9302 CHECK_EQ(1, value->Int32Value()); |
| 9303 } | 9303 } |
| 9304 } | 9304 } |
| 9305 | 9305 |
| 9306 | 9306 |
| 9307 THREADED_TEST(CallKnownGlobalReceiver) { | 9307 THREADED_TEST(CallKnownGlobalReceiver) { |
| 9308 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 9308 v8::HandleScope handle_scope(CcTest::isolate()); |
| 9309 | 9309 |
| 9310 Local<Value> global_object; | 9310 Local<Value> global_object; |
| 9311 | 9311 |
| 9312 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9312 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
| 9313 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 9313 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
| 9314 | 9314 |
| 9315 // The script to check that we leave global object not | 9315 // The script to check that we leave global object not |
| 9316 // global object proxy on stack when we deoptimize from inside | 9316 // global object proxy on stack when we deoptimize from inside |
| 9317 // arguments evaluation. | 9317 // arguments evaluation. |
| 9318 // To provoke error we need to both force deoptimization | 9318 // To provoke error we need to both force deoptimization |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9377 } | 9377 } |
| 9378 | 9378 |
| 9379 | 9379 |
| 9380 static void ShadowNamedGet(Local<String> key, | 9380 static void ShadowNamedGet(Local<String> key, |
| 9381 const v8::PropertyCallbackInfo<v8::Value>&) { | 9381 const v8::PropertyCallbackInfo<v8::Value>&) { |
| 9382 } | 9382 } |
| 9383 | 9383 |
| 9384 | 9384 |
| 9385 THREADED_TEST(ShadowObject) { | 9385 THREADED_TEST(ShadowObject) { |
| 9386 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; | 9386 shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0; |
| 9387 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 9387 v8::HandleScope handle_scope(CcTest::isolate()); |
| 9388 | 9388 |
| 9389 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 9389 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 9390 LocalContext context(NULL, global_template); | 9390 LocalContext context(NULL, global_template); |
| 9391 | 9391 |
| 9392 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 9392 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
| 9393 t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet); | 9393 t->InstanceTemplate()->SetNamedPropertyHandler(ShadowNamedGet); |
| 9394 t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet); | 9394 t->InstanceTemplate()->SetIndexedPropertyHandler(ShadowIndexedGet); |
| 9395 Local<ObjectTemplate> proto = t->PrototypeTemplate(); | 9395 Local<ObjectTemplate> proto = t->PrototypeTemplate(); |
| 9396 Local<ObjectTemplate> instance = t->InstanceTemplate(); | 9396 Local<ObjectTemplate> instance = t->InstanceTemplate(); |
| 9397 | 9397 |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9998 "result4 = f(this)")); | 9998 "result4 = f(this)")); |
| 9999 script->Run(); | 9999 script->Run(); |
| 10000 CHECK(!try_catch.HasCaught()); | 10000 CHECK(!try_catch.HasCaught()); |
| 10001 CHECK_EQ(2, current->Global()->Get(v8_str("result4"))->Int32Value()); | 10001 CHECK_EQ(2, current->Global()->Get(v8_str("result4"))->Int32Value()); |
| 10002 | 10002 |
| 10003 try_catch.Reset(); | 10003 try_catch.Reset(); |
| 10004 } | 10004 } |
| 10005 | 10005 |
| 10006 | 10006 |
| 10007 THREADED_TEST(CrossEval) { | 10007 THREADED_TEST(CrossEval) { |
| 10008 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10008 v8::HandleScope scope(CcTest::isolate()); |
| 10009 LocalContext other; | 10009 LocalContext other; |
| 10010 LocalContext current; | 10010 LocalContext current; |
| 10011 | 10011 |
| 10012 Local<String> token = v8_str("<security token>"); | 10012 Local<String> token = v8_str("<security token>"); |
| 10013 other->SetSecurityToken(token); | 10013 other->SetSecurityToken(token); |
| 10014 current->SetSecurityToken(token); | 10014 current->SetSecurityToken(token); |
| 10015 | 10015 |
| 10016 // Set up reference from current to other. | 10016 // Set up reference from current to other. |
| 10017 current->Global()->Set(v8_str("other"), other->Global()); | 10017 current->Global()->Set(v8_str("other"), other->Global()); |
| 10018 | 10018 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10081 Script::Compile(v8_str("other.y = 1; eval.call(other, 'y')")); | 10081 Script::Compile(v8_str("other.y = 1; eval.call(other, 'y')")); |
| 10082 result = script->Run(); | 10082 result = script->Run(); |
| 10083 CHECK(try_catch.HasCaught()); | 10083 CHECK(try_catch.HasCaught()); |
| 10084 } | 10084 } |
| 10085 | 10085 |
| 10086 | 10086 |
| 10087 // Test that calling eval in a context which has been detached from | 10087 // Test that calling eval in a context which has been detached from |
| 10088 // its global throws an exception. This behavior is consistent with | 10088 // its global throws an exception. This behavior is consistent with |
| 10089 // other JavaScript implementations. | 10089 // other JavaScript implementations. |
| 10090 THREADED_TEST(EvalInDetachedGlobal) { | 10090 THREADED_TEST(EvalInDetachedGlobal) { |
| 10091 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 10091 v8::Isolate* isolate = CcTest::isolate(); |
| 10092 v8::HandleScope scope(isolate); | 10092 v8::HandleScope scope(isolate); |
| 10093 | 10093 |
| 10094 v8::Local<Context> context0 = Context::New(isolate); | 10094 v8::Local<Context> context0 = Context::New(isolate); |
| 10095 v8::Local<Context> context1 = Context::New(isolate); | 10095 v8::Local<Context> context1 = Context::New(isolate); |
| 10096 | 10096 |
| 10097 // Set up function in context0 that uses eval from context0. | 10097 // Set up function in context0 that uses eval from context0. |
| 10098 context0->Enter(); | 10098 context0->Enter(); |
| 10099 v8::Handle<v8::Value> fun = | 10099 v8::Handle<v8::Value> fun = |
| 10100 CompileRun("var x = 42;" | 10100 CompileRun("var x = 42;" |
| 10101 "(function() {" | 10101 "(function() {" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10114 context0->DetachGlobal(); | 10114 context0->DetachGlobal(); |
| 10115 v8::TryCatch catcher; | 10115 v8::TryCatch catcher; |
| 10116 x_value = CompileRun("fun('x')"); | 10116 x_value = CompileRun("fun('x')"); |
| 10117 CHECK(x_value.IsEmpty()); | 10117 CHECK(x_value.IsEmpty()); |
| 10118 CHECK(catcher.HasCaught()); | 10118 CHECK(catcher.HasCaught()); |
| 10119 context1->Exit(); | 10119 context1->Exit(); |
| 10120 } | 10120 } |
| 10121 | 10121 |
| 10122 | 10122 |
| 10123 THREADED_TEST(CrossLazyLoad) { | 10123 THREADED_TEST(CrossLazyLoad) { |
| 10124 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10124 v8::HandleScope scope(CcTest::isolate()); |
| 10125 LocalContext other; | 10125 LocalContext other; |
| 10126 LocalContext current; | 10126 LocalContext current; |
| 10127 | 10127 |
| 10128 Local<String> token = v8_str("<security token>"); | 10128 Local<String> token = v8_str("<security token>"); |
| 10129 other->SetSecurityToken(token); | 10129 other->SetSecurityToken(token); |
| 10130 current->SetSecurityToken(token); | 10130 current->SetSecurityToken(token); |
| 10131 | 10131 |
| 10132 // Set up reference from current to other. | 10132 // Set up reference from current to other. |
| 10133 current->Global()->Set(v8_str("other"), other->Global()); | 10133 current->Global()->Set(v8_str("other"), other->Global()); |
| 10134 | 10134 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10310 } | 10310 } |
| 10311 } | 10311 } |
| 10312 | 10312 |
| 10313 | 10313 |
| 10314 static int CountHandles() { | 10314 static int CountHandles() { |
| 10315 return v8::HandleScope::NumberOfHandles(); | 10315 return v8::HandleScope::NumberOfHandles(); |
| 10316 } | 10316 } |
| 10317 | 10317 |
| 10318 | 10318 |
| 10319 static int Recurse(int depth, int iterations) { | 10319 static int Recurse(int depth, int iterations) { |
| 10320 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10320 v8::HandleScope scope(CcTest::isolate()); |
| 10321 if (depth == 0) return CountHandles(); | 10321 if (depth == 0) return CountHandles(); |
| 10322 for (int i = 0; i < iterations; i++) { | 10322 for (int i = 0; i < iterations; i++) { |
| 10323 Local<v8::Number> n(v8::Integer::New(42)); | 10323 Local<v8::Number> n(v8::Integer::New(42)); |
| 10324 } | 10324 } |
| 10325 return Recurse(depth - 1, iterations); | 10325 return Recurse(depth - 1, iterations); |
| 10326 } | 10326 } |
| 10327 | 10327 |
| 10328 | 10328 |
| 10329 THREADED_TEST(HandleIteration) { | 10329 THREADED_TEST(HandleIteration) { |
| 10330 static const int kIterations = 500; | 10330 static const int kIterations = 500; |
| 10331 static const int kNesting = 200; | 10331 static const int kNesting = 200; |
| 10332 CHECK_EQ(0, CountHandles()); | 10332 CHECK_EQ(0, CountHandles()); |
| 10333 { | 10333 { |
| 10334 v8::HandleScope scope1(v8::Isolate::GetCurrent()); | 10334 v8::HandleScope scope1(CcTest::isolate()); |
| 10335 CHECK_EQ(0, CountHandles()); | 10335 CHECK_EQ(0, CountHandles()); |
| 10336 for (int i = 0; i < kIterations; i++) { | 10336 for (int i = 0; i < kIterations; i++) { |
| 10337 Local<v8::Number> n(v8::Integer::New(42)); | 10337 Local<v8::Number> n(v8::Integer::New(42)); |
| 10338 CHECK_EQ(i + 1, CountHandles()); | 10338 CHECK_EQ(i + 1, CountHandles()); |
| 10339 } | 10339 } |
| 10340 | 10340 |
| 10341 CHECK_EQ(kIterations, CountHandles()); | 10341 CHECK_EQ(kIterations, CountHandles()); |
| 10342 { | 10342 { |
| 10343 v8::HandleScope scope2(v8::Isolate::GetCurrent()); | 10343 v8::HandleScope scope2(CcTest::isolate()); |
| 10344 for (int j = 0; j < kIterations; j++) { | 10344 for (int j = 0; j < kIterations; j++) { |
| 10345 Local<v8::Number> n(v8::Integer::New(42)); | 10345 Local<v8::Number> n(v8::Integer::New(42)); |
| 10346 CHECK_EQ(j + 1 + kIterations, CountHandles()); | 10346 CHECK_EQ(j + 1 + kIterations, CountHandles()); |
| 10347 } | 10347 } |
| 10348 } | 10348 } |
| 10349 CHECK_EQ(kIterations, CountHandles()); | 10349 CHECK_EQ(kIterations, CountHandles()); |
| 10350 } | 10350 } |
| 10351 CHECK_EQ(0, CountHandles()); | 10351 CHECK_EQ(0, CountHandles()); |
| 10352 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); | 10352 CHECK_EQ(kNesting * kIterations, Recurse(kNesting, kIterations)); |
| 10353 } | 10353 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10421 | 10421 |
| 10422 | 10422 |
| 10423 typedef void (*NamedPropertyGetter)( | 10423 typedef void (*NamedPropertyGetter)( |
| 10424 Local<String> property, | 10424 Local<String> property, |
| 10425 const v8::PropertyCallbackInfo<v8::Value>& info); | 10425 const v8::PropertyCallbackInfo<v8::Value>& info); |
| 10426 | 10426 |
| 10427 | 10427 |
| 10428 static void CheckInterceptorLoadIC(NamedPropertyGetter getter, | 10428 static void CheckInterceptorLoadIC(NamedPropertyGetter getter, |
| 10429 const char* source, | 10429 const char* source, |
| 10430 int expected) { | 10430 int expected) { |
| 10431 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10431 v8::HandleScope scope(CcTest::isolate()); |
| 10432 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10432 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10433 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); | 10433 templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data")); |
| 10434 LocalContext context; | 10434 LocalContext context; |
| 10435 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10435 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10436 v8::Handle<Value> value = CompileRun(source); | 10436 v8::Handle<Value> value = CompileRun(source); |
| 10437 CHECK_EQ(expected, value->Int32Value()); | 10437 CHECK_EQ(expected, value->Int32Value()); |
| 10438 } | 10438 } |
| 10439 | 10439 |
| 10440 | 10440 |
| 10441 static void InterceptorLoadICGetter( | 10441 static void InterceptorLoadICGetter( |
| 10442 Local<String> name, | 10442 Local<String> name, |
| 10443 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10443 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10444 ApiTestFuzzer::Fuzz(); | 10444 ApiTestFuzzer::Fuzz(); |
| 10445 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 10445 v8::Isolate* isolate = CcTest::isolate(); |
| 10446 CHECK_EQ(isolate, info.GetIsolate()); | 10446 CHECK_EQ(isolate, info.GetIsolate()); |
| 10447 CHECK_EQ(v8_str("data"), info.Data()); | 10447 CHECK_EQ(v8_str("data"), info.Data()); |
| 10448 CHECK_EQ(v8_str("x"), name); | 10448 CHECK_EQ(v8_str("x"), name); |
| 10449 info.GetReturnValue().Set(v8::Integer::New(42)); | 10449 info.GetReturnValue().Set(v8::Integer::New(42)); |
| 10450 } | 10450 } |
| 10451 | 10451 |
| 10452 | 10452 |
| 10453 // This test should hit the load IC for the interceptor case. | 10453 // This test should hit the load IC for the interceptor case. |
| 10454 THREADED_TEST(InterceptorLoadIC) { | 10454 THREADED_TEST(InterceptorLoadIC) { |
| 10455 CheckInterceptorLoadIC(InterceptorLoadICGetter, | 10455 CheckInterceptorLoadIC(InterceptorLoadICGetter, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10634 | 10634 |
| 10635 | 10635 |
| 10636 static void SetOnThis(Local<String> name, | 10636 static void SetOnThis(Local<String> name, |
| 10637 Local<Value> value, | 10637 Local<Value> value, |
| 10638 const v8::PropertyCallbackInfo<void>& info) { | 10638 const v8::PropertyCallbackInfo<void>& info) { |
| 10639 info.This()->ForceSet(name, value); | 10639 info.This()->ForceSet(name, value); |
| 10640 } | 10640 } |
| 10641 | 10641 |
| 10642 | 10642 |
| 10643 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) { | 10643 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) { |
| 10644 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10644 v8::HandleScope scope(CcTest::isolate()); |
| 10645 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10645 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10646 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10646 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10647 templ->SetAccessor(v8_str("y"), Return239Callback); | 10647 templ->SetAccessor(v8_str("y"), Return239Callback); |
| 10648 LocalContext context; | 10648 LocalContext context; |
| 10649 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10649 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10650 | 10650 |
| 10651 // Check the case when receiver and interceptor's holder | 10651 // Check the case when receiver and interceptor's holder |
| 10652 // are the same objects. | 10652 // are the same objects. |
| 10653 v8::Handle<Value> value = CompileRun( | 10653 v8::Handle<Value> value = CompileRun( |
| 10654 "var result = 0;" | 10654 "var result = 0;" |
| 10655 "for (var i = 0; i < 7; i++) {" | 10655 "for (var i = 0; i < 7; i++) {" |
| 10656 " result = o.y;" | 10656 " result = o.y;" |
| 10657 "}"); | 10657 "}"); |
| 10658 CHECK_EQ(239, value->Int32Value()); | 10658 CHECK_EQ(239, value->Int32Value()); |
| 10659 | 10659 |
| 10660 // Check the case when interceptor's holder is in proto chain | 10660 // Check the case when interceptor's holder is in proto chain |
| 10661 // of receiver. | 10661 // of receiver. |
| 10662 value = CompileRun( | 10662 value = CompileRun( |
| 10663 "r = { __proto__: o };" | 10663 "r = { __proto__: o };" |
| 10664 "var result = 0;" | 10664 "var result = 0;" |
| 10665 "for (var i = 0; i < 7; i++) {" | 10665 "for (var i = 0; i < 7; i++) {" |
| 10666 " result = r.y;" | 10666 " result = r.y;" |
| 10667 "}"); | 10667 "}"); |
| 10668 CHECK_EQ(239, value->Int32Value()); | 10668 CHECK_EQ(239, value->Int32Value()); |
| 10669 } | 10669 } |
| 10670 | 10670 |
| 10671 | 10671 |
| 10672 THREADED_TEST(InterceptorLoadICWithCallbackOnProto) { | 10672 THREADED_TEST(InterceptorLoadICWithCallbackOnProto) { |
| 10673 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10673 v8::HandleScope scope(CcTest::isolate()); |
| 10674 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10674 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10675 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10675 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10676 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10676 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10677 templ_p->SetAccessor(v8_str("y"), Return239Callback); | 10677 templ_p->SetAccessor(v8_str("y"), Return239Callback); |
| 10678 | 10678 |
| 10679 LocalContext context; | 10679 LocalContext context; |
| 10680 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10680 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10681 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10681 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10682 | 10682 |
| 10683 // Check the case when receiver and interceptor's holder | 10683 // Check the case when receiver and interceptor's holder |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10696 "r = { __proto__: o };" | 10696 "r = { __proto__: o };" |
| 10697 "var result = 0;" | 10697 "var result = 0;" |
| 10698 "for (var i = 0; i < 7; i++) {" | 10698 "for (var i = 0; i < 7; i++) {" |
| 10699 " result = r.x + r.y;" | 10699 " result = r.x + r.y;" |
| 10700 "}"); | 10700 "}"); |
| 10701 CHECK_EQ(239 + 42, value->Int32Value()); | 10701 CHECK_EQ(239 + 42, value->Int32Value()); |
| 10702 } | 10702 } |
| 10703 | 10703 |
| 10704 | 10704 |
| 10705 THREADED_TEST(InterceptorLoadICForCallbackWithOverride) { | 10705 THREADED_TEST(InterceptorLoadICForCallbackWithOverride) { |
| 10706 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10706 v8::HandleScope scope(CcTest::isolate()); |
| 10707 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10707 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10708 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10708 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10709 templ->SetAccessor(v8_str("y"), Return239Callback); | 10709 templ->SetAccessor(v8_str("y"), Return239Callback); |
| 10710 | 10710 |
| 10711 LocalContext context; | 10711 LocalContext context; |
| 10712 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10712 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10713 | 10713 |
| 10714 v8::Handle<Value> value = CompileRun( | 10714 v8::Handle<Value> value = CompileRun( |
| 10715 "fst = new Object(); fst.__proto__ = o;" | 10715 "fst = new Object(); fst.__proto__ = o;" |
| 10716 "snd = new Object(); snd.__proto__ = fst;" | 10716 "snd = new Object(); snd.__proto__ = fst;" |
| 10717 "var result1 = 0;" | 10717 "var result1 = 0;" |
| 10718 "for (var i = 0; i < 7; i++) {" | 10718 "for (var i = 0; i < 7; i++) {" |
| 10719 " result1 = snd.x;" | 10719 " result1 = snd.x;" |
| 10720 "}" | 10720 "}" |
| 10721 "fst.x = 239;" | 10721 "fst.x = 239;" |
| 10722 "var result = 0;" | 10722 "var result = 0;" |
| 10723 "for (var i = 0; i < 7; i++) {" | 10723 "for (var i = 0; i < 7; i++) {" |
| 10724 " result = snd.x;" | 10724 " result = snd.x;" |
| 10725 "}" | 10725 "}" |
| 10726 "result + result1"); | 10726 "result + result1"); |
| 10727 CHECK_EQ(239 + 42, value->Int32Value()); | 10727 CHECK_EQ(239 + 42, value->Int32Value()); |
| 10728 } | 10728 } |
| 10729 | 10729 |
| 10730 | 10730 |
| 10731 // Test the case when we stored callback into | 10731 // Test the case when we stored callback into |
| 10732 // a stub, but interceptor produced value on its own. | 10732 // a stub, but interceptor produced value on its own. |
| 10733 THREADED_TEST(InterceptorLoadICCallbackNotNeeded) { | 10733 THREADED_TEST(InterceptorLoadICCallbackNotNeeded) { |
| 10734 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10734 v8::HandleScope scope(CcTest::isolate()); |
| 10735 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10735 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10736 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10736 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10737 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10737 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10738 templ_p->SetAccessor(v8_str("y"), Return239Callback); | 10738 templ_p->SetAccessor(v8_str("y"), Return239Callback); |
| 10739 | 10739 |
| 10740 LocalContext context; | 10740 LocalContext context; |
| 10741 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10741 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10742 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10742 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10743 | 10743 |
| 10744 v8::Handle<Value> value = CompileRun( | 10744 v8::Handle<Value> value = CompileRun( |
| 10745 "o.__proto__ = p;" | 10745 "o.__proto__ = p;" |
| 10746 "for (var i = 0; i < 7; i++) {" | 10746 "for (var i = 0; i < 7; i++) {" |
| 10747 " o.x;" | 10747 " o.x;" |
| 10748 // Now it should be ICed and keep a reference to x defined on p | 10748 // Now it should be ICed and keep a reference to x defined on p |
| 10749 "}" | 10749 "}" |
| 10750 "var result = 0;" | 10750 "var result = 0;" |
| 10751 "for (var i = 0; i < 7; i++) {" | 10751 "for (var i = 0; i < 7; i++) {" |
| 10752 " result += o.x;" | 10752 " result += o.x;" |
| 10753 "}" | 10753 "}" |
| 10754 "result"); | 10754 "result"); |
| 10755 CHECK_EQ(42 * 7, value->Int32Value()); | 10755 CHECK_EQ(42 * 7, value->Int32Value()); |
| 10756 } | 10756 } |
| 10757 | 10757 |
| 10758 | 10758 |
| 10759 // Test the case when we stored callback into | 10759 // Test the case when we stored callback into |
| 10760 // a stub, but it got invalidated later on. | 10760 // a stub, but it got invalidated later on. |
| 10761 THREADED_TEST(InterceptorLoadICInvalidatedCallback) { | 10761 THREADED_TEST(InterceptorLoadICInvalidatedCallback) { |
| 10762 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10762 v8::HandleScope scope(CcTest::isolate()); |
| 10763 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10763 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10764 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10764 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10765 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10765 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10766 templ_p->SetAccessor(v8_str("y"), Return239Callback, SetOnThis); | 10766 templ_p->SetAccessor(v8_str("y"), Return239Callback, SetOnThis); |
| 10767 | 10767 |
| 10768 LocalContext context; | 10768 LocalContext context; |
| 10769 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10769 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10770 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10770 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10771 | 10771 |
| 10772 v8::Handle<Value> value = CompileRun( | 10772 v8::Handle<Value> value = CompileRun( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 10784 "}" | 10784 "}" |
| 10785 "result"); | 10785 "result"); |
| 10786 CHECK_EQ(42 * 10, value->Int32Value()); | 10786 CHECK_EQ(42 * 10, value->Int32Value()); |
| 10787 } | 10787 } |
| 10788 | 10788 |
| 10789 | 10789 |
| 10790 // Test the case when we stored callback into | 10790 // Test the case when we stored callback into |
| 10791 // a stub, but it got invalidated later on due to override on | 10791 // a stub, but it got invalidated later on due to override on |
| 10792 // global object which is between interceptor and callbacks' holders. | 10792 // global object which is between interceptor and callbacks' holders. |
| 10793 THREADED_TEST(InterceptorLoadICInvalidatedCallbackViaGlobal) { | 10793 THREADED_TEST(InterceptorLoadICInvalidatedCallbackViaGlobal) { |
| 10794 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10794 v8::HandleScope scope(CcTest::isolate()); |
| 10795 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 10795 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 10796 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10796 templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10797 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); | 10797 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New(); |
| 10798 templ_p->SetAccessor(v8_str("y"), Return239Callback, SetOnThis); | 10798 templ_p->SetAccessor(v8_str("y"), Return239Callback, SetOnThis); |
| 10799 | 10799 |
| 10800 LocalContext context; | 10800 LocalContext context; |
| 10801 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 10801 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 10802 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); | 10802 context->Global()->Set(v8_str("p"), templ_p->NewInstance()); |
| 10803 | 10803 |
| 10804 v8::Handle<Value> value = CompileRun( | 10804 v8::Handle<Value> value = CompileRun( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10839 Local<Value> value, | 10839 Local<Value> value, |
| 10840 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10840 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10841 CHECK(v8_str("x")->Equals(key)); | 10841 CHECK(v8_str("x")->Equals(key)); |
| 10842 CHECK_EQ(42, value->Int32Value()); | 10842 CHECK_EQ(42, value->Int32Value()); |
| 10843 info.GetReturnValue().Set(value); | 10843 info.GetReturnValue().Set(value); |
| 10844 } | 10844 } |
| 10845 | 10845 |
| 10846 | 10846 |
| 10847 // This test should hit the store IC for the interceptor case. | 10847 // This test should hit the store IC for the interceptor case. |
| 10848 THREADED_TEST(InterceptorStoreIC) { | 10848 THREADED_TEST(InterceptorStoreIC) { |
| 10849 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10849 v8::HandleScope scope(CcTest::isolate()); |
| 10850 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10850 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10851 templ->SetNamedPropertyHandler(InterceptorLoadICGetter, | 10851 templ->SetNamedPropertyHandler(InterceptorLoadICGetter, |
| 10852 InterceptorStoreICSetter, | 10852 InterceptorStoreICSetter, |
| 10853 0, 0, 0, v8_str("data")); | 10853 0, 0, 0, v8_str("data")); |
| 10854 LocalContext context; | 10854 LocalContext context; |
| 10855 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10855 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10856 CompileRun( | 10856 CompileRun( |
| 10857 "for (var i = 0; i < 1000; i++) {" | 10857 "for (var i = 0; i < 1000; i++) {" |
| 10858 " o.x = 42;" | 10858 " o.x = 42;" |
| 10859 "}"); | 10859 "}"); |
| 10860 } | 10860 } |
| 10861 | 10861 |
| 10862 | 10862 |
| 10863 THREADED_TEST(InterceptorStoreICWithNoSetter) { | 10863 THREADED_TEST(InterceptorStoreICWithNoSetter) { |
| 10864 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10864 v8::HandleScope scope(CcTest::isolate()); |
| 10865 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10865 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10866 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 10866 templ->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 10867 LocalContext context; | 10867 LocalContext context; |
| 10868 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10868 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10869 v8::Handle<Value> value = CompileRun( | 10869 v8::Handle<Value> value = CompileRun( |
| 10870 "for (var i = 0; i < 1000; i++) {" | 10870 "for (var i = 0; i < 1000; i++) {" |
| 10871 " o.y = 239;" | 10871 " o.y = 239;" |
| 10872 "}" | 10872 "}" |
| 10873 "42 + o.y"); | 10873 "42 + o.y"); |
| 10874 CHECK_EQ(239 + 42, value->Int32Value()); | 10874 CHECK_EQ(239 + 42, value->Int32Value()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 10885 Local<String> name, | 10885 Local<String> name, |
| 10886 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10886 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10887 ApiTestFuzzer::Fuzz(); | 10887 ApiTestFuzzer::Fuzz(); |
| 10888 CHECK(v8_str("x")->Equals(name)); | 10888 CHECK(v8_str("x")->Equals(name)); |
| 10889 info.GetReturnValue().Set(call_ic_function); | 10889 info.GetReturnValue().Set(call_ic_function); |
| 10890 } | 10890 } |
| 10891 | 10891 |
| 10892 | 10892 |
| 10893 // This test should hit the call IC for the interceptor case. | 10893 // This test should hit the call IC for the interceptor case. |
| 10894 THREADED_TEST(InterceptorCallIC) { | 10894 THREADED_TEST(InterceptorCallIC) { |
| 10895 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10895 v8::HandleScope scope(CcTest::isolate()); |
| 10896 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10896 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10897 templ->SetNamedPropertyHandler(InterceptorCallICGetter); | 10897 templ->SetNamedPropertyHandler(InterceptorCallICGetter); |
| 10898 LocalContext context; | 10898 LocalContext context; |
| 10899 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10899 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10900 call_ic_function = | 10900 call_ic_function = |
| 10901 v8_compile("function f(x) { return x + 1; }; f")->Run(); | 10901 v8_compile("function f(x) { return x + 1; }; f")->Run(); |
| 10902 v8::Handle<Value> value = CompileRun( | 10902 v8::Handle<Value> value = CompileRun( |
| 10903 "var result = 0;" | 10903 "var result = 0;" |
| 10904 "for (var i = 0; i < 1000; i++) {" | 10904 "for (var i = 0; i < 1000; i++) {" |
| 10905 " result = o.x(41);" | 10905 " result = o.x(41);" |
| 10906 "}"); | 10906 "}"); |
| 10907 CHECK_EQ(42, value->Int32Value()); | 10907 CHECK_EQ(42, value->Int32Value()); |
| 10908 } | 10908 } |
| 10909 | 10909 |
| 10910 | 10910 |
| 10911 // This test checks that if interceptor doesn't provide | 10911 // This test checks that if interceptor doesn't provide |
| 10912 // a value, we can fetch regular value. | 10912 // a value, we can fetch regular value. |
| 10913 THREADED_TEST(InterceptorCallICSeesOthers) { | 10913 THREADED_TEST(InterceptorCallICSeesOthers) { |
| 10914 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10914 v8::HandleScope scope(CcTest::isolate()); |
| 10915 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10915 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10916 templ->SetNamedPropertyHandler(NoBlockGetterX); | 10916 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 10917 LocalContext context; | 10917 LocalContext context; |
| 10918 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10918 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10919 v8::Handle<Value> value = CompileRun( | 10919 v8::Handle<Value> value = CompileRun( |
| 10920 "o.x = function f(x) { return x + 1; };" | 10920 "o.x = function f(x) { return x + 1; };" |
| 10921 "var result = 0;" | 10921 "var result = 0;" |
| 10922 "for (var i = 0; i < 7; i++) {" | 10922 "for (var i = 0; i < 7; i++) {" |
| 10923 " result = o.x(41);" | 10923 " result = o.x(41);" |
| 10924 "}"); | 10924 "}"); |
| 10925 CHECK_EQ(42, value->Int32Value()); | 10925 CHECK_EQ(42, value->Int32Value()); |
| 10926 } | 10926 } |
| 10927 | 10927 |
| 10928 | 10928 |
| 10929 static v8::Handle<Value> call_ic_function4; | 10929 static v8::Handle<Value> call_ic_function4; |
| 10930 static void InterceptorCallICGetter4( | 10930 static void InterceptorCallICGetter4( |
| 10931 Local<String> name, | 10931 Local<String> name, |
| 10932 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10932 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 10933 ApiTestFuzzer::Fuzz(); | 10933 ApiTestFuzzer::Fuzz(); |
| 10934 CHECK(v8_str("x")->Equals(name)); | 10934 CHECK(v8_str("x")->Equals(name)); |
| 10935 info.GetReturnValue().Set(call_ic_function4); | 10935 info.GetReturnValue().Set(call_ic_function4); |
| 10936 } | 10936 } |
| 10937 | 10937 |
| 10938 | 10938 |
| 10939 // This test checks that if interceptor provides a function, | 10939 // This test checks that if interceptor provides a function, |
| 10940 // even if we cached shadowed variant, interceptor's function | 10940 // even if we cached shadowed variant, interceptor's function |
| 10941 // is invoked | 10941 // is invoked |
| 10942 THREADED_TEST(InterceptorCallICCacheableNotNeeded) { | 10942 THREADED_TEST(InterceptorCallICCacheableNotNeeded) { |
| 10943 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10943 v8::HandleScope scope(CcTest::isolate()); |
| 10944 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10944 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10945 templ->SetNamedPropertyHandler(InterceptorCallICGetter4); | 10945 templ->SetNamedPropertyHandler(InterceptorCallICGetter4); |
| 10946 LocalContext context; | 10946 LocalContext context; |
| 10947 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10947 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10948 call_ic_function4 = | 10948 call_ic_function4 = |
| 10949 v8_compile("function f(x) { return x - 1; }; f")->Run(); | 10949 v8_compile("function f(x) { return x - 1; }; f")->Run(); |
| 10950 v8::Handle<Value> value = CompileRun( | 10950 v8::Handle<Value> value = CompileRun( |
| 10951 "Object.getPrototypeOf(o).x = function(x) { return x + 1; };" | 10951 "Object.getPrototypeOf(o).x = function(x) { return x + 1; };" |
| 10952 "var result = 0;" | 10952 "var result = 0;" |
| 10953 "for (var i = 0; i < 1000; i++) {" | 10953 "for (var i = 0; i < 1000; i++) {" |
| 10954 " result = o.x(42);" | 10954 " result = o.x(42);" |
| 10955 "}"); | 10955 "}"); |
| 10956 CHECK_EQ(41, value->Int32Value()); | 10956 CHECK_EQ(41, value->Int32Value()); |
| 10957 } | 10957 } |
| 10958 | 10958 |
| 10959 | 10959 |
| 10960 // Test the case when we stored cacheable lookup into | 10960 // Test the case when we stored cacheable lookup into |
| 10961 // a stub, but it got invalidated later on | 10961 // a stub, but it got invalidated later on |
| 10962 THREADED_TEST(InterceptorCallICInvalidatedCacheable) { | 10962 THREADED_TEST(InterceptorCallICInvalidatedCacheable) { |
| 10963 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10963 v8::HandleScope scope(CcTest::isolate()); |
| 10964 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10964 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10965 templ->SetNamedPropertyHandler(NoBlockGetterX); | 10965 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 10966 LocalContext context; | 10966 LocalContext context; |
| 10967 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10967 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10968 v8::Handle<Value> value = CompileRun( | 10968 v8::Handle<Value> value = CompileRun( |
| 10969 "proto1 = new Object();" | 10969 "proto1 = new Object();" |
| 10970 "proto2 = new Object();" | 10970 "proto2 = new Object();" |
| 10971 "o.__proto__ = proto1;" | 10971 "o.__proto__ = proto1;" |
| 10972 "proto1.__proto__ = proto2;" | 10972 "proto1.__proto__ = proto2;" |
| 10973 "proto2.y = function(x) { return x + 1; };" | 10973 "proto2.y = function(x) { return x + 1; };" |
| 10974 // Invoke it many times to compile a stub | 10974 // Invoke it many times to compile a stub |
| 10975 "for (var i = 0; i < 7; i++) {" | 10975 "for (var i = 0; i < 7; i++) {" |
| 10976 " o.y(42);" | 10976 " o.y(42);" |
| 10977 "}" | 10977 "}" |
| 10978 "proto1.y = function(x) { return x - 1; };" | 10978 "proto1.y = function(x) { return x - 1; };" |
| 10979 "var result = 0;" | 10979 "var result = 0;" |
| 10980 "for (var i = 0; i < 7; i++) {" | 10980 "for (var i = 0; i < 7; i++) {" |
| 10981 " result += o.y(42);" | 10981 " result += o.y(42);" |
| 10982 "}"); | 10982 "}"); |
| 10983 CHECK_EQ(41 * 7, value->Int32Value()); | 10983 CHECK_EQ(41 * 7, value->Int32Value()); |
| 10984 } | 10984 } |
| 10985 | 10985 |
| 10986 | 10986 |
| 10987 // This test checks that if interceptor doesn't provide a function, | 10987 // This test checks that if interceptor doesn't provide a function, |
| 10988 // cached constant function is used | 10988 // cached constant function is used |
| 10989 THREADED_TEST(InterceptorCallICConstantFunctionUsed) { | 10989 THREADED_TEST(InterceptorCallICConstantFunctionUsed) { |
| 10990 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 10990 v8::HandleScope scope(CcTest::isolate()); |
| 10991 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 10991 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 10992 templ->SetNamedPropertyHandler(NoBlockGetterX); | 10992 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 10993 LocalContext context; | 10993 LocalContext context; |
| 10994 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 10994 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 10995 v8::Handle<Value> value = CompileRun( | 10995 v8::Handle<Value> value = CompileRun( |
| 10996 "function inc(x) { return x + 1; };" | 10996 "function inc(x) { return x + 1; };" |
| 10997 "inc(1);" | 10997 "inc(1);" |
| 10998 "o.x = inc;" | 10998 "o.x = inc;" |
| 10999 "var result = 0;" | 10999 "var result = 0;" |
| 11000 "for (var i = 0; i < 1000; i++) {" | 11000 "for (var i = 0; i < 1000; i++) {" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 11011 ApiTestFuzzer::Fuzz(); | 11011 ApiTestFuzzer::Fuzz(); |
| 11012 if (v8_str("x")->Equals(name)) | 11012 if (v8_str("x")->Equals(name)) |
| 11013 info.GetReturnValue().Set(call_ic_function5); | 11013 info.GetReturnValue().Set(call_ic_function5); |
| 11014 } | 11014 } |
| 11015 | 11015 |
| 11016 | 11016 |
| 11017 // This test checks that if interceptor provides a function, | 11017 // This test checks that if interceptor provides a function, |
| 11018 // even if we cached constant function, interceptor's function | 11018 // even if we cached constant function, interceptor's function |
| 11019 // is invoked | 11019 // is invoked |
| 11020 THREADED_TEST(InterceptorCallICConstantFunctionNotNeeded) { | 11020 THREADED_TEST(InterceptorCallICConstantFunctionNotNeeded) { |
| 11021 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11021 v8::HandleScope scope(CcTest::isolate()); |
| 11022 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11022 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11023 templ->SetNamedPropertyHandler(InterceptorCallICGetter5); | 11023 templ->SetNamedPropertyHandler(InterceptorCallICGetter5); |
| 11024 LocalContext context; | 11024 LocalContext context; |
| 11025 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 11025 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 11026 call_ic_function5 = | 11026 call_ic_function5 = |
| 11027 v8_compile("function f(x) { return x - 1; }; f")->Run(); | 11027 v8_compile("function f(x) { return x - 1; }; f")->Run(); |
| 11028 v8::Handle<Value> value = CompileRun( | 11028 v8::Handle<Value> value = CompileRun( |
| 11029 "function inc(x) { return x + 1; };" | 11029 "function inc(x) { return x + 1; };" |
| 11030 "inc(1);" | 11030 "inc(1);" |
| 11031 "o.x = inc;" | 11031 "o.x = inc;" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 11044 ApiTestFuzzer::Fuzz(); | 11044 ApiTestFuzzer::Fuzz(); |
| 11045 if (v8_str("x")->Equals(name)) | 11045 if (v8_str("x")->Equals(name)) |
| 11046 info.GetReturnValue().Set(call_ic_function6); | 11046 info.GetReturnValue().Set(call_ic_function6); |
| 11047 } | 11047 } |
| 11048 | 11048 |
| 11049 | 11049 |
| 11050 // Same test as above, except the code is wrapped in a function | 11050 // Same test as above, except the code is wrapped in a function |
| 11051 // to test the optimized compiler. | 11051 // to test the optimized compiler. |
| 11052 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { | 11052 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) { |
| 11053 i::FLAG_allow_natives_syntax = true; | 11053 i::FLAG_allow_natives_syntax = true; |
| 11054 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11054 v8::HandleScope scope(CcTest::isolate()); |
| 11055 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11055 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11056 templ->SetNamedPropertyHandler(InterceptorCallICGetter6); | 11056 templ->SetNamedPropertyHandler(InterceptorCallICGetter6); |
| 11057 LocalContext context; | 11057 LocalContext context; |
| 11058 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 11058 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 11059 call_ic_function6 = | 11059 call_ic_function6 = |
| 11060 v8_compile("function f(x) { return x - 1; }; f")->Run(); | 11060 v8_compile("function f(x) { return x - 1; }; f")->Run(); |
| 11061 v8::Handle<Value> value = CompileRun( | 11061 v8::Handle<Value> value = CompileRun( |
| 11062 "function inc(x) { return x + 1; };" | 11062 "function inc(x) { return x + 1; };" |
| 11063 "inc(1);" | 11063 "inc(1);" |
| 11064 "o.x = inc;" | 11064 "o.x = inc;" |
| 11065 "function test() {" | 11065 "function test() {" |
| 11066 " var result = 0;" | 11066 " var result = 0;" |
| 11067 " for (var i = 0; i < 1000; i++) {" | 11067 " for (var i = 0; i < 1000; i++) {" |
| 11068 " result = o.x(42);" | 11068 " result = o.x(42);" |
| 11069 " }" | 11069 " }" |
| 11070 " return result;" | 11070 " return result;" |
| 11071 "};" | 11071 "};" |
| 11072 "test();" | 11072 "test();" |
| 11073 "test();" | 11073 "test();" |
| 11074 "test();" | 11074 "test();" |
| 11075 "%OptimizeFunctionOnNextCall(test);" | 11075 "%OptimizeFunctionOnNextCall(test);" |
| 11076 "test()"); | 11076 "test()"); |
| 11077 CHECK_EQ(41, value->Int32Value()); | 11077 CHECK_EQ(41, value->Int32Value()); |
| 11078 } | 11078 } |
| 11079 | 11079 |
| 11080 | 11080 |
| 11081 // Test the case when we stored constant function into | 11081 // Test the case when we stored constant function into |
| 11082 // a stub, but it got invalidated later on | 11082 // a stub, but it got invalidated later on |
| 11083 THREADED_TEST(InterceptorCallICInvalidatedConstantFunction) { | 11083 THREADED_TEST(InterceptorCallICInvalidatedConstantFunction) { |
| 11084 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11084 v8::HandleScope scope(CcTest::isolate()); |
| 11085 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11085 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11086 templ->SetNamedPropertyHandler(NoBlockGetterX); | 11086 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 11087 LocalContext context; | 11087 LocalContext context; |
| 11088 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 11088 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 11089 v8::Handle<Value> value = CompileRun( | 11089 v8::Handle<Value> value = CompileRun( |
| 11090 "function inc(x) { return x + 1; };" | 11090 "function inc(x) { return x + 1; };" |
| 11091 "inc(1);" | 11091 "inc(1);" |
| 11092 "proto1 = new Object();" | 11092 "proto1 = new Object();" |
| 11093 "proto2 = new Object();" | 11093 "proto2 = new Object();" |
| 11094 "o.__proto__ = proto1;" | 11094 "o.__proto__ = proto1;" |
| 11095 "proto1.__proto__ = proto2;" | 11095 "proto1.__proto__ = proto2;" |
| 11096 "proto2.y = inc;" | 11096 "proto2.y = inc;" |
| 11097 // Invoke it many times to compile a stub | 11097 // Invoke it many times to compile a stub |
| 11098 "for (var i = 0; i < 7; i++) {" | 11098 "for (var i = 0; i < 7; i++) {" |
| 11099 " o.y(42);" | 11099 " o.y(42);" |
| 11100 "}" | 11100 "}" |
| 11101 "proto1.y = function(x) { return x - 1; };" | 11101 "proto1.y = function(x) { return x - 1; };" |
| 11102 "var result = 0;" | 11102 "var result = 0;" |
| 11103 "for (var i = 0; i < 7; i++) {" | 11103 "for (var i = 0; i < 7; i++) {" |
| 11104 " result += o.y(42);" | 11104 " result += o.y(42);" |
| 11105 "}"); | 11105 "}"); |
| 11106 CHECK_EQ(41 * 7, value->Int32Value()); | 11106 CHECK_EQ(41 * 7, value->Int32Value()); |
| 11107 } | 11107 } |
| 11108 | 11108 |
| 11109 | 11109 |
| 11110 // Test the case when we stored constant function into | 11110 // Test the case when we stored constant function into |
| 11111 // a stub, but it got invalidated later on due to override on | 11111 // a stub, but it got invalidated later on due to override on |
| 11112 // global object which is between interceptor and constant function' holders. | 11112 // global object which is between interceptor and constant function' holders. |
| 11113 THREADED_TEST(InterceptorCallICInvalidatedConstantFunctionViaGlobal) { | 11113 THREADED_TEST(InterceptorCallICInvalidatedConstantFunctionViaGlobal) { |
| 11114 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11114 v8::HandleScope scope(CcTest::isolate()); |
| 11115 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11115 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11116 templ->SetNamedPropertyHandler(NoBlockGetterX); | 11116 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 11117 LocalContext context; | 11117 LocalContext context; |
| 11118 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 11118 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 11119 v8::Handle<Value> value = CompileRun( | 11119 v8::Handle<Value> value = CompileRun( |
| 11120 "function inc(x) { return x + 1; };" | 11120 "function inc(x) { return x + 1; };" |
| 11121 "inc(1);" | 11121 "inc(1);" |
| 11122 "o.__proto__ = this;" | 11122 "o.__proto__ = this;" |
| 11123 "this.__proto__.y = inc;" | 11123 "this.__proto__.y = inc;" |
| 11124 // Invoke it many times to compile a stub | 11124 // Invoke it many times to compile a stub |
| 11125 "for (var i = 0; i < 7; i++) {" | 11125 "for (var i = 0; i < 7; i++) {" |
| 11126 " if (o.y(42) != 43) throw 'oops: ' + o.y(42);" | 11126 " if (o.y(42) != 43) throw 'oops: ' + o.y(42);" |
| 11127 "}" | 11127 "}" |
| 11128 "this.y = function(x) { return x - 1; };" | 11128 "this.y = function(x) { return x - 1; };" |
| 11129 "var result = 0;" | 11129 "var result = 0;" |
| 11130 "for (var i = 0; i < 7; i++) {" | 11130 "for (var i = 0; i < 7; i++) {" |
| 11131 " result += o.y(42);" | 11131 " result += o.y(42);" |
| 11132 "}"); | 11132 "}"); |
| 11133 CHECK_EQ(41 * 7, value->Int32Value()); | 11133 CHECK_EQ(41 * 7, value->Int32Value()); |
| 11134 } | 11134 } |
| 11135 | 11135 |
| 11136 | 11136 |
| 11137 // Test the case when actual function to call sits on global object. | 11137 // Test the case when actual function to call sits on global object. |
| 11138 THREADED_TEST(InterceptorCallICCachedFromGlobal) { | 11138 THREADED_TEST(InterceptorCallICCachedFromGlobal) { |
| 11139 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11139 v8::HandleScope scope(CcTest::isolate()); |
| 11140 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 11140 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 11141 templ_o->SetNamedPropertyHandler(NoBlockGetterX); | 11141 templ_o->SetNamedPropertyHandler(NoBlockGetterX); |
| 11142 | 11142 |
| 11143 LocalContext context; | 11143 LocalContext context; |
| 11144 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 11144 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 11145 | 11145 |
| 11146 v8::Handle<Value> value = CompileRun( | 11146 v8::Handle<Value> value = CompileRun( |
| 11147 "try {" | 11147 "try {" |
| 11148 " o.__proto__ = this;" | 11148 " o.__proto__ = this;" |
| 11149 " for (var i = 0; i < 10; i++) {" | 11149 " for (var i = 0; i < 10; i++) {" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 11172 ++(*call_count); | 11172 ++(*call_count); |
| 11173 if ((*call_count) % 20 == 0) { | 11173 if ((*call_count) % 20 == 0) { |
| 11174 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11174 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 11175 } | 11175 } |
| 11176 } | 11176 } |
| 11177 | 11177 |
| 11178 static void FastApiCallback_TrivialSignature( | 11178 static void FastApiCallback_TrivialSignature( |
| 11179 const v8::FunctionCallbackInfo<v8::Value>& args) { | 11179 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 11180 ApiTestFuzzer::Fuzz(); | 11180 ApiTestFuzzer::Fuzz(); |
| 11181 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); | 11181 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); |
| 11182 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 11182 v8::Isolate* isolate = CcTest::isolate(); |
| 11183 CHECK_EQ(isolate, args.GetIsolate()); | 11183 CHECK_EQ(isolate, args.GetIsolate()); |
| 11184 CHECK_EQ(args.This(), args.Holder()); | 11184 CHECK_EQ(args.This(), args.Holder()); |
| 11185 CHECK(args.Data()->Equals(v8_str("method_data"))); | 11185 CHECK(args.Data()->Equals(v8_str("method_data"))); |
| 11186 args.GetReturnValue().Set(args[0]->Int32Value() + 1); | 11186 args.GetReturnValue().Set(args[0]->Int32Value() + 1); |
| 11187 } | 11187 } |
| 11188 | 11188 |
| 11189 static void FastApiCallback_SimpleSignature( | 11189 static void FastApiCallback_SimpleSignature( |
| 11190 const v8::FunctionCallbackInfo<v8::Value>& args) { | 11190 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 11191 ApiTestFuzzer::Fuzz(); | 11191 ApiTestFuzzer::Fuzz(); |
| 11192 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)); | 11192 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_SimpleSignature)); |
| 11193 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 11193 v8::Isolate* isolate = CcTest::isolate(); |
| 11194 CHECK_EQ(isolate, args.GetIsolate()); | 11194 CHECK_EQ(isolate, args.GetIsolate()); |
| 11195 CHECK_EQ(args.This()->GetPrototype(), args.Holder()); | 11195 CHECK_EQ(args.This()->GetPrototype(), args.Holder()); |
| 11196 CHECK(args.Data()->Equals(v8_str("method_data"))); | 11196 CHECK(args.Data()->Equals(v8_str("method_data"))); |
| 11197 // Note, we're using HasRealNamedProperty instead of Has to avoid | 11197 // Note, we're using HasRealNamedProperty instead of Has to avoid |
| 11198 // invoking the interceptor again. | 11198 // invoking the interceptor again. |
| 11199 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); | 11199 CHECK(args.Holder()->HasRealNamedProperty(v8_str("foo"))); |
| 11200 args.GetReturnValue().Set(args[0]->Int32Value() + 1); | 11200 args.GetReturnValue().Set(args[0]->Int32Value() + 1); |
| 11201 } | 11201 } |
| 11202 | 11202 |
| 11203 | 11203 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11326 "for (var i = 0; i < 5; i++) {" | 11326 "for (var i = 0; i < 5; i++) {" |
| 11327 " try { o1.p1; } catch (e) { result += e; }" | 11327 " try { o1.p1; } catch (e) { result += e; }" |
| 11328 "}" | 11328 "}" |
| 11329 "result;"); | 11329 "result;"); |
| 11330 CHECK_EQ(v8_str("ggggg"), result); | 11330 CHECK_EQ(v8_str("ggggg"), result); |
| 11331 } | 11331 } |
| 11332 | 11332 |
| 11333 | 11333 |
| 11334 THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) { | 11334 THREADED_PROFILED_TEST(InterceptorCallICFastApi_TrivialSignature) { |
| 11335 int interceptor_call_count = 0; | 11335 int interceptor_call_count = 0; |
| 11336 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11336 v8::HandleScope scope(CcTest::isolate()); |
| 11337 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11337 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11338 v8::Handle<v8::FunctionTemplate> method_templ = | 11338 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11339 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, | 11339 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, |
| 11340 v8_str("method_data"), | 11340 v8_str("method_data"), |
| 11341 v8::Handle<v8::Signature>()); | 11341 v8::Handle<v8::Signature>()); |
| 11342 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11342 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11343 proto_templ->Set(v8_str("method"), method_templ); | 11343 proto_templ->Set(v8_str("method"), method_templ); |
| 11344 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11344 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11345 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11345 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
| 11346 NULL, NULL, NULL, NULL, | 11346 NULL, NULL, NULL, NULL, |
| 11347 v8::External::New(&interceptor_call_count)); | 11347 v8::External::New(&interceptor_call_count)); |
| 11348 LocalContext context; | 11348 LocalContext context; |
| 11349 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11349 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11350 GenerateSomeGarbage(); | 11350 GenerateSomeGarbage(); |
| 11351 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11351 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11352 CompileRun( | 11352 CompileRun( |
| 11353 "var result = 0;" | 11353 "var result = 0;" |
| 11354 "for (var i = 0; i < 100; i++) {" | 11354 "for (var i = 0; i < 100; i++) {" |
| 11355 " result = o.method(41);" | 11355 " result = o.method(41);" |
| 11356 "}"); | 11356 "}"); |
| 11357 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11357 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11358 CHECK_EQ(100, interceptor_call_count); | 11358 CHECK_EQ(100, interceptor_call_count); |
| 11359 } | 11359 } |
| 11360 | 11360 |
| 11361 | 11361 |
| 11362 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { | 11362 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { |
| 11363 int interceptor_call_count = 0; | 11363 int interceptor_call_count = 0; |
| 11364 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11364 v8::HandleScope scope(CcTest::isolate()); |
| 11365 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11365 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11366 v8::Handle<v8::FunctionTemplate> method_templ = | 11366 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11367 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11367 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11368 v8_str("method_data"), | 11368 v8_str("method_data"), |
| 11369 v8::Signature::New(fun_templ)); | 11369 v8::Signature::New(fun_templ)); |
| 11370 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11370 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11371 proto_templ->Set(v8_str("method"), method_templ); | 11371 proto_templ->Set(v8_str("method"), method_templ); |
| 11372 fun_templ->SetHiddenPrototype(true); | 11372 fun_templ->SetHiddenPrototype(true); |
| 11373 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11373 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11374 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11374 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 11386 "for (var i = 0; i < 100; i++) {" | 11386 "for (var i = 0; i < 100; i++) {" |
| 11387 " result = receiver.method(41);" | 11387 " result = receiver.method(41);" |
| 11388 "}"); | 11388 "}"); |
| 11389 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11389 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11390 CHECK_EQ(100, interceptor_call_count); | 11390 CHECK_EQ(100, interceptor_call_count); |
| 11391 } | 11391 } |
| 11392 | 11392 |
| 11393 | 11393 |
| 11394 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { | 11394 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { |
| 11395 int interceptor_call_count = 0; | 11395 int interceptor_call_count = 0; |
| 11396 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11396 v8::HandleScope scope(CcTest::isolate()); |
| 11397 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11397 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11398 v8::Handle<v8::FunctionTemplate> method_templ = | 11398 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11399 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11399 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11400 v8_str("method_data"), | 11400 v8_str("method_data"), |
| 11401 v8::Signature::New(fun_templ)); | 11401 v8::Signature::New(fun_templ)); |
| 11402 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11402 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11403 proto_templ->Set(v8_str("method"), method_templ); | 11403 proto_templ->Set(v8_str("method"), method_templ); |
| 11404 fun_templ->SetHiddenPrototype(true); | 11404 fun_templ->SetHiddenPrototype(true); |
| 11405 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11405 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11406 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11406 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 11424 " }" | 11424 " }" |
| 11425 "}"); | 11425 "}"); |
| 11426 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 11426 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11427 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11427 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11428 CHECK_GE(interceptor_call_count, 50); | 11428 CHECK_GE(interceptor_call_count, 50); |
| 11429 } | 11429 } |
| 11430 | 11430 |
| 11431 | 11431 |
| 11432 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { | 11432 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { |
| 11433 int interceptor_call_count = 0; | 11433 int interceptor_call_count = 0; |
| 11434 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11434 v8::HandleScope scope(CcTest::isolate()); |
| 11435 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11435 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11436 v8::Handle<v8::FunctionTemplate> method_templ = | 11436 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11437 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11437 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11438 v8_str("method_data"), | 11438 v8_str("method_data"), |
| 11439 v8::Signature::New(fun_templ)); | 11439 v8::Signature::New(fun_templ)); |
| 11440 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11440 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11441 proto_templ->Set(v8_str("method"), method_templ); | 11441 proto_templ->Set(v8_str("method"), method_templ); |
| 11442 fun_templ->SetHiddenPrototype(true); | 11442 fun_templ->SetHiddenPrototype(true); |
| 11443 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11443 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11444 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11444 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 11462 " }" | 11462 " }" |
| 11463 "}"); | 11463 "}"); |
| 11464 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 11464 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11465 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11465 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11466 CHECK_GE(interceptor_call_count, 50); | 11466 CHECK_GE(interceptor_call_count, 50); |
| 11467 } | 11467 } |
| 11468 | 11468 |
| 11469 | 11469 |
| 11470 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { | 11470 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { |
| 11471 int interceptor_call_count = 0; | 11471 int interceptor_call_count = 0; |
| 11472 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11472 v8::HandleScope scope(CcTest::isolate()); |
| 11473 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11473 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11474 v8::Handle<v8::FunctionTemplate> method_templ = | 11474 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11475 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11475 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11476 v8_str("method_data"), | 11476 v8_str("method_data"), |
| 11477 v8::Signature::New(fun_templ)); | 11477 v8::Signature::New(fun_templ)); |
| 11478 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11478 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11479 proto_templ->Set(v8_str("method"), method_templ); | 11479 proto_templ->Set(v8_str("method"), method_templ); |
| 11480 fun_templ->SetHiddenPrototype(true); | 11480 fun_templ->SetHiddenPrototype(true); |
| 11481 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11481 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11482 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11482 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 11503 CHECK(try_catch.HasCaught()); | 11503 CHECK(try_catch.HasCaught()); |
| 11504 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), | 11504 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), |
| 11505 try_catch.Exception()->ToString()); | 11505 try_catch.Exception()->ToString()); |
| 11506 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11506 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11507 CHECK_GE(interceptor_call_count, 50); | 11507 CHECK_GE(interceptor_call_count, 50); |
| 11508 } | 11508 } |
| 11509 | 11509 |
| 11510 | 11510 |
| 11511 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { | 11511 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { |
| 11512 int interceptor_call_count = 0; | 11512 int interceptor_call_count = 0; |
| 11513 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11513 v8::HandleScope scope(CcTest::isolate()); |
| 11514 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11514 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11515 v8::Handle<v8::FunctionTemplate> method_templ = | 11515 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11516 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11516 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11517 v8_str("method_data"), | 11517 v8_str("method_data"), |
| 11518 v8::Signature::New(fun_templ)); | 11518 v8::Signature::New(fun_templ)); |
| 11519 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11519 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11520 proto_templ->Set(v8_str("method"), method_templ); | 11520 proto_templ->Set(v8_str("method"), method_templ); |
| 11521 fun_templ->SetHiddenPrototype(true); | 11521 fun_templ->SetHiddenPrototype(true); |
| 11522 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11522 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11523 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, | 11523 templ->SetNamedPropertyHandler(InterceptorCallICFastApi, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 11543 "}"); | 11543 "}"); |
| 11544 CHECK(try_catch.HasCaught()); | 11544 CHECK(try_catch.HasCaught()); |
| 11545 CHECK_EQ(v8_str("TypeError: Illegal invocation"), | 11545 CHECK_EQ(v8_str("TypeError: Illegal invocation"), |
| 11546 try_catch.Exception()->ToString()); | 11546 try_catch.Exception()->ToString()); |
| 11547 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11547 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11548 CHECK_GE(interceptor_call_count, 50); | 11548 CHECK_GE(interceptor_call_count, 50); |
| 11549 } | 11549 } |
| 11550 | 11550 |
| 11551 | 11551 |
| 11552 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { | 11552 THREADED_PROFILED_TEST(CallICFastApi_TrivialSignature) { |
| 11553 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11553 v8::HandleScope scope(CcTest::isolate()); |
| 11554 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11554 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11555 v8::Handle<v8::FunctionTemplate> method_templ = | 11555 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11556 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, | 11556 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature, |
| 11557 v8_str("method_data"), | 11557 v8_str("method_data"), |
| 11558 v8::Handle<v8::Signature>()); | 11558 v8::Handle<v8::Signature>()); |
| 11559 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11559 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11560 proto_templ->Set(v8_str("method"), method_templ); | 11560 proto_templ->Set(v8_str("method"), method_templ); |
| 11561 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 11561 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11562 USE(templ); | 11562 USE(templ); |
| 11563 LocalContext context; | 11563 LocalContext context; |
| 11564 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11564 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11565 GenerateSomeGarbage(); | 11565 GenerateSomeGarbage(); |
| 11566 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11566 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11567 CompileRun( | 11567 CompileRun( |
| 11568 "var result = 0;" | 11568 "var result = 0;" |
| 11569 "for (var i = 0; i < 100; i++) {" | 11569 "for (var i = 0; i < 100; i++) {" |
| 11570 " result = o.method(41);" | 11570 " result = o.method(41);" |
| 11571 "}"); | 11571 "}"); |
| 11572 | 11572 |
| 11573 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11573 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11574 } | 11574 } |
| 11575 | 11575 |
| 11576 | 11576 |
| 11577 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) { | 11577 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) { |
| 11578 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11578 v8::HandleScope scope(CcTest::isolate()); |
| 11579 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11579 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11580 v8::Handle<v8::FunctionTemplate> method_templ = | 11580 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11581 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11581 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11582 v8_str("method_data"), | 11582 v8_str("method_data"), |
| 11583 v8::Signature::New(fun_templ)); | 11583 v8::Signature::New(fun_templ)); |
| 11584 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11584 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11585 proto_templ->Set(v8_str("method"), method_templ); | 11585 proto_templ->Set(v8_str("method"), method_templ); |
| 11586 fun_templ->SetHiddenPrototype(true); | 11586 fun_templ->SetHiddenPrototype(true); |
| 11587 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 11587 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11588 CHECK(!templ.IsEmpty()); | 11588 CHECK(!templ.IsEmpty()); |
| 11589 LocalContext context; | 11589 LocalContext context; |
| 11590 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11590 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11591 GenerateSomeGarbage(); | 11591 GenerateSomeGarbage(); |
| 11592 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11592 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11593 CompileRun( | 11593 CompileRun( |
| 11594 "o.foo = 17;" | 11594 "o.foo = 17;" |
| 11595 "var receiver = {};" | 11595 "var receiver = {};" |
| 11596 "receiver.__proto__ = o;" | 11596 "receiver.__proto__ = o;" |
| 11597 "var result = 0;" | 11597 "var result = 0;" |
| 11598 "for (var i = 0; i < 100; i++) {" | 11598 "for (var i = 0; i < 100; i++) {" |
| 11599 " result = receiver.method(41);" | 11599 " result = receiver.method(41);" |
| 11600 "}"); | 11600 "}"); |
| 11601 | 11601 |
| 11602 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11602 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11603 } | 11603 } |
| 11604 | 11604 |
| 11605 | 11605 |
| 11606 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) { | 11606 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) { |
| 11607 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11607 v8::HandleScope scope(CcTest::isolate()); |
| 11608 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11608 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11609 v8::Handle<v8::FunctionTemplate> method_templ = | 11609 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11610 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11610 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11611 v8_str("method_data"), | 11611 v8_str("method_data"), |
| 11612 v8::Signature::New(fun_templ)); | 11612 v8::Signature::New(fun_templ)); |
| 11613 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11613 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11614 proto_templ->Set(v8_str("method"), method_templ); | 11614 proto_templ->Set(v8_str("method"), method_templ); |
| 11615 fun_templ->SetHiddenPrototype(true); | 11615 fun_templ->SetHiddenPrototype(true); |
| 11616 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 11616 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11617 CHECK(!templ.IsEmpty()); | 11617 CHECK(!templ.IsEmpty()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 11631 " saved_result = result;" | 11631 " saved_result = result;" |
| 11632 " receiver = {method: function(x) { return x - 1 }};" | 11632 " receiver = {method: function(x) { return x - 1 }};" |
| 11633 " }" | 11633 " }" |
| 11634 "}"); | 11634 "}"); |
| 11635 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 11635 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11636 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11636 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11637 } | 11637 } |
| 11638 | 11638 |
| 11639 | 11639 |
| 11640 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) { | 11640 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) { |
| 11641 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11641 v8::HandleScope scope(CcTest::isolate()); |
| 11642 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11642 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11643 v8::Handle<v8::FunctionTemplate> method_templ = | 11643 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11644 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11644 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11645 v8_str("method_data"), | 11645 v8_str("method_data"), |
| 11646 v8::Signature::New(fun_templ)); | 11646 v8::Signature::New(fun_templ)); |
| 11647 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11647 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11648 proto_templ->Set(v8_str("method"), method_templ); | 11648 proto_templ->Set(v8_str("method"), method_templ); |
| 11649 fun_templ->SetHiddenPrototype(true); | 11649 fun_templ->SetHiddenPrototype(true); |
| 11650 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 11650 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11651 CHECK(!templ.IsEmpty()); | 11651 CHECK(!templ.IsEmpty()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 11668 " }" | 11668 " }" |
| 11669 "}"); | 11669 "}"); |
| 11670 CHECK(try_catch.HasCaught()); | 11670 CHECK(try_catch.HasCaught()); |
| 11671 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), | 11671 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), |
| 11672 try_catch.Exception()->ToString()); | 11672 try_catch.Exception()->ToString()); |
| 11673 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11673 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11674 } | 11674 } |
| 11675 | 11675 |
| 11676 | 11676 |
| 11677 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { | 11677 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { |
| 11678 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11678 v8::HandleScope scope(CcTest::isolate()); |
| 11679 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11679 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11680 v8::Handle<v8::FunctionTemplate> method_templ = | 11680 v8::Handle<v8::FunctionTemplate> method_templ = |
| 11681 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11681 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, |
| 11682 v8_str("method_data"), | 11682 v8_str("method_data"), |
| 11683 v8::Signature::New(fun_templ)); | 11683 v8::Signature::New(fun_templ)); |
| 11684 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11684 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11685 proto_templ->Set(v8_str("method"), method_templ); | 11685 proto_templ->Set(v8_str("method"), method_templ); |
| 11686 fun_templ->SetHiddenPrototype(true); | 11686 fun_templ->SetHiddenPrototype(true); |
| 11687 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 11687 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11688 CHECK(!templ.IsEmpty()); | 11688 CHECK(!templ.IsEmpty()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 11719 ApiTestFuzzer::Fuzz(); | 11719 ApiTestFuzzer::Fuzz(); |
| 11720 if (v8_str("x")->Equals(name)) { | 11720 if (v8_str("x")->Equals(name)) { |
| 11721 info.GetReturnValue().Set(keyed_call_ic_function); | 11721 info.GetReturnValue().Set(keyed_call_ic_function); |
| 11722 } | 11722 } |
| 11723 } | 11723 } |
| 11724 | 11724 |
| 11725 | 11725 |
| 11726 // Test the case when we stored cacheable lookup into | 11726 // Test the case when we stored cacheable lookup into |
| 11727 // a stub, but the function name changed (to another cacheable function). | 11727 // a stub, but the function name changed (to another cacheable function). |
| 11728 THREADED_TEST(InterceptorKeyedCallICKeyChange1) { | 11728 THREADED_TEST(InterceptorKeyedCallICKeyChange1) { |
| 11729 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11729 v8::HandleScope scope(CcTest::isolate()); |
| 11730 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11730 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11731 templ->SetNamedPropertyHandler(NoBlockGetterX); | 11731 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 11732 LocalContext context; | 11732 LocalContext context; |
| 11733 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 11733 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 11734 CompileRun( | 11734 CompileRun( |
| 11735 "proto = new Object();" | 11735 "proto = new Object();" |
| 11736 "proto.y = function(x) { return x + 1; };" | 11736 "proto.y = function(x) { return x + 1; };" |
| 11737 "proto.z = function(x) { return x - 1; };" | 11737 "proto.z = function(x) { return x - 1; };" |
| 11738 "o.__proto__ = proto;" | 11738 "o.__proto__ = proto;" |
| 11739 "var result = 0;" | 11739 "var result = 0;" |
| 11740 "var method = 'y';" | 11740 "var method = 'y';" |
| 11741 "for (var i = 0; i < 10; i++) {" | 11741 "for (var i = 0; i < 10; i++) {" |
| 11742 " if (i == 5) { method = 'z'; };" | 11742 " if (i == 5) { method = 'z'; };" |
| 11743 " result += o[method](41);" | 11743 " result += o[method](41);" |
| 11744 "}"); | 11744 "}"); |
| 11745 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); | 11745 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11746 } | 11746 } |
| 11747 | 11747 |
| 11748 | 11748 |
| 11749 // Test the case when we stored cacheable lookup into | 11749 // Test the case when we stored cacheable lookup into |
| 11750 // a stub, but the function name changed (and the new function is present | 11750 // a stub, but the function name changed (and the new function is present |
| 11751 // both before and after the interceptor in the prototype chain). | 11751 // both before and after the interceptor in the prototype chain). |
| 11752 THREADED_TEST(InterceptorKeyedCallICKeyChange2) { | 11752 THREADED_TEST(InterceptorKeyedCallICKeyChange2) { |
| 11753 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11753 v8::HandleScope scope(CcTest::isolate()); |
| 11754 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11754 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11755 templ->SetNamedPropertyHandler(InterceptorKeyedCallICGetter); | 11755 templ->SetNamedPropertyHandler(InterceptorKeyedCallICGetter); |
| 11756 LocalContext context; | 11756 LocalContext context; |
| 11757 context->Global()->Set(v8_str("proto1"), templ->NewInstance()); | 11757 context->Global()->Set(v8_str("proto1"), templ->NewInstance()); |
| 11758 keyed_call_ic_function = | 11758 keyed_call_ic_function = |
| 11759 v8_compile("function f(x) { return x - 1; }; f")->Run(); | 11759 v8_compile("function f(x) { return x - 1; }; f")->Run(); |
| 11760 CompileRun( | 11760 CompileRun( |
| 11761 "o = new Object();" | 11761 "o = new Object();" |
| 11762 "proto2 = new Object();" | 11762 "proto2 = new Object();" |
| 11763 "o.y = function(x) { return x + 1; };" | 11763 "o.y = function(x) { return x + 1; };" |
| 11764 "proto2.y = function(x) { return x + 2; };" | 11764 "proto2.y = function(x) { return x + 2; };" |
| 11765 "o.__proto__ = proto1;" | 11765 "o.__proto__ = proto1;" |
| 11766 "proto1.__proto__ = proto2;" | 11766 "proto1.__proto__ = proto2;" |
| 11767 "var result = 0;" | 11767 "var result = 0;" |
| 11768 "var method = 'x';" | 11768 "var method = 'x';" |
| 11769 "for (var i = 0; i < 10; i++) {" | 11769 "for (var i = 0; i < 10; i++) {" |
| 11770 " if (i == 5) { method = 'y'; };" | 11770 " if (i == 5) { method = 'y'; };" |
| 11771 " result += o[method](41);" | 11771 " result += o[method](41);" |
| 11772 "}"); | 11772 "}"); |
| 11773 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); | 11773 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11774 } | 11774 } |
| 11775 | 11775 |
| 11776 | 11776 |
| 11777 // Same as InterceptorKeyedCallICKeyChange1 only the cacheable function sit | 11777 // Same as InterceptorKeyedCallICKeyChange1 only the cacheable function sit |
| 11778 // on the global object. | 11778 // on the global object. |
| 11779 THREADED_TEST(InterceptorKeyedCallICKeyChangeOnGlobal) { | 11779 THREADED_TEST(InterceptorKeyedCallICKeyChangeOnGlobal) { |
| 11780 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11780 v8::HandleScope scope(CcTest::isolate()); |
| 11781 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11781 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11782 templ->SetNamedPropertyHandler(NoBlockGetterX); | 11782 templ->SetNamedPropertyHandler(NoBlockGetterX); |
| 11783 LocalContext context; | 11783 LocalContext context; |
| 11784 context->Global()->Set(v8_str("o"), templ->NewInstance()); | 11784 context->Global()->Set(v8_str("o"), templ->NewInstance()); |
| 11785 CompileRun( | 11785 CompileRun( |
| 11786 "function inc(x) { return x + 1; };" | 11786 "function inc(x) { return x + 1; };" |
| 11787 "inc(1);" | 11787 "inc(1);" |
| 11788 "function dec(x) { return x - 1; };" | 11788 "function dec(x) { return x - 1; };" |
| 11789 "dec(1);" | 11789 "dec(1);" |
| 11790 "o.__proto__ = this;" | 11790 "o.__proto__ = this;" |
| 11791 "this.__proto__.x = inc;" | 11791 "this.__proto__.x = inc;" |
| 11792 "this.__proto__.y = dec;" | 11792 "this.__proto__.y = dec;" |
| 11793 "var result = 0;" | 11793 "var result = 0;" |
| 11794 "var method = 'x';" | 11794 "var method = 'x';" |
| 11795 "for (var i = 0; i < 10; i++) {" | 11795 "for (var i = 0; i < 10; i++) {" |
| 11796 " if (i == 5) { method = 'y'; };" | 11796 " if (i == 5) { method = 'y'; };" |
| 11797 " result += o[method](41);" | 11797 " result += o[method](41);" |
| 11798 "}"); | 11798 "}"); |
| 11799 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); | 11799 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11800 } | 11800 } |
| 11801 | 11801 |
| 11802 | 11802 |
| 11803 // Test the case when actual function to call sits on global object. | 11803 // Test the case when actual function to call sits on global object. |
| 11804 THREADED_TEST(InterceptorKeyedCallICFromGlobal) { | 11804 THREADED_TEST(InterceptorKeyedCallICFromGlobal) { |
| 11805 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11805 v8::HandleScope scope(CcTest::isolate()); |
| 11806 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 11806 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 11807 templ_o->SetNamedPropertyHandler(NoBlockGetterX); | 11807 templ_o->SetNamedPropertyHandler(NoBlockGetterX); |
| 11808 LocalContext context; | 11808 LocalContext context; |
| 11809 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 11809 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 11810 | 11810 |
| 11811 CompileRun( | 11811 CompileRun( |
| 11812 "function len(x) { return x.length; };" | 11812 "function len(x) { return x.length; };" |
| 11813 "o.__proto__ = this;" | 11813 "o.__proto__ = this;" |
| 11814 "var m = 'parseFloat';" | 11814 "var m = 'parseFloat';" |
| 11815 "var result = 0;" | 11815 "var result = 0;" |
| 11816 "for (var i = 0; i < 10; i++) {" | 11816 "for (var i = 0; i < 10; i++) {" |
| 11817 " if (i == 5) {" | 11817 " if (i == 5) {" |
| 11818 " m = 'len';" | 11818 " m = 'len';" |
| 11819 " saved_result = result;" | 11819 " saved_result = result;" |
| 11820 " };" | 11820 " };" |
| 11821 " result = o[m]('239');" | 11821 " result = o[m]('239');" |
| 11822 "}"); | 11822 "}"); |
| 11823 CHECK_EQ(3, context->Global()->Get(v8_str("result"))->Int32Value()); | 11823 CHECK_EQ(3, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11824 CHECK_EQ(239, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11824 CHECK_EQ(239, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11825 } | 11825 } |
| 11826 | 11826 |
| 11827 | 11827 |
| 11828 // Test the map transition before the interceptor. | 11828 // Test the map transition before the interceptor. |
| 11829 THREADED_TEST(InterceptorKeyedCallICMapChangeBefore) { | 11829 THREADED_TEST(InterceptorKeyedCallICMapChangeBefore) { |
| 11830 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11830 v8::HandleScope scope(CcTest::isolate()); |
| 11831 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 11831 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 11832 templ_o->SetNamedPropertyHandler(NoBlockGetterX); | 11832 templ_o->SetNamedPropertyHandler(NoBlockGetterX); |
| 11833 LocalContext context; | 11833 LocalContext context; |
| 11834 context->Global()->Set(v8_str("proto"), templ_o->NewInstance()); | 11834 context->Global()->Set(v8_str("proto"), templ_o->NewInstance()); |
| 11835 | 11835 |
| 11836 CompileRun( | 11836 CompileRun( |
| 11837 "var o = new Object();" | 11837 "var o = new Object();" |
| 11838 "o.__proto__ = proto;" | 11838 "o.__proto__ = proto;" |
| 11839 "o.method = function(x) { return x + 1; };" | 11839 "o.method = function(x) { return x + 1; };" |
| 11840 "var m = 'method';" | 11840 "var m = 'method';" |
| 11841 "var result = 0;" | 11841 "var result = 0;" |
| 11842 "for (var i = 0; i < 10; i++) {" | 11842 "for (var i = 0; i < 10; i++) {" |
| 11843 " if (i == 5) { o.method = function(x) { return x - 1; }; };" | 11843 " if (i == 5) { o.method = function(x) { return x - 1; }; };" |
| 11844 " result += o[m](41);" | 11844 " result += o[m](41);" |
| 11845 "}"); | 11845 "}"); |
| 11846 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); | 11846 CHECK_EQ(42*5 + 40*5, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11847 } | 11847 } |
| 11848 | 11848 |
| 11849 | 11849 |
| 11850 // Test the map transition after the interceptor. | 11850 // Test the map transition after the interceptor. |
| 11851 THREADED_TEST(InterceptorKeyedCallICMapChangeAfter) { | 11851 THREADED_TEST(InterceptorKeyedCallICMapChangeAfter) { |
| 11852 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11852 v8::HandleScope scope(CcTest::isolate()); |
| 11853 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); | 11853 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New(); |
| 11854 templ_o->SetNamedPropertyHandler(NoBlockGetterX); | 11854 templ_o->SetNamedPropertyHandler(NoBlockGetterX); |
| 11855 LocalContext context; | 11855 LocalContext context; |
| 11856 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); | 11856 context->Global()->Set(v8_str("o"), templ_o->NewInstance()); |
| 11857 | 11857 |
| 11858 CompileRun( | 11858 CompileRun( |
| 11859 "var proto = new Object();" | 11859 "var proto = new Object();" |
| 11860 "o.__proto__ = proto;" | 11860 "o.__proto__ = proto;" |
| 11861 "proto.method = function(x) { return x + 1; };" | 11861 "proto.method = function(x) { return x + 1; };" |
| 11862 "var m = 'method';" | 11862 "var m = 'method';" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 11878 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { | 11878 if (v8_str("x")->Equals(name) && interceptor_call_count++ < 20) { |
| 11879 info.GetReturnValue().Set(call_ic_function2); | 11879 info.GetReturnValue().Set(call_ic_function2); |
| 11880 } | 11880 } |
| 11881 } | 11881 } |
| 11882 | 11882 |
| 11883 | 11883 |
| 11884 // This test should hit load and call ICs for the interceptor case. | 11884 // This test should hit load and call ICs for the interceptor case. |
| 11885 // Once in a while, the interceptor will reply that a property was not | 11885 // Once in a while, the interceptor will reply that a property was not |
| 11886 // found in which case we should get a reference error. | 11886 // found in which case we should get a reference error. |
| 11887 THREADED_TEST(InterceptorICReferenceErrors) { | 11887 THREADED_TEST(InterceptorICReferenceErrors) { |
| 11888 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11888 v8::HandleScope scope(CcTest::isolate()); |
| 11889 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11889 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11890 templ->SetNamedPropertyHandler(InterceptorICRefErrorGetter); | 11890 templ->SetNamedPropertyHandler(InterceptorICRefErrorGetter); |
| 11891 LocalContext context(0, templ, v8::Handle<Value>()); | 11891 LocalContext context(0, templ, v8::Handle<Value>()); |
| 11892 call_ic_function2 = v8_compile("function h(x) { return x; }; h")->Run(); | 11892 call_ic_function2 = v8_compile("function h(x) { return x; }; h")->Run(); |
| 11893 v8::Handle<Value> value = CompileRun( | 11893 v8::Handle<Value> value = CompileRun( |
| 11894 "function f() {" | 11894 "function f() {" |
| 11895 " for (var i = 0; i < 1000; i++) {" | 11895 " for (var i = 0; i < 1000; i++) {" |
| 11896 " try { x; } catch(e) { return true; }" | 11896 " try { x; } catch(e) { return true; }" |
| 11897 " }" | 11897 " }" |
| 11898 " return false;" | 11898 " return false;" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 11925 v8::ThrowException(v8_num(42)); | 11925 v8::ThrowException(v8_num(42)); |
| 11926 return; | 11926 return; |
| 11927 } | 11927 } |
| 11928 } | 11928 } |
| 11929 | 11929 |
| 11930 | 11930 |
| 11931 // Test interceptor load/call IC where the interceptor throws an | 11931 // Test interceptor load/call IC where the interceptor throws an |
| 11932 // exception once in a while. | 11932 // exception once in a while. |
| 11933 THREADED_TEST(InterceptorICGetterExceptions) { | 11933 THREADED_TEST(InterceptorICGetterExceptions) { |
| 11934 interceptor_ic_exception_get_count = 0; | 11934 interceptor_ic_exception_get_count = 0; |
| 11935 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11935 v8::HandleScope scope(CcTest::isolate()); |
| 11936 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11936 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11937 templ->SetNamedPropertyHandler(InterceptorICExceptionGetter); | 11937 templ->SetNamedPropertyHandler(InterceptorICExceptionGetter); |
| 11938 LocalContext context(0, templ, v8::Handle<Value>()); | 11938 LocalContext context(0, templ, v8::Handle<Value>()); |
| 11939 call_ic_function3 = v8_compile("function h(x) { return x; }; h")->Run(); | 11939 call_ic_function3 = v8_compile("function h(x) { return x; }; h")->Run(); |
| 11940 v8::Handle<Value> value = CompileRun( | 11940 v8::Handle<Value> value = CompileRun( |
| 11941 "function f() {" | 11941 "function f() {" |
| 11942 " for (var i = 0; i < 100; i++) {" | 11942 " for (var i = 0; i < 100; i++) {" |
| 11943 " try { x; } catch(e) { return true; }" | 11943 " try { x; } catch(e) { return true; }" |
| 11944 " }" | 11944 " }" |
| 11945 " return false;" | 11945 " return false;" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 11969 if (++interceptor_ic_exception_set_count > 20) { | 11969 if (++interceptor_ic_exception_set_count > 20) { |
| 11970 v8::ThrowException(v8_num(42)); | 11970 v8::ThrowException(v8_num(42)); |
| 11971 } | 11971 } |
| 11972 } | 11972 } |
| 11973 | 11973 |
| 11974 | 11974 |
| 11975 // Test interceptor store IC where the interceptor throws an exception | 11975 // Test interceptor store IC where the interceptor throws an exception |
| 11976 // once in a while. | 11976 // once in a while. |
| 11977 THREADED_TEST(InterceptorICSetterExceptions) { | 11977 THREADED_TEST(InterceptorICSetterExceptions) { |
| 11978 interceptor_ic_exception_set_count = 0; | 11978 interceptor_ic_exception_set_count = 0; |
| 11979 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11979 v8::HandleScope scope(CcTest::isolate()); |
| 11980 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11980 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11981 templ->SetNamedPropertyHandler(0, InterceptorICExceptionSetter); | 11981 templ->SetNamedPropertyHandler(0, InterceptorICExceptionSetter); |
| 11982 LocalContext context(0, templ, v8::Handle<Value>()); | 11982 LocalContext context(0, templ, v8::Handle<Value>()); |
| 11983 v8::Handle<Value> value = CompileRun( | 11983 v8::Handle<Value> value = CompileRun( |
| 11984 "function f() {" | 11984 "function f() {" |
| 11985 " for (var i = 0; i < 100; i++) {" | 11985 " for (var i = 0; i < 100; i++) {" |
| 11986 " try { x = 42; } catch(e) { return true; }" | 11986 " try { x = 42; } catch(e) { return true; }" |
| 11987 " }" | 11987 " }" |
| 11988 " return false;" | 11988 " return false;" |
| 11989 "};" | 11989 "};" |
| 11990 "f();"); | 11990 "f();"); |
| 11991 CHECK_EQ(true, value->BooleanValue()); | 11991 CHECK_EQ(true, value->BooleanValue()); |
| 11992 } | 11992 } |
| 11993 | 11993 |
| 11994 | 11994 |
| 11995 // Test that we ignore null interceptors. | 11995 // Test that we ignore null interceptors. |
| 11996 THREADED_TEST(NullNamedInterceptor) { | 11996 THREADED_TEST(NullNamedInterceptor) { |
| 11997 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 11997 v8::HandleScope scope(CcTest::isolate()); |
| 11998 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 11998 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 11999 templ->SetNamedPropertyHandler( | 11999 templ->SetNamedPropertyHandler( |
| 12000 static_cast<v8::NamedPropertyGetterCallback>(0)); | 12000 static_cast<v8::NamedPropertyGetterCallback>(0)); |
| 12001 LocalContext context; | 12001 LocalContext context; |
| 12002 templ->Set("x", v8_num(42)); | 12002 templ->Set("x", v8_num(42)); |
| 12003 v8::Handle<v8::Object> obj = templ->NewInstance(); | 12003 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 12004 context->Global()->Set(v8_str("obj"), obj); | 12004 context->Global()->Set(v8_str("obj"), obj); |
| 12005 v8::Handle<Value> value = CompileRun("obj.x"); | 12005 v8::Handle<Value> value = CompileRun("obj.x"); |
| 12006 CHECK(value->IsInt32()); | 12006 CHECK(value->IsInt32()); |
| 12007 CHECK_EQ(42, value->Int32Value()); | 12007 CHECK_EQ(42, value->Int32Value()); |
| 12008 } | 12008 } |
| 12009 | 12009 |
| 12010 | 12010 |
| 12011 // Test that we ignore null interceptors. | 12011 // Test that we ignore null interceptors. |
| 12012 THREADED_TEST(NullIndexedInterceptor) { | 12012 THREADED_TEST(NullIndexedInterceptor) { |
| 12013 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12013 v8::HandleScope scope(CcTest::isolate()); |
| 12014 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 12014 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 12015 templ->SetIndexedPropertyHandler( | 12015 templ->SetIndexedPropertyHandler( |
| 12016 static_cast<v8::IndexedPropertyGetterCallback>(0)); | 12016 static_cast<v8::IndexedPropertyGetterCallback>(0)); |
| 12017 LocalContext context; | 12017 LocalContext context; |
| 12018 templ->Set("42", v8_num(42)); | 12018 templ->Set("42", v8_num(42)); |
| 12019 v8::Handle<v8::Object> obj = templ->NewInstance(); | 12019 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 12020 context->Global()->Set(v8_str("obj"), obj); | 12020 context->Global()->Set(v8_str("obj"), obj); |
| 12021 v8::Handle<Value> value = CompileRun("obj[42]"); | 12021 v8::Handle<Value> value = CompileRun("obj[42]"); |
| 12022 CHECK(value->IsInt32()); | 12022 CHECK(value->IsInt32()); |
| 12023 CHECK_EQ(42, value->Int32Value()); | 12023 CHECK_EQ(42, value->Int32Value()); |
| 12024 } | 12024 } |
| 12025 | 12025 |
| 12026 | 12026 |
| 12027 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { | 12027 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { |
| 12028 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12028 v8::HandleScope scope(CcTest::isolate()); |
| 12029 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 12029 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 12030 templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter); | 12030 templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter); |
| 12031 LocalContext env; | 12031 LocalContext env; |
| 12032 env->Global()->Set(v8_str("obj"), | 12032 env->Global()->Set(v8_str("obj"), |
| 12033 templ->GetFunction()->NewInstance()); | 12033 templ->GetFunction()->NewInstance()); |
| 12034 ExpectTrue("obj.x === 42"); | 12034 ExpectTrue("obj.x === 42"); |
| 12035 ExpectTrue("!obj.propertyIsEnumerable('x')"); | 12035 ExpectTrue("!obj.propertyIsEnumerable('x')"); |
| 12036 } | 12036 } |
| 12037 | 12037 |
| 12038 | 12038 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12238 | 12238 |
| 12239 | 12239 |
| 12240 static void IsConstructHandler( | 12240 static void IsConstructHandler( |
| 12241 const v8::FunctionCallbackInfo<v8::Value>& args) { | 12241 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 12242 ApiTestFuzzer::Fuzz(); | 12242 ApiTestFuzzer::Fuzz(); |
| 12243 args.GetReturnValue().Set(args.IsConstructCall()); | 12243 args.GetReturnValue().Set(args.IsConstructCall()); |
| 12244 } | 12244 } |
| 12245 | 12245 |
| 12246 | 12246 |
| 12247 THREADED_TEST(IsConstructCall) { | 12247 THREADED_TEST(IsConstructCall) { |
| 12248 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12248 v8::HandleScope scope(CcTest::isolate()); |
| 12249 | 12249 |
| 12250 // Function template with call handler. | 12250 // Function template with call handler. |
| 12251 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 12251 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 12252 templ->SetCallHandler(IsConstructHandler); | 12252 templ->SetCallHandler(IsConstructHandler); |
| 12253 | 12253 |
| 12254 LocalContext context; | 12254 LocalContext context; |
| 12255 | 12255 |
| 12256 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 12256 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 12257 Local<Value> value = v8_compile("f()")->Run(); | 12257 Local<Value> value = v8_compile("f()")->Run(); |
| 12258 CHECK(!value->BooleanValue()); | 12258 CHECK(!value->BooleanValue()); |
| 12259 value = v8_compile("new f()")->Run(); | 12259 value = v8_compile("new f()")->Run(); |
| 12260 CHECK(value->BooleanValue()); | 12260 CHECK(value->BooleanValue()); |
| 12261 } | 12261 } |
| 12262 | 12262 |
| 12263 | 12263 |
| 12264 THREADED_TEST(ObjectProtoToString) { | 12264 THREADED_TEST(ObjectProtoToString) { |
| 12265 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12265 v8::HandleScope scope(CcTest::isolate()); |
| 12266 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 12266 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
| 12267 templ->SetClassName(v8_str("MyClass")); | 12267 templ->SetClassName(v8_str("MyClass")); |
| 12268 | 12268 |
| 12269 LocalContext context; | 12269 LocalContext context; |
| 12270 | 12270 |
| 12271 Local<String> customized_tostring = v8_str("customized toString"); | 12271 Local<String> customized_tostring = v8_str("customized toString"); |
| 12272 | 12272 |
| 12273 // Replace Object.prototype.toString | 12273 // Replace Object.prototype.toString |
| 12274 v8_compile("Object.prototype.toString = function() {" | 12274 v8_compile("Object.prototype.toString = function() {" |
| 12275 " return 'customized toString';" | 12275 " return 'customized toString';" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12635 CHECK_EQ(expected, count); | 12635 CHECK_EQ(expected, count); |
| 12636 } | 12636 } |
| 12637 | 12637 |
| 12638 | 12638 |
| 12639 TEST(DontLeakGlobalObjects) { | 12639 TEST(DontLeakGlobalObjects) { |
| 12640 // Regression test for issues 1139850 and 1174891. | 12640 // Regression test for issues 1139850 and 1174891. |
| 12641 | 12641 |
| 12642 v8::V8::Initialize(); | 12642 v8::V8::Initialize(); |
| 12643 | 12643 |
| 12644 for (int i = 0; i < 5; i++) { | 12644 for (int i = 0; i < 5; i++) { |
| 12645 { v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12645 { v8::HandleScope scope(CcTest::isolate()); |
| 12646 LocalContext context; | 12646 LocalContext context; |
| 12647 } | 12647 } |
| 12648 v8::V8::ContextDisposedNotification(); | 12648 v8::V8::ContextDisposedNotification(); |
| 12649 CheckSurvivingGlobalObjectsCount(0); | 12649 CheckSurvivingGlobalObjectsCount(0); |
| 12650 | 12650 |
| 12651 { v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12651 { v8::HandleScope scope(CcTest::isolate()); |
| 12652 LocalContext context; | 12652 LocalContext context; |
| 12653 v8_compile("Date")->Run(); | 12653 v8_compile("Date")->Run(); |
| 12654 } | 12654 } |
| 12655 v8::V8::ContextDisposedNotification(); | 12655 v8::V8::ContextDisposedNotification(); |
| 12656 CheckSurvivingGlobalObjectsCount(0); | 12656 CheckSurvivingGlobalObjectsCount(0); |
| 12657 | 12657 |
| 12658 { v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12658 { v8::HandleScope scope(CcTest::isolate()); |
| 12659 LocalContext context; | 12659 LocalContext context; |
| 12660 v8_compile("/aaa/")->Run(); | 12660 v8_compile("/aaa/")->Run(); |
| 12661 } | 12661 } |
| 12662 v8::V8::ContextDisposedNotification(); | 12662 v8::V8::ContextDisposedNotification(); |
| 12663 CheckSurvivingGlobalObjectsCount(0); | 12663 CheckSurvivingGlobalObjectsCount(0); |
| 12664 | 12664 |
| 12665 { v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12665 { v8::HandleScope scope(CcTest::isolate()); |
| 12666 const char* extension_list[] = { "v8/gc" }; | 12666 const char* extension_list[] = { "v8/gc" }; |
| 12667 v8::ExtensionConfiguration extensions(1, extension_list); | 12667 v8::ExtensionConfiguration extensions(1, extension_list); |
| 12668 LocalContext context(&extensions); | 12668 LocalContext context(&extensions); |
| 12669 v8_compile("gc();")->Run(); | 12669 v8_compile("gc();")->Run(); |
| 12670 } | 12670 } |
| 12671 v8::V8::ContextDisposedNotification(); | 12671 v8::V8::ContextDisposedNotification(); |
| 12672 CheckSurvivingGlobalObjectsCount(0); | 12672 CheckSurvivingGlobalObjectsCount(0); |
| 12673 } | 12673 } |
| 12674 } | 12674 } |
| 12675 | 12675 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12838 v8::V8::Initialize(); | 12838 v8::V8::Initialize(); |
| 12839 | 12839 |
| 12840 const int nof = 2; | 12840 const int nof = 2; |
| 12841 const char* sources[nof] = { | 12841 const char* sources[nof] = { |
| 12842 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", | 12842 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", |
| 12843 "Object()" | 12843 "Object()" |
| 12844 }; | 12844 }; |
| 12845 | 12845 |
| 12846 for (int i = 0; i < nof; i++) { | 12846 for (int i = 0; i < nof; i++) { |
| 12847 const char* source = sources[i]; | 12847 const char* source = sources[i]; |
| 12848 { v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12848 { v8::HandleScope scope(CcTest::isolate()); |
| 12849 LocalContext context; | 12849 LocalContext context; |
| 12850 CompileRun(source); | 12850 CompileRun(source); |
| 12851 } | 12851 } |
| 12852 { v8::HandleScope scope(v8::Isolate::GetCurrent()); | 12852 { v8::HandleScope scope(CcTest::isolate()); |
| 12853 LocalContext context; | 12853 LocalContext context; |
| 12854 CompileRun(source); | 12854 CompileRun(source); |
| 12855 } | 12855 } |
| 12856 } | 12856 } |
| 12857 } | 12857 } |
| 12858 | 12858 |
| 12859 | 12859 |
| 12860 static v8::Handle<Value> NestedScope(v8::Local<Context> env) { | 12860 static v8::Handle<Value> NestedScope(v8::Local<Context> env) { |
| 12861 v8::HandleScope inner(env->GetIsolate()); | 12861 v8::HandleScope inner(env->GetIsolate()); |
| 12862 env->Enter(); | 12862 env->Enter(); |
| 12863 v8::Handle<Value> three = v8_num(3); | 12863 v8::Handle<Value> three = v8_num(3); |
| 12864 v8::Handle<Value> value = inner.Close(three); | 12864 v8::Handle<Value> value = inner.Close(three); |
| 12865 env->Exit(); | 12865 env->Exit(); |
| 12866 return value; | 12866 return value; |
| 12867 } | 12867 } |
| 12868 | 12868 |
| 12869 | 12869 |
| 12870 THREADED_TEST(NestedHandleScopeAndContexts) { | 12870 THREADED_TEST(NestedHandleScopeAndContexts) { |
| 12871 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 12871 v8::Isolate* isolate = CcTest::isolate(); |
| 12872 v8::HandleScope outer(isolate); | 12872 v8::HandleScope outer(isolate); |
| 12873 v8::Local<Context> env = Context::New(isolate); | 12873 v8::Local<Context> env = Context::New(isolate); |
| 12874 env->Enter(); | 12874 env->Enter(); |
| 12875 v8::Handle<Value> value = NestedScope(env); | 12875 v8::Handle<Value> value = NestedScope(env); |
| 12876 v8::Handle<String> str(value->ToString()); | 12876 v8::Handle<String> str(value->ToString()); |
| 12877 CHECK(!str.IsEmpty()); | 12877 CHECK(!str.IsEmpty()); |
| 12878 env->Exit(); | 12878 env->Exit(); |
| 12879 } | 12879 } |
| 12880 | 12880 |
| 12881 | 12881 |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13460 | 13460 |
| 13461 isolate->Exit(); | 13461 isolate->Exit(); |
| 13462 isolate->Dispose(); | 13462 isolate->Dispose(); |
| 13463 } | 13463 } |
| 13464 | 13464 |
| 13465 | 13465 |
| 13466 static int64_t cast(intptr_t x) { return static_cast<int64_t>(x); } | 13466 static int64_t cast(intptr_t x) { return static_cast<int64_t>(x); } |
| 13467 | 13467 |
| 13468 | 13468 |
| 13469 THREADED_TEST(ExternalAllocatedMemory) { | 13469 THREADED_TEST(ExternalAllocatedMemory) { |
| 13470 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 13470 v8::Isolate* isolate = CcTest::isolate(); |
| 13471 v8::HandleScope outer(isolate); | 13471 v8::HandleScope outer(isolate); |
| 13472 v8::Local<Context> env(Context::New(isolate)); | 13472 v8::Local<Context> env(Context::New(isolate)); |
| 13473 CHECK(!env.IsEmpty()); | 13473 CHECK(!env.IsEmpty()); |
| 13474 const intptr_t kSize = 1024*1024; | 13474 const intptr_t kSize = 1024*1024; |
| 13475 int64_t baseline = cast(isolate->AdjustAmountOfExternalAllocatedMemory(0)); | 13475 int64_t baseline = cast(isolate->AdjustAmountOfExternalAllocatedMemory(0)); |
| 13476 CHECK_EQ(baseline + cast(kSize), | 13476 CHECK_EQ(baseline + cast(kSize), |
| 13477 cast(isolate->AdjustAmountOfExternalAllocatedMemory(kSize))); | 13477 cast(isolate->AdjustAmountOfExternalAllocatedMemory(kSize))); |
| 13478 CHECK_EQ(baseline, | 13478 CHECK_EQ(baseline, |
| 13479 cast(isolate->AdjustAmountOfExternalAllocatedMemory(-kSize))); | 13479 cast(isolate->AdjustAmountOfExternalAllocatedMemory(-kSize))); |
| 13480 } | 13480 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13535 "" | 13535 "" |
| 13536 "f();")); | 13536 "f();")); |
| 13537 v8::Handle<v8::Value> result = script->Run(); | 13537 v8::Handle<v8::Value> result = script->Run(); |
| 13538 CHECK(result.IsEmpty()); | 13538 CHECK(result.IsEmpty()); |
| 13539 } | 13539 } |
| 13540 | 13540 |
| 13541 | 13541 |
| 13542 static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script, | 13542 static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script, |
| 13543 const char* resource_name, | 13543 const char* resource_name, |
| 13544 int line_offset) { | 13544 int line_offset) { |
| 13545 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 13545 v8::HandleScope scope(CcTest::isolate()); |
| 13546 v8::TryCatch try_catch; | 13546 v8::TryCatch try_catch; |
| 13547 v8::Handle<v8::Value> result = script->Run(); | 13547 v8::Handle<v8::Value> result = script->Run(); |
| 13548 CHECK(result.IsEmpty()); | 13548 CHECK(result.IsEmpty()); |
| 13549 CHECK(try_catch.HasCaught()); | 13549 CHECK(try_catch.HasCaught()); |
| 13550 v8::Handle<v8::Message> message = try_catch.Message(); | 13550 v8::Handle<v8::Message> message = try_catch.Message(); |
| 13551 CHECK(!message.IsEmpty()); | 13551 CHECK(!message.IsEmpty()); |
| 13552 CHECK_EQ(10 + line_offset, message->GetLineNumber()); | 13552 CHECK_EQ(10 + line_offset, message->GetLineNumber()); |
| 13553 CHECK_EQ(91, message->GetStartPosition()); | 13553 CHECK_EQ(91, message->GetStartPosition()); |
| 13554 CHECK_EQ(92, message->GetEndPosition()); | 13554 CHECK_EQ(92, message->GetEndPosition()); |
| 13555 CHECK_EQ(2, message->GetStartColumn()); | 13555 CHECK_EQ(2, message->GetStartColumn()); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13808 context->Global()->Set(v8_str("obj_2"), instance_2); | 13808 context->Global()->Set(v8_str("obj_2"), instance_2); |
| 13809 | 13809 |
| 13810 Local<Value> value_2 = CompileRun("obj_2.a"); | 13810 Local<Value> value_2 = CompileRun("obj_2.a"); |
| 13811 CHECK(value_2->IsUndefined()); | 13811 CHECK(value_2->IsUndefined()); |
| 13812 } | 13812 } |
| 13813 | 13813 |
| 13814 | 13814 |
| 13815 // This tests that access check information remains on the global | 13815 // This tests that access check information remains on the global |
| 13816 // object template when creating contexts. | 13816 // object template when creating contexts. |
| 13817 THREADED_TEST(AccessControlRepeatedContextCreation) { | 13817 THREADED_TEST(AccessControlRepeatedContextCreation) { |
| 13818 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 13818 v8::Isolate* isolate = CcTest::isolate(); |
| 13819 v8::HandleScope handle_scope(isolate); | 13819 v8::HandleScope handle_scope(isolate); |
| 13820 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 13820 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 13821 global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker, | 13821 global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker, |
| 13822 IndexedSetAccessBlocker); | 13822 IndexedSetAccessBlocker); |
| 13823 i::Handle<i::ObjectTemplateInfo> internal_template = | 13823 i::Handle<i::ObjectTemplateInfo> internal_template = |
| 13824 v8::Utils::OpenHandle(*global_template); | 13824 v8::Utils::OpenHandle(*global_template); |
| 13825 CHECK(!internal_template->constructor()->IsUndefined()); | 13825 CHECK(!internal_template->constructor()->IsUndefined()); |
| 13826 i::Handle<i::FunctionTemplateInfo> constructor( | 13826 i::Handle<i::FunctionTemplateInfo> constructor( |
| 13827 i::FunctionTemplateInfo::cast(internal_template->constructor())); | 13827 i::FunctionTemplateInfo::cast(internal_template->constructor())); |
| 13828 CHECK(!constructor->access_check_info()->IsUndefined()); | 13828 CHECK(!constructor->access_check_info()->IsUndefined()); |
| 13829 v8::Local<Context> context0(Context::New(isolate, NULL, global_template)); | 13829 v8::Local<Context> context0(Context::New(isolate, NULL, global_template)); |
| 13830 CHECK(!context0.IsEmpty()); | 13830 CHECK(!context0.IsEmpty()); |
| 13831 CHECK(!constructor->access_check_info()->IsUndefined()); | 13831 CHECK(!constructor->access_check_info()->IsUndefined()); |
| 13832 } | 13832 } |
| 13833 | 13833 |
| 13834 | 13834 |
| 13835 THREADED_TEST(TurnOnAccessCheck) { | 13835 THREADED_TEST(TurnOnAccessCheck) { |
| 13836 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 13836 v8::Isolate* isolate = CcTest::isolate(); |
| 13837 v8::HandleScope handle_scope(isolate); | 13837 v8::HandleScope handle_scope(isolate); |
| 13838 | 13838 |
| 13839 // Create an environment with access check to the global object disabled by | 13839 // Create an environment with access check to the global object disabled by |
| 13840 // default. | 13840 // default. |
| 13841 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 13841 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 13842 global_template->SetAccessCheckCallbacks(NamedGetAccessBlocker, | 13842 global_template->SetAccessCheckCallbacks(NamedGetAccessBlocker, |
| 13843 IndexedGetAccessBlocker, | 13843 IndexedGetAccessBlocker, |
| 13844 v8::Handle<v8::Value>(), | 13844 v8::Handle<v8::Value>(), |
| 13845 false); | 13845 false); |
| 13846 v8::Local<Context> context = Context::New(isolate, NULL, global_template); | 13846 v8::Local<Context> context = Context::New(isolate, NULL, global_template); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13907 Local<Value> data) { | 13907 Local<Value> data) { |
| 13908 if (!name->IsString()) return false; | 13908 if (!name->IsString()) return false; |
| 13909 i::Handle<i::String> name_handle = | 13909 i::Handle<i::String> name_handle = |
| 13910 v8::Utils::OpenHandle(String::Cast(*name)); | 13910 v8::Utils::OpenHandle(String::Cast(*name)); |
| 13911 return !name_handle->IsUtf8EqualTo(i::CStrVector(kPropertyA)) | 13911 return !name_handle->IsUtf8EqualTo(i::CStrVector(kPropertyA)) |
| 13912 && !name_handle->IsUtf8EqualTo(i::CStrVector(kPropertyH)); | 13912 && !name_handle->IsUtf8EqualTo(i::CStrVector(kPropertyH)); |
| 13913 } | 13913 } |
| 13914 | 13914 |
| 13915 | 13915 |
| 13916 THREADED_TEST(TurnOnAccessCheckAndRecompile) { | 13916 THREADED_TEST(TurnOnAccessCheckAndRecompile) { |
| 13917 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 13917 v8::Isolate* isolate = CcTest::isolate(); |
| 13918 v8::HandleScope handle_scope(isolate); | 13918 v8::HandleScope handle_scope(isolate); |
| 13919 | 13919 |
| 13920 // Create an environment with access check to the global object disabled by | 13920 // Create an environment with access check to the global object disabled by |
| 13921 // default. When the registered access checker will block access to properties | 13921 // default. When the registered access checker will block access to properties |
| 13922 // a and h. | 13922 // a and h. |
| 13923 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 13923 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 13924 global_template->SetAccessCheckCallbacks(NamedGetAccessBlockAandH, | 13924 global_template->SetAccessCheckCallbacks(NamedGetAccessBlockAandH, |
| 13925 IndexedGetAccessBlocker, | 13925 IndexedGetAccessBlocker, |
| 13926 v8::Handle<v8::Value>(), | 13926 v8::Handle<v8::Value>(), |
| 13927 false); | 13927 false); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14119 CHECK(!try_catch.HasCaught()); | 14119 CHECK(!try_catch.HasCaught()); |
| 14120 | 14120 |
| 14121 delete sd; | 14121 delete sd; |
| 14122 } | 14122 } |
| 14123 | 14123 |
| 14124 | 14124 |
| 14125 // Verifies that the Handle<String> and const char* versions of the API produce | 14125 // Verifies that the Handle<String> and const char* versions of the API produce |
| 14126 // the same results (at least for one trivial case). | 14126 // the same results (at least for one trivial case). |
| 14127 TEST(PreCompileAPIVariationsAreSame) { | 14127 TEST(PreCompileAPIVariationsAreSame) { |
| 14128 v8::V8::Initialize(); | 14128 v8::V8::Initialize(); |
| 14129 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14129 v8::HandleScope scope(CcTest::isolate()); |
| 14130 | 14130 |
| 14131 const char* cstring = "function foo(a) { return a+1; }"; | 14131 const char* cstring = "function foo(a) { return a+1; }"; |
| 14132 | 14132 |
| 14133 v8::ScriptData* sd_from_cstring = | 14133 v8::ScriptData* sd_from_cstring = |
| 14134 v8::ScriptData::PreCompile(cstring, i::StrLength(cstring)); | 14134 v8::ScriptData::PreCompile(cstring, i::StrLength(cstring)); |
| 14135 | 14135 |
| 14136 TestAsciiResource* resource = new TestAsciiResource(cstring); | 14136 TestAsciiResource* resource = new TestAsciiResource(cstring); |
| 14137 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile( | 14137 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile( |
| 14138 v8::String::NewExternal(resource)); | 14138 v8::String::NewExternal(resource)); |
| 14139 | 14139 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 14156 delete sd_from_string; | 14156 delete sd_from_string; |
| 14157 } | 14157 } |
| 14158 | 14158 |
| 14159 | 14159 |
| 14160 // This tests that we do not allow dictionary load/call inline caches | 14160 // This tests that we do not allow dictionary load/call inline caches |
| 14161 // to use functions that have not yet been compiled. The potential | 14161 // to use functions that have not yet been compiled. The potential |
| 14162 // problem of loading a function that has not yet been compiled can | 14162 // problem of loading a function that has not yet been compiled can |
| 14163 // arise because we share code between contexts via the compilation | 14163 // arise because we share code between contexts via the compilation |
| 14164 // cache. | 14164 // cache. |
| 14165 THREADED_TEST(DictionaryICLoadedFunction) { | 14165 THREADED_TEST(DictionaryICLoadedFunction) { |
| 14166 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14166 v8::HandleScope scope(CcTest::isolate()); |
| 14167 // Test LoadIC. | 14167 // Test LoadIC. |
| 14168 for (int i = 0; i < 2; i++) { | 14168 for (int i = 0; i < 2; i++) { |
| 14169 LocalContext context; | 14169 LocalContext context; |
| 14170 context->Global()->Set(v8_str("tmp"), v8::True()); | 14170 context->Global()->Set(v8_str("tmp"), v8::True()); |
| 14171 context->Global()->Delete(v8_str("tmp")); | 14171 context->Global()->Delete(v8_str("tmp")); |
| 14172 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); | 14172 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); |
| 14173 } | 14173 } |
| 14174 // Test CallIC. | 14174 // Test CallIC. |
| 14175 for (int i = 0; i < 2; i++) { | 14175 for (int i = 0; i < 2; i++) { |
| 14176 LocalContext context; | 14176 LocalContext context; |
| 14177 context->Global()->Set(v8_str("tmp"), v8::True()); | 14177 context->Global()->Set(v8_str("tmp"), v8::True()); |
| 14178 context->Global()->Delete(v8_str("tmp")); | 14178 context->Global()->Delete(v8_str("tmp")); |
| 14179 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); | 14179 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); |
| 14180 } | 14180 } |
| 14181 } | 14181 } |
| 14182 | 14182 |
| 14183 | 14183 |
| 14184 // Test that cross-context new calls use the context of the callee to | 14184 // Test that cross-context new calls use the context of the callee to |
| 14185 // create the new JavaScript object. | 14185 // create the new JavaScript object. |
| 14186 THREADED_TEST(CrossContextNew) { | 14186 THREADED_TEST(CrossContextNew) { |
| 14187 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 14187 v8::Isolate* isolate = CcTest::isolate(); |
| 14188 v8::HandleScope scope(isolate); | 14188 v8::HandleScope scope(isolate); |
| 14189 v8::Local<Context> context0 = Context::New(isolate); | 14189 v8::Local<Context> context0 = Context::New(isolate); |
| 14190 v8::Local<Context> context1 = Context::New(isolate); | 14190 v8::Local<Context> context1 = Context::New(isolate); |
| 14191 | 14191 |
| 14192 // Allow cross-domain access. | 14192 // Allow cross-domain access. |
| 14193 Local<String> token = v8_str("<security token>"); | 14193 Local<String> token = v8_str("<security token>"); |
| 14194 context0->SetSecurityToken(token); | 14194 context0->SetSecurityToken(token); |
| 14195 context1->SetSecurityToken(token); | 14195 context1->SetSecurityToken(token); |
| 14196 | 14196 |
| 14197 // Set an 'x' property on the Object prototype and define a | 14197 // Set an 'x' property on the Object prototype and define a |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14700 } | 14700 } |
| 14701 morph_success_ = true; | 14701 morph_success_ = true; |
| 14702 } | 14702 } |
| 14703 | 14703 |
| 14704 void LongRunningRegExp() { | 14704 void LongRunningRegExp() { |
| 14705 block_.Signal(); // Enable morphing thread on next preemption. | 14705 block_.Signal(); // Enable morphing thread on next preemption. |
| 14706 while (morphs_during_regexp_ < kRequiredModifications && | 14706 while (morphs_during_regexp_ < kRequiredModifications && |
| 14707 morphs_ < kMaxModifications) { | 14707 morphs_ < kMaxModifications) { |
| 14708 int morphs_before = morphs_; | 14708 int morphs_before = morphs_; |
| 14709 { | 14709 { |
| 14710 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14710 v8::HandleScope scope(CcTest::isolate()); |
| 14711 // Match 15-30 "a"'s against 14 and a "b". | 14711 // Match 15-30 "a"'s against 14 and a "b". |
| 14712 const char* c_source = | 14712 const char* c_source = |
| 14713 "/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/" | 14713 "/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/" |
| 14714 ".exec(input) === null"; | 14714 ".exec(input) === null"; |
| 14715 Local<String> source = String::New(c_source); | 14715 Local<String> source = String::New(c_source); |
| 14716 Local<Script> script = Script::Compile(source); | 14716 Local<Script> script = Script::Compile(source); |
| 14717 Local<Value> result = script->Run(); | 14717 Local<Value> result = script->Run(); |
| 14718 CHECK(result->IsTrue()); | 14718 CHECK(result->IsTrue()); |
| 14719 } | 14719 } |
| 14720 int morphs_after = morphs_; | 14720 int morphs_after = morphs_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14755 RegExpStringModificationTest().RunTest(); | 14755 RegExpStringModificationTest().RunTest(); |
| 14756 | 14756 |
| 14757 local_env->Exit(); | 14757 local_env->Exit(); |
| 14758 } | 14758 } |
| 14759 | 14759 |
| 14760 | 14760 |
| 14761 // Test that we cannot set a property on the global object if there | 14761 // Test that we cannot set a property on the global object if there |
| 14762 // is a read-only property in the prototype chain. | 14762 // is a read-only property in the prototype chain. |
| 14763 TEST(ReadOnlyPropertyInGlobalProto) { | 14763 TEST(ReadOnlyPropertyInGlobalProto) { |
| 14764 i::FLAG_es5_readonly = true; | 14764 i::FLAG_es5_readonly = true; |
| 14765 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14765 v8::HandleScope scope(CcTest::isolate()); |
| 14766 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14766 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14767 LocalContext context(0, templ); | 14767 LocalContext context(0, templ); |
| 14768 v8::Handle<v8::Object> global = context->Global(); | 14768 v8::Handle<v8::Object> global = context->Global(); |
| 14769 v8::Handle<v8::Object> global_proto = | 14769 v8::Handle<v8::Object> global_proto = |
| 14770 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); | 14770 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__"))); |
| 14771 global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly); | 14771 global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly); |
| 14772 global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly); | 14772 global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly); |
| 14773 // Check without 'eval' or 'with'. | 14773 // Check without 'eval' or 'with'. |
| 14774 v8::Handle<v8::Value> res = | 14774 v8::Handle<v8::Value> res = |
| 14775 CompileRun("function f() { x = 42; return x; }; f()"); | 14775 CompileRun("function f() { x = 42; return x; }; f()"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14808 force_set_set_count++; | 14808 force_set_set_count++; |
| 14809 info.GetReturnValue().SetUndefined(); | 14809 info.GetReturnValue().SetUndefined(); |
| 14810 } | 14810 } |
| 14811 | 14811 |
| 14812 | 14812 |
| 14813 TEST(ForceSet) { | 14813 TEST(ForceSet) { |
| 14814 force_set_get_count = 0; | 14814 force_set_get_count = 0; |
| 14815 force_set_set_count = 0; | 14815 force_set_set_count = 0; |
| 14816 pass_on_get = false; | 14816 pass_on_get = false; |
| 14817 | 14817 |
| 14818 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14818 v8::HandleScope scope(CcTest::isolate()); |
| 14819 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14819 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14820 v8::Handle<v8::String> access_property = v8::String::New("a"); | 14820 v8::Handle<v8::String> access_property = v8::String::New("a"); |
| 14821 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); | 14821 templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter); |
| 14822 LocalContext context(NULL, templ); | 14822 LocalContext context(NULL, templ); |
| 14823 v8::Handle<v8::Object> global = context->Global(); | 14823 v8::Handle<v8::Object> global = context->Global(); |
| 14824 | 14824 |
| 14825 // Ordinary properties | 14825 // Ordinary properties |
| 14826 v8::Handle<v8::String> simple_property = v8::String::New("p"); | 14826 v8::Handle<v8::String> simple_property = v8::String::New("p"); |
| 14827 global->Set(simple_property, v8::Int32::New(4), v8::ReadOnly); | 14827 global->Set(simple_property, v8::Int32::New(4), v8::ReadOnly); |
| 14828 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 14828 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 14850 CHECK_EQ(1, force_set_set_count); | 14850 CHECK_EQ(1, force_set_set_count); |
| 14851 CHECK_EQ(2, force_set_get_count); | 14851 CHECK_EQ(2, force_set_get_count); |
| 14852 } | 14852 } |
| 14853 | 14853 |
| 14854 | 14854 |
| 14855 TEST(ForceSetWithInterceptor) { | 14855 TEST(ForceSetWithInterceptor) { |
| 14856 force_set_get_count = 0; | 14856 force_set_get_count = 0; |
| 14857 force_set_set_count = 0; | 14857 force_set_set_count = 0; |
| 14858 pass_on_get = false; | 14858 pass_on_get = false; |
| 14859 | 14859 |
| 14860 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14860 v8::HandleScope scope(CcTest::isolate()); |
| 14861 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14861 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14862 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); | 14862 templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter); |
| 14863 LocalContext context(NULL, templ); | 14863 LocalContext context(NULL, templ); |
| 14864 v8::Handle<v8::Object> global = context->Global(); | 14864 v8::Handle<v8::Object> global = context->Global(); |
| 14865 | 14865 |
| 14866 v8::Handle<v8::String> some_property = v8::String::New("a"); | 14866 v8::Handle<v8::String> some_property = v8::String::New("a"); |
| 14867 CHECK_EQ(0, force_set_set_count); | 14867 CHECK_EQ(0, force_set_set_count); |
| 14868 CHECK_EQ(0, force_set_get_count); | 14868 CHECK_EQ(0, force_set_get_count); |
| 14869 CHECK_EQ(3, global->Get(some_property)->Int32Value()); | 14869 CHECK_EQ(3, global->Get(some_property)->Int32Value()); |
| 14870 // Setting the property shouldn't override it, just call the setter | 14870 // Setting the property shouldn't override it, just call the setter |
| (...skipping 22 matching lines...) Expand all Loading... |
| 14893 CHECK_EQ(1, force_set_set_count); | 14893 CHECK_EQ(1, force_set_set_count); |
| 14894 CHECK_EQ(5, force_set_get_count); | 14894 CHECK_EQ(5, force_set_get_count); |
| 14895 // The interceptor should also work for other properties | 14895 // The interceptor should also work for other properties |
| 14896 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value()); | 14896 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value()); |
| 14897 CHECK_EQ(1, force_set_set_count); | 14897 CHECK_EQ(1, force_set_set_count); |
| 14898 CHECK_EQ(6, force_set_get_count); | 14898 CHECK_EQ(6, force_set_get_count); |
| 14899 } | 14899 } |
| 14900 | 14900 |
| 14901 | 14901 |
| 14902 THREADED_TEST(ForceDelete) { | 14902 THREADED_TEST(ForceDelete) { |
| 14903 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14903 v8::HandleScope scope(CcTest::isolate()); |
| 14904 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14904 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14905 LocalContext context(NULL, templ); | 14905 LocalContext context(NULL, templ); |
| 14906 v8::Handle<v8::Object> global = context->Global(); | 14906 v8::Handle<v8::Object> global = context->Global(); |
| 14907 | 14907 |
| 14908 // Ordinary properties | 14908 // Ordinary properties |
| 14909 v8::Handle<v8::String> simple_property = v8::String::New("p"); | 14909 v8::Handle<v8::String> simple_property = v8::String::New("p"); |
| 14910 global->Set(simple_property, v8::Int32::New(4), v8::DontDelete); | 14910 global->Set(simple_property, v8::Int32::New(4), v8::DontDelete); |
| 14911 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); | 14911 CHECK_EQ(4, global->Get(simple_property)->Int32Value()); |
| 14912 // This should fail because the property is dont-delete. | 14912 // This should fail because the property is dont-delete. |
| 14913 CHECK(!global->Delete(simple_property)); | 14913 CHECK(!global->Delete(simple_property)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 14928 force_delete_interceptor_count++; | 14928 force_delete_interceptor_count++; |
| 14929 if (pass_on_delete) return; | 14929 if (pass_on_delete) return; |
| 14930 info.GetReturnValue().Set(true); | 14930 info.GetReturnValue().Set(true); |
| 14931 } | 14931 } |
| 14932 | 14932 |
| 14933 | 14933 |
| 14934 THREADED_TEST(ForceDeleteWithInterceptor) { | 14934 THREADED_TEST(ForceDeleteWithInterceptor) { |
| 14935 force_delete_interceptor_count = 0; | 14935 force_delete_interceptor_count = 0; |
| 14936 pass_on_delete = false; | 14936 pass_on_delete = false; |
| 14937 | 14937 |
| 14938 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 14938 v8::HandleScope scope(CcTest::isolate()); |
| 14939 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); | 14939 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(); |
| 14940 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); | 14940 templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter); |
| 14941 LocalContext context(NULL, templ); | 14941 LocalContext context(NULL, templ); |
| 14942 v8::Handle<v8::Object> global = context->Global(); | 14942 v8::Handle<v8::Object> global = context->Global(); |
| 14943 | 14943 |
| 14944 v8::Handle<v8::String> some_property = v8::String::New("a"); | 14944 v8::Handle<v8::String> some_property = v8::String::New("a"); |
| 14945 global->Set(some_property, v8::Integer::New(42), v8::DontDelete); | 14945 global->Set(some_property, v8::Integer::New(42), v8::DontDelete); |
| 14946 | 14946 |
| 14947 // Deleting a property should get intercepted and nothing should | 14947 // Deleting a property should get intercepted and nothing should |
| 14948 // happen. | 14948 // happen. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14981 CHECK(context->Global()->ForceDelete(v8_str("foo"))); | 14981 CHECK(context->Global()->ForceDelete(v8_str("foo"))); |
| 14982 // Make sure the value for foo is read from the prototype, and that | 14982 // Make sure the value for foo is read from the prototype, and that |
| 14983 // we don't get in trouble with reading the deleted cell value | 14983 // we don't get in trouble with reading the deleted cell value |
| 14984 // sentinel. | 14984 // sentinel. |
| 14985 CHECK_EQ(5, CompileRun("f()")->Int32Value()); | 14985 CHECK_EQ(5, CompileRun("f()")->Int32Value()); |
| 14986 } | 14986 } |
| 14987 | 14987 |
| 14988 | 14988 |
| 14989 TEST(InlinedFunctionAcrossContexts) { | 14989 TEST(InlinedFunctionAcrossContexts) { |
| 14990 i::FLAG_allow_natives_syntax = true; | 14990 i::FLAG_allow_natives_syntax = true; |
| 14991 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 14991 v8::Isolate* isolate = CcTest::isolate(); |
| 14992 v8::HandleScope outer_scope(isolate); | 14992 v8::HandleScope outer_scope(isolate); |
| 14993 v8::Local<v8::Context> ctx1 = v8::Context::New(isolate); | 14993 v8::Local<v8::Context> ctx1 = v8::Context::New(isolate); |
| 14994 v8::Local<v8::Context> ctx2 = v8::Context::New(isolate); | 14994 v8::Local<v8::Context> ctx2 = v8::Context::New(isolate); |
| 14995 ctx1->Enter(); | 14995 ctx1->Enter(); |
| 14996 | 14996 |
| 14997 { | 14997 { |
| 14998 v8::HandleScope inner_scope(v8::Isolate::GetCurrent()); | 14998 v8::HandleScope inner_scope(CcTest::isolate()); |
| 14999 CompileRun("var G = 42; function foo() { return G; }"); | 14999 CompileRun("var G = 42; function foo() { return G; }"); |
| 15000 v8::Local<v8::Value> foo = ctx1->Global()->Get(v8_str("foo")); | 15000 v8::Local<v8::Value> foo = ctx1->Global()->Get(v8_str("foo")); |
| 15001 ctx2->Enter(); | 15001 ctx2->Enter(); |
| 15002 ctx2->Global()->Set(v8_str("o"), foo); | 15002 ctx2->Global()->Set(v8_str("o"), foo); |
| 15003 v8::Local<v8::Value> res = CompileRun( | 15003 v8::Local<v8::Value> res = CompileRun( |
| 15004 "function f() { return o(); }" | 15004 "function f() { return o(); }" |
| 15005 "for (var i = 0; i < 10; ++i) f();" | 15005 "for (var i = 0; i < 10; ++i) f();" |
| 15006 "%OptimizeFunctionOnNextCall(f);" | 15006 "%OptimizeFunctionOnNextCall(f);" |
| 15007 "f();"); | 15007 "f();"); |
| 15008 CHECK_EQ(42, res->Int32Value()); | 15008 CHECK_EQ(42, res->Int32Value()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15050 CHECK(isolate->context() == NULL); | 15050 CHECK(isolate->context() == NULL); |
| 15051 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | 15051 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); |
| 15052 v8::HandleScope scope(v8_isolate); | 15052 v8::HandleScope scope(v8_isolate); |
| 15053 // The following should not crash, but return an empty handle. | 15053 // The following should not crash, but return an empty handle. |
| 15054 v8::Local<v8::Context> current = v8_isolate->GetCurrentContext(); | 15054 v8::Local<v8::Context> current = v8_isolate->GetCurrentContext(); |
| 15055 CHECK(current.IsEmpty()); | 15055 CHECK(current.IsEmpty()); |
| 15056 } | 15056 } |
| 15057 | 15057 |
| 15058 | 15058 |
| 15059 THREADED_TEST(GetCallingContext) { | 15059 THREADED_TEST(GetCallingContext) { |
| 15060 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 15060 v8::Isolate* isolate = CcTest::isolate(); |
| 15061 v8::HandleScope scope(isolate); | 15061 v8::HandleScope scope(isolate); |
| 15062 | 15062 |
| 15063 Local<Context> calling_context0(Context::New(isolate)); | 15063 Local<Context> calling_context0(Context::New(isolate)); |
| 15064 Local<Context> calling_context1(Context::New(isolate)); | 15064 Local<Context> calling_context1(Context::New(isolate)); |
| 15065 Local<Context> calling_context2(Context::New(isolate)); | 15065 Local<Context> calling_context2(Context::New(isolate)); |
| 15066 ::calling_context0 = calling_context0; | 15066 ::calling_context0 = calling_context0; |
| 15067 ::calling_context1 = calling_context1; | 15067 ::calling_context1 = calling_context1; |
| 15068 ::calling_context2 = calling_context2; | 15068 ::calling_context2 = calling_context2; |
| 15069 | 15069 |
| 15070 // Allow cross-domain access. | 15070 // Allow cross-domain access. |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16462 v8::String::Utf8Value stack(try_catch.StackTrace()); | 16462 v8::String::Utf8Value stack(try_catch.StackTrace()); |
| 16463 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); | 16463 CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL); |
| 16464 } | 16464 } |
| 16465 | 16465 |
| 16466 | 16466 |
| 16467 // Checks that a StackFrame has certain expected values. | 16467 // Checks that a StackFrame has certain expected values. |
| 16468 void checkStackFrame(const char* expected_script_name, | 16468 void checkStackFrame(const char* expected_script_name, |
| 16469 const char* expected_func_name, int expected_line_number, | 16469 const char* expected_func_name, int expected_line_number, |
| 16470 int expected_column, bool is_eval, bool is_constructor, | 16470 int expected_column, bool is_eval, bool is_constructor, |
| 16471 v8::Handle<v8::StackFrame> frame) { | 16471 v8::Handle<v8::StackFrame> frame) { |
| 16472 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16472 v8::HandleScope scope(CcTest::isolate()); |
| 16473 v8::String::Utf8Value func_name(frame->GetFunctionName()); | 16473 v8::String::Utf8Value func_name(frame->GetFunctionName()); |
| 16474 v8::String::Utf8Value script_name(frame->GetScriptName()); | 16474 v8::String::Utf8Value script_name(frame->GetScriptName()); |
| 16475 if (*script_name == NULL) { | 16475 if (*script_name == NULL) { |
| 16476 // The situation where there is no associated script, like for evals. | 16476 // The situation where there is no associated script, like for evals. |
| 16477 CHECK(expected_script_name == NULL); | 16477 CHECK(expected_script_name == NULL); |
| 16478 } else { | 16478 } else { |
| 16479 CHECK(strstr(*script_name, expected_script_name) != NULL); | 16479 CHECK(strstr(*script_name, expected_script_name) != NULL); |
| 16480 } | 16480 } |
| 16481 CHECK(strstr(*func_name, expected_func_name) != NULL); | 16481 CHECK(strstr(*func_name, expected_func_name) != NULL); |
| 16482 CHECK_EQ(expected_line_number, frame->GetLineNumber()); | 16482 CHECK_EQ(expected_line_number, frame->GetLineNumber()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16534 | 16534 |
| 16535 CHECK(stackTrace->AsArray()->IsArray()); | 16535 CHECK(stackTrace->AsArray()->IsArray()); |
| 16536 } | 16536 } |
| 16537 } | 16537 } |
| 16538 | 16538 |
| 16539 | 16539 |
| 16540 // Tests the C++ StackTrace API. | 16540 // Tests the C++ StackTrace API. |
| 16541 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. | 16541 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. |
| 16542 // THREADED_TEST(CaptureStackTrace) { | 16542 // THREADED_TEST(CaptureStackTrace) { |
| 16543 TEST(CaptureStackTrace) { | 16543 TEST(CaptureStackTrace) { |
| 16544 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16544 v8::HandleScope scope(CcTest::isolate()); |
| 16545 v8::Handle<v8::String> origin = v8::String::New("capture-stack-trace-test"); | 16545 v8::Handle<v8::String> origin = v8::String::New("capture-stack-trace-test"); |
| 16546 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16546 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16547 templ->Set(v8_str("AnalyzeStackInNativeCode"), | 16547 templ->Set(v8_str("AnalyzeStackInNativeCode"), |
| 16548 v8::FunctionTemplate::New(AnalyzeStackInNativeCode)); | 16548 v8::FunctionTemplate::New(AnalyzeStackInNativeCode)); |
| 16549 LocalContext context(0, templ); | 16549 LocalContext context(0, templ); |
| 16550 | 16550 |
| 16551 // Test getting OVERVIEW information. Should ignore information that is not | 16551 // Test getting OVERVIEW information. Should ignore information that is not |
| 16552 // script name, function name, line number, and column offset. | 16552 // script name, function name, line number, and column offset. |
| 16553 const char *overview_source = | 16553 const char *overview_source = |
| 16554 "function bar() {\n" | 16554 "function bar() {\n" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16783 for (int i = 0; i < 3; i++) { | 16783 for (int i = 0; i < 3; i++) { |
| 16784 v8::Handle<v8::String> name = | 16784 v8::Handle<v8::String> name = |
| 16785 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16785 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16786 CHECK(!name.IsEmpty()); | 16786 CHECK(!name.IsEmpty()); |
| 16787 CHECK_EQ(url, name); | 16787 CHECK_EQ(url, name); |
| 16788 } | 16788 } |
| 16789 } | 16789 } |
| 16790 | 16790 |
| 16791 | 16791 |
| 16792 TEST(SourceURLInStackTrace) { | 16792 TEST(SourceURLInStackTrace) { |
| 16793 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16793 v8::HandleScope scope(CcTest::isolate()); |
| 16794 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16794 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16795 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), | 16795 templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"), |
| 16796 v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL)); | 16796 v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL)); |
| 16797 LocalContext context(0, templ); | 16797 LocalContext context(0, templ); |
| 16798 | 16798 |
| 16799 const char *source = | 16799 const char *source = |
| 16800 "function outer() {\n" | 16800 "function outer() {\n" |
| 16801 "function bar() {\n" | 16801 "function bar() {\n" |
| 16802 " AnalyzeStackOfEvalWithSourceURL();\n" | 16802 " AnalyzeStackOfEvalWithSourceURL();\n" |
| 16803 "}\n" | 16803 "}\n" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 16825 v8::Handle<v8::StackTrace> stackTrace = | 16825 v8::Handle<v8::StackTrace> stackTrace = |
| 16826 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kScriptId); | 16826 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kScriptId); |
| 16827 CHECK_EQ(2, stackTrace->GetFrameCount()); | 16827 CHECK_EQ(2, stackTrace->GetFrameCount()); |
| 16828 for (int i = 0; i < 2; i++) { | 16828 for (int i = 0; i < 2; i++) { |
| 16829 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); | 16829 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); |
| 16830 } | 16830 } |
| 16831 } | 16831 } |
| 16832 | 16832 |
| 16833 | 16833 |
| 16834 TEST(ScriptIdInStackTrace) { | 16834 TEST(ScriptIdInStackTrace) { |
| 16835 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16835 v8::HandleScope scope(CcTest::isolate()); |
| 16836 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16836 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16837 templ->Set(v8_str("AnalyzeScriptIdInStack"), | 16837 templ->Set(v8_str("AnalyzeScriptIdInStack"), |
| 16838 v8::FunctionTemplate::New(AnalyzeScriptIdInStack)); | 16838 v8::FunctionTemplate::New(AnalyzeScriptIdInStack)); |
| 16839 LocalContext context(0, templ); | 16839 LocalContext context(0, templ); |
| 16840 | 16840 |
| 16841 v8::Handle<v8::String> scriptSource = v8::String::New( | 16841 v8::Handle<v8::String> scriptSource = v8::String::New( |
| 16842 "function foo() {\n" | 16842 "function foo() {\n" |
| 16843 " AnalyzeScriptIdInStack();" | 16843 " AnalyzeScriptIdInStack();" |
| 16844 "}\n" | 16844 "}\n" |
| 16845 "foo();\n"); | 16845 "foo();\n"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 16863 for (int i = 0; i < 3; i++) { | 16863 for (int i = 0; i < 3; i++) { |
| 16864 v8::Handle<v8::String> name = | 16864 v8::Handle<v8::String> name = |
| 16865 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16865 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16866 CHECK(!name.IsEmpty()); | 16866 CHECK(!name.IsEmpty()); |
| 16867 CHECK_EQ(url, name); | 16867 CHECK_EQ(url, name); |
| 16868 } | 16868 } |
| 16869 } | 16869 } |
| 16870 | 16870 |
| 16871 | 16871 |
| 16872 TEST(InlineScriptWithSourceURLInStackTrace) { | 16872 TEST(InlineScriptWithSourceURLInStackTrace) { |
| 16873 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16873 v8::HandleScope scope(CcTest::isolate()); |
| 16874 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16874 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16875 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), | 16875 templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"), |
| 16876 v8::FunctionTemplate::New( | 16876 v8::FunctionTemplate::New( |
| 16877 AnalyzeStackOfInlineScriptWithSourceURL)); | 16877 AnalyzeStackOfInlineScriptWithSourceURL)); |
| 16878 LocalContext context(0, templ); | 16878 LocalContext context(0, templ); |
| 16879 | 16879 |
| 16880 const char *source = | 16880 const char *source = |
| 16881 "function outer() {\n" | 16881 "function outer() {\n" |
| 16882 "function bar() {\n" | 16882 "function bar() {\n" |
| 16883 " AnalyzeStackOfInlineScriptWithSourceURL();\n" | 16883 " AnalyzeStackOfInlineScriptWithSourceURL();\n" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 16908 for (int i = 0; i < 3; i++) { | 16908 for (int i = 0; i < 3; i++) { |
| 16909 v8::Handle<v8::String> name = | 16909 v8::Handle<v8::String> name = |
| 16910 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16910 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16911 CHECK(!name.IsEmpty()); | 16911 CHECK(!name.IsEmpty()); |
| 16912 CHECK_EQ(url, name); | 16912 CHECK_EQ(url, name); |
| 16913 } | 16913 } |
| 16914 } | 16914 } |
| 16915 | 16915 |
| 16916 | 16916 |
| 16917 TEST(DynamicWithSourceURLInStackTrace) { | 16917 TEST(DynamicWithSourceURLInStackTrace) { |
| 16918 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16918 v8::HandleScope scope(CcTest::isolate()); |
| 16919 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16919 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 16920 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), | 16920 templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"), |
| 16921 v8::FunctionTemplate::New( | 16921 v8::FunctionTemplate::New( |
| 16922 AnalyzeStackOfDynamicScriptWithSourceURL)); | 16922 AnalyzeStackOfDynamicScriptWithSourceURL)); |
| 16923 LocalContext context(0, templ); | 16923 LocalContext context(0, templ); |
| 16924 | 16924 |
| 16925 const char *source = | 16925 const char *source = |
| 16926 "function outer() {\n" | 16926 "function outer() {\n" |
| 16927 "function bar() {\n" | 16927 "function bar() {\n" |
| 16928 " AnalyzeStackOfDynamicScriptWithSourceURL();\n" | 16928 " AnalyzeStackOfDynamicScriptWithSourceURL();\n" |
| 16929 "}\n" | 16929 "}\n" |
| 16930 "function foo() {\n" | 16930 "function foo() {\n" |
| 16931 "\n" | 16931 "\n" |
| 16932 " bar();\n" | 16932 " bar();\n" |
| 16933 "}\n" | 16933 "}\n" |
| 16934 "foo();\n" | 16934 "foo();\n" |
| 16935 "}\n" | 16935 "}\n" |
| 16936 "outer()\n%s"; | 16936 "outer()\n%s"; |
| 16937 | 16937 |
| 16938 i::ScopedVector<char> code(1024); | 16938 i::ScopedVector<char> code(1024); |
| 16939 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); | 16939 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); |
| 16940 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); | 16940 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); |
| 16941 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); | 16941 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); |
| 16942 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); | 16942 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); |
| 16943 } | 16943 } |
| 16944 | 16944 |
| 16945 | 16945 |
| 16946 static void CreateGarbageInOldSpace() { | 16946 static void CreateGarbageInOldSpace() { |
| 16947 i::Factory* factory = i::Isolate::Current()->factory(); | 16947 i::Factory* factory = i::Isolate::Current()->factory(); |
| 16948 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 16948 v8::HandleScope scope(CcTest::isolate()); |
| 16949 i::AlwaysAllocateScope always_allocate; | 16949 i::AlwaysAllocateScope always_allocate; |
| 16950 for (int i = 0; i < 1000; i++) { | 16950 for (int i = 0; i < 1000; i++) { |
| 16951 factory->NewFixedArray(1000, i::TENURED); | 16951 factory->NewFixedArray(1000, i::TENURED); |
| 16952 } | 16952 } |
| 16953 } | 16953 } |
| 16954 | 16954 |
| 16955 | 16955 |
| 16956 // Test that idle notification can be handled and eventually returns true. | 16956 // Test that idle notification can be handled and eventually returns true. |
| 16957 TEST(IdleNotification) { | 16957 TEST(IdleNotification) { |
| 16958 const intptr_t MB = 1024 * 1024; | 16958 const intptr_t MB = 1024 * 1024; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17329 v8::Handle<v8::String> str(args[0]->ToString()); | 17329 v8::Handle<v8::String> str(args[0]->ToString()); |
| 17330 USE(str); | 17330 USE(str); |
| 17331 if (tc.HasCaught()) | 17331 if (tc.HasCaught()) |
| 17332 tc.ReThrow(); | 17332 tc.ReThrow(); |
| 17333 } | 17333 } |
| 17334 | 17334 |
| 17335 | 17335 |
| 17336 // Test that an exception can be propagated down through a spaghetti | 17336 // Test that an exception can be propagated down through a spaghetti |
| 17337 // stack using ReThrow. | 17337 // stack using ReThrow. |
| 17338 THREADED_TEST(SpaghettiStackReThrow) { | 17338 THREADED_TEST(SpaghettiStackReThrow) { |
| 17339 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 17339 v8::HandleScope scope(CcTest::isolate()); |
| 17340 LocalContext context; | 17340 LocalContext context; |
| 17341 context->Global()->Set( | 17341 context->Global()->Set( |
| 17342 v8::String::New("s"), | 17342 v8::String::New("s"), |
| 17343 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); | 17343 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); |
| 17344 v8::TryCatch try_catch; | 17344 v8::TryCatch try_catch; |
| 17345 CompileRun( | 17345 CompileRun( |
| 17346 "var i = 0;" | 17346 "var i = 0;" |
| 17347 "var o = {" | 17347 "var o = {" |
| 17348 " toString: function () {" | 17348 " toString: function () {" |
| 17349 " if (i == 10) {" | 17349 " if (i == 10) {" |
| 17350 " throw 'Hey!';" | 17350 " throw 'Hey!';" |
| 17351 " } else {" | 17351 " } else {" |
| 17352 " i++;" | 17352 " i++;" |
| 17353 " return s(o);" | 17353 " return s(o);" |
| 17354 " }" | 17354 " }" |
| 17355 " }" | 17355 " }" |
| 17356 "};" | 17356 "};" |
| 17357 "s(o);"); | 17357 "s(o);"); |
| 17358 CHECK(try_catch.HasCaught()); | 17358 CHECK(try_catch.HasCaught()); |
| 17359 v8::String::Utf8Value value(try_catch.Exception()); | 17359 v8::String::Utf8Value value(try_catch.Exception()); |
| 17360 CHECK_EQ(0, strcmp(*value, "Hey!")); | 17360 CHECK_EQ(0, strcmp(*value, "Hey!")); |
| 17361 } | 17361 } |
| 17362 | 17362 |
| 17363 | 17363 |
| 17364 TEST(Regress528) { | 17364 TEST(Regress528) { |
| 17365 v8::V8::Initialize(); | 17365 v8::V8::Initialize(); |
| 17366 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 17366 v8::Isolate* isolate = CcTest::isolate(); |
| 17367 v8::HandleScope scope(isolate); | 17367 v8::HandleScope scope(isolate); |
| 17368 v8::Local<Context> other_context; | 17368 v8::Local<Context> other_context; |
| 17369 int gc_count; | 17369 int gc_count; |
| 17370 | 17370 |
| 17371 // Create a context used to keep the code from aging in the compilation | 17371 // Create a context used to keep the code from aging in the compilation |
| 17372 // cache. | 17372 // cache. |
| 17373 other_context = Context::New(isolate); | 17373 other_context = Context::New(isolate); |
| 17374 | 17374 |
| 17375 // Context-dependent context data creates reference from the compilation | 17375 // Context-dependent context data creates reference from the compilation |
| 17376 // cache to the global object. | 17376 // cache to the global object. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17568 const v8::PropertyCallbackInfo<v8::Value>& info) { | 17568 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 17569 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); | 17569 CHECK(v8::Utils::OpenHandle(*info.This())->IsJSObject()); |
| 17570 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); | 17570 CHECK(v8::Utils::OpenHandle(*info.Holder())->IsJSObject()); |
| 17571 if (!name->Equals(v8_str("foo"))) return; | 17571 if (!name->Equals(v8_str("foo"))) return; |
| 17572 info.This()->Set(v8_str("y"), v8_num(23)); | 17572 info.This()->Set(v8_str("y"), v8_num(23)); |
| 17573 info.GetReturnValue().Set(v8_num(23)); | 17573 info.GetReturnValue().Set(v8_num(23)); |
| 17574 } | 17574 } |
| 17575 | 17575 |
| 17576 | 17576 |
| 17577 TEST(SetterOnConstructorPrototype) { | 17577 TEST(SetterOnConstructorPrototype) { |
| 17578 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 17578 v8::HandleScope scope(CcTest::isolate()); |
| 17579 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 17579 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 17580 templ->SetAccessor(v8_str("x"), | 17580 templ->SetAccessor(v8_str("x"), |
| 17581 GetterWhichReturns42, | 17581 GetterWhichReturns42, |
| 17582 SetterWhichSetsYOnThisTo23); | 17582 SetterWhichSetsYOnThisTo23); |
| 17583 LocalContext context; | 17583 LocalContext context; |
| 17584 context->Global()->Set(v8_str("P"), templ->NewInstance()); | 17584 context->Global()->Set(v8_str("P"), templ->NewInstance()); |
| 17585 CompileRun("function C1() {" | 17585 CompileRun("function C1() {" |
| 17586 " this.x = 23;" | 17586 " this.x = 23;" |
| 17587 "};" | 17587 "};" |
| 17588 "C1.prototype = P;" | 17588 "C1.prototype = P;" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17620 Local<String> name, | 17620 Local<String> name, |
| 17621 Local<Value> value, | 17621 Local<Value> value, |
| 17622 const v8::PropertyCallbackInfo<v8::Value>& info) { | 17622 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 17623 if (name->Equals(v8_str("x"))) { | 17623 if (name->Equals(v8_str("x"))) { |
| 17624 info.This()->Set(v8_str("y"), v8_num(23)); | 17624 info.This()->Set(v8_str("y"), v8_num(23)); |
| 17625 } | 17625 } |
| 17626 } | 17626 } |
| 17627 | 17627 |
| 17628 | 17628 |
| 17629 THREADED_TEST(InterceptorOnConstructorPrototype) { | 17629 THREADED_TEST(InterceptorOnConstructorPrototype) { |
| 17630 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 17630 v8::HandleScope scope(CcTest::isolate()); |
| 17631 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 17631 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 17632 templ->SetNamedPropertyHandler(NamedPropertyGetterWhichReturns42, | 17632 templ->SetNamedPropertyHandler(NamedPropertyGetterWhichReturns42, |
| 17633 NamedPropertySetterWhichSetsYOnThisTo23); | 17633 NamedPropertySetterWhichSetsYOnThisTo23); |
| 17634 LocalContext context; | 17634 LocalContext context; |
| 17635 context->Global()->Set(v8_str("P"), templ->NewInstance()); | 17635 context->Global()->Set(v8_str("P"), templ->NewInstance()); |
| 17636 CompileRun("function C1() {" | 17636 CompileRun("function C1() {" |
| 17637 " this.x = 23;" | 17637 " this.x = 23;" |
| 17638 "};" | 17638 "};" |
| 17639 "C1.prototype = P;" | 17639 "C1.prototype = P;" |
| 17640 "function C2() {" | 17640 "function C2() {" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17836 CHECK_EQ(2, prologue_call_count); | 17836 CHECK_EQ(2, prologue_call_count); |
| 17837 CHECK_EQ(2, epilogue_call_count); | 17837 CHECK_EQ(2, epilogue_call_count); |
| 17838 CHECK_EQ(2, prologue_call_count_second); | 17838 CHECK_EQ(2, prologue_call_count_second); |
| 17839 CHECK_EQ(2, epilogue_call_count_second); | 17839 CHECK_EQ(2, epilogue_call_count_second); |
| 17840 } | 17840 } |
| 17841 | 17841 |
| 17842 | 17842 |
| 17843 THREADED_TEST(AddToJSFunctionResultCache) { | 17843 THREADED_TEST(AddToJSFunctionResultCache) { |
| 17844 i::FLAG_stress_compaction = false; | 17844 i::FLAG_stress_compaction = false; |
| 17845 i::FLAG_allow_natives_syntax = true; | 17845 i::FLAG_allow_natives_syntax = true; |
| 17846 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 17846 v8::HandleScope scope(CcTest::isolate()); |
| 17847 | 17847 |
| 17848 LocalContext context; | 17848 LocalContext context; |
| 17849 | 17849 |
| 17850 const char* code = | 17850 const char* code = |
| 17851 "(function() {" | 17851 "(function() {" |
| 17852 " var key0 = 'a';" | 17852 " var key0 = 'a';" |
| 17853 " var key1 = 'b';" | 17853 " var key1 = 'b';" |
| 17854 " var r0 = %_GetFromCache(0, key0);" | 17854 " var r0 = %_GetFromCache(0, key0);" |
| 17855 " var r1 = %_GetFromCache(0, key1);" | 17855 " var r1 = %_GetFromCache(0, key1);" |
| 17856 " var r0_ = %_GetFromCache(0, key0);" | 17856 " var r0_ = %_GetFromCache(0, key0);" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18039 | 18039 |
| 18040 ExpectObject("str2.lastIndexOf('dab');", lastindexof); | 18040 ExpectObject("str2.lastIndexOf('dab');", lastindexof); |
| 18041 | 18041 |
| 18042 reresult = CompileRun("str2.charCodeAt(2);"); | 18042 reresult = CompileRun("str2.charCodeAt(2);"); |
| 18043 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); | 18043 CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value()); |
| 18044 } | 18044 } |
| 18045 | 18045 |
| 18046 | 18046 |
| 18047 TEST(ContainsOnlyOneByte) { | 18047 TEST(ContainsOnlyOneByte) { |
| 18048 v8::V8::Initialize(); | 18048 v8::V8::Initialize(); |
| 18049 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 18049 v8::Isolate* isolate = CcTest::isolate(); |
| 18050 v8::HandleScope scope(isolate); | 18050 v8::HandleScope scope(isolate); |
| 18051 // Make a buffer long enough that it won't automatically be converted. | 18051 // Make a buffer long enough that it won't automatically be converted. |
| 18052 const int length = 512; | 18052 const int length = 512; |
| 18053 // Ensure word aligned assignment. | 18053 // Ensure word aligned assignment. |
| 18054 const int aligned_length = length*sizeof(uintptr_t)/sizeof(uint16_t); | 18054 const int aligned_length = length*sizeof(uintptr_t)/sizeof(uint16_t); |
| 18055 i::SmartArrayPointer<uintptr_t> | 18055 i::SmartArrayPointer<uintptr_t> |
| 18056 aligned_contents(new uintptr_t[aligned_length]); | 18056 aligned_contents(new uintptr_t[aligned_length]); |
| 18057 uint16_t* string_contents = reinterpret_cast<uint16_t*>(*aligned_contents); | 18057 uint16_t* string_contents = reinterpret_cast<uint16_t*>(*aligned_contents); |
| 18058 // Set to contain only one byte. | 18058 // Set to contain only one byte. |
| 18059 for (int i = 0; i < length-1; i++) { | 18059 for (int i = 0; i < length-1; i++) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18119 } | 18119 } |
| 18120 | 18120 |
| 18121 | 18121 |
| 18122 TEST(GCInFailedAccessCheckCallback) { | 18122 TEST(GCInFailedAccessCheckCallback) { |
| 18123 // Install a failed access check callback that performs a GC on each | 18123 // Install a failed access check callback that performs a GC on each |
| 18124 // invocation. Then force the callback to be called from va | 18124 // invocation. Then force the callback to be called from va |
| 18125 | 18125 |
| 18126 v8::V8::Initialize(); | 18126 v8::V8::Initialize(); |
| 18127 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); | 18127 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); |
| 18128 | 18128 |
| 18129 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 18129 v8::HandleScope scope(CcTest::isolate()); |
| 18130 | 18130 |
| 18131 // Create an ObjectTemplate for global objects and install access | 18131 // Create an ObjectTemplate for global objects and install access |
| 18132 // check callbacks that will block access. | 18132 // check callbacks that will block access. |
| 18133 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 18133 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 18134 global_template->SetAccessCheckCallbacks(NamedGetAccessBlocker, | 18134 global_template->SetAccessCheckCallbacks(NamedGetAccessBlocker, |
| 18135 IndexedGetAccessBlocker, | 18135 IndexedGetAccessBlocker, |
| 18136 v8::Handle<v8::Value>(), | 18136 v8::Handle<v8::Value>(), |
| 18137 false); | 18137 false); |
| 18138 | 18138 |
| 18139 // Create a context and set an x property on it's global object. | 18139 // Create a context and set an x property on it's global object. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18191 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); | 18191 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); |
| 18192 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); | 18192 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); |
| 18193 | 18193 |
| 18194 // Reset the failed access check callback so it does not influence | 18194 // Reset the failed access check callback so it does not influence |
| 18195 // the other tests. | 18195 // the other tests. |
| 18196 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); | 18196 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); |
| 18197 } | 18197 } |
| 18198 | 18198 |
| 18199 | 18199 |
| 18200 TEST(IsolateNewDispose) { | 18200 TEST(IsolateNewDispose) { |
| 18201 v8::Isolate* current_isolate = v8::Isolate::GetCurrent(); | 18201 v8::Isolate* current_isolate = CcTest::isolate(); |
| 18202 v8::Isolate* isolate = v8::Isolate::New(); | 18202 v8::Isolate* isolate = v8::Isolate::New(); |
| 18203 CHECK(isolate != NULL); | 18203 CHECK(isolate != NULL); |
| 18204 CHECK(!reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate()); | 18204 CHECK(!reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate()); |
| 18205 CHECK(current_isolate != isolate); | 18205 CHECK(current_isolate != isolate); |
| 18206 CHECK(current_isolate == v8::Isolate::GetCurrent()); | 18206 CHECK(current_isolate == CcTest::isolate()); |
| 18207 | 18207 |
| 18208 v8::V8::SetFatalErrorHandler(StoringErrorCallback); | 18208 v8::V8::SetFatalErrorHandler(StoringErrorCallback); |
| 18209 last_location = last_message = NULL; | 18209 last_location = last_message = NULL; |
| 18210 isolate->Dispose(); | 18210 isolate->Dispose(); |
| 18211 CHECK_EQ(last_location, NULL); | 18211 CHECK_EQ(last_location, NULL); |
| 18212 CHECK_EQ(last_message, NULL); | 18212 CHECK_EQ(last_message, NULL); |
| 18213 } | 18213 } |
| 18214 | 18214 |
| 18215 | 18215 |
| 18216 UNINITIALIZED_TEST(DisposeIsolateWhenInUse) { | 18216 UNINITIALIZED_TEST(DisposeIsolateWhenInUse) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18274 v8::Context::Scope context_scope(context); | 18274 v8::Context::Scope context_scope(context); |
| 18275 // Now again in isolate 1 | 18275 // Now again in isolate 1 |
| 18276 ExpectString("function f() { return foo; }; f()", "isolate 1"); | 18276 ExpectString("function f() { return foo; }; f()", "isolate 1"); |
| 18277 } | 18277 } |
| 18278 | 18278 |
| 18279 isolate1->Exit(); | 18279 isolate1->Exit(); |
| 18280 | 18280 |
| 18281 // Run some stuff in default isolate. | 18281 // Run some stuff in default isolate. |
| 18282 v8::Persistent<v8::Context> context_default; | 18282 v8::Persistent<v8::Context> context_default; |
| 18283 { | 18283 { |
| 18284 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 18284 v8::Isolate* isolate = CcTest::isolate(); |
| 18285 v8::Isolate::Scope iscope(isolate); | 18285 v8::Isolate::Scope iscope(isolate); |
| 18286 v8::HandleScope scope(isolate); | 18286 v8::HandleScope scope(isolate); |
| 18287 context_default.Reset(isolate, Context::New(isolate)); | 18287 context_default.Reset(isolate, Context::New(isolate)); |
| 18288 } | 18288 } |
| 18289 | 18289 |
| 18290 { | 18290 { |
| 18291 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 18291 v8::HandleScope scope(CcTest::isolate()); |
| 18292 v8::Local<v8::Context> context = | 18292 v8::Local<v8::Context> context = |
| 18293 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context_default); | 18293 v8::Local<v8::Context>::New(CcTest::isolate(), context_default); |
| 18294 v8::Context::Scope context_scope(context); | 18294 v8::Context::Scope context_scope(context); |
| 18295 // Variables in other isolates should be not available, verify there | 18295 // Variables in other isolates should be not available, verify there |
| 18296 // is an exception. | 18296 // is an exception. |
| 18297 ExpectTrue("function f() {" | 18297 ExpectTrue("function f() {" |
| 18298 " try {" | 18298 " try {" |
| 18299 " foo;" | 18299 " foo;" |
| 18300 " return false;" | 18300 " return false;" |
| 18301 " } catch(e) {" | 18301 " } catch(e) {" |
| 18302 " return true;" | 18302 " return true;" |
| 18303 " }" | 18303 " }" |
| 18304 "};" | 18304 "};" |
| 18305 "var isDefaultIsolate = true;" | 18305 "var isDefaultIsolate = true;" |
| 18306 "f()"); | 18306 "f()"); |
| 18307 } | 18307 } |
| 18308 | 18308 |
| 18309 isolate1->Enter(); | 18309 isolate1->Enter(); |
| 18310 | 18310 |
| 18311 { | 18311 { |
| 18312 v8::Isolate::Scope iscope(isolate2); | 18312 v8::Isolate::Scope iscope(isolate2); |
| 18313 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 18313 v8::HandleScope scope(isolate2); |
| 18314 v8::Local<v8::Context> context = | 18314 v8::Local<v8::Context> context = |
| 18315 v8::Local<v8::Context>::New(isolate2, context2); | 18315 v8::Local<v8::Context>::New(isolate2, context2); |
| 18316 v8::Context::Scope context_scope(context); | 18316 v8::Context::Scope context_scope(context); |
| 18317 ExpectString("function f() { return foo; }; f()", "isolate 2"); | 18317 ExpectString("function f() { return foo; }; f()", "isolate 2"); |
| 18318 } | 18318 } |
| 18319 | 18319 |
| 18320 { | 18320 { |
| 18321 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 18321 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 18322 v8::Local<v8::Context> context = | 18322 v8::Local<v8::Context> context = |
| 18323 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1); | 18323 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 18339 isolate1->Dispose(); | 18339 isolate1->Dispose(); |
| 18340 CHECK_EQ(last_location, NULL); | 18340 CHECK_EQ(last_location, NULL); |
| 18341 CHECK_EQ(last_message, NULL); | 18341 CHECK_EQ(last_message, NULL); |
| 18342 | 18342 |
| 18343 isolate2->Dispose(); | 18343 isolate2->Dispose(); |
| 18344 CHECK_EQ(last_location, NULL); | 18344 CHECK_EQ(last_location, NULL); |
| 18345 CHECK_EQ(last_message, NULL); | 18345 CHECK_EQ(last_message, NULL); |
| 18346 | 18346 |
| 18347 // Check that default isolate still runs. | 18347 // Check that default isolate still runs. |
| 18348 { | 18348 { |
| 18349 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 18349 v8::HandleScope scope(CcTest::isolate()); |
| 18350 v8::Local<v8::Context> context = | 18350 v8::Local<v8::Context> context = |
| 18351 v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context_default); | 18351 v8::Local<v8::Context>::New(CcTest::isolate(), context_default); |
| 18352 v8::Context::Scope context_scope(context); | 18352 v8::Context::Scope context_scope(context); |
| 18353 ExpectTrue("function f() { return isDefaultIsolate; }; f()"); | 18353 ExpectTrue("function f() { return isDefaultIsolate; }; f()"); |
| 18354 } | 18354 } |
| 18355 } | 18355 } |
| 18356 | 18356 |
| 18357 | 18357 |
| 18358 static int CalcFibonacci(v8::Isolate* isolate, int limit) { | 18358 static int CalcFibonacci(v8::Isolate* isolate, int limit) { |
| 18359 v8::Isolate::Scope isolate_scope(isolate); | 18359 v8::Isolate::Scope isolate_scope(isolate); |
| 18360 v8::HandleScope scope(isolate); | 18360 v8::HandleScope scope(isolate); |
| 18361 LocalContext context; | 18361 LocalContext context; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18395 v8::Isolate* isolate1 = v8::Isolate::New(); | 18395 v8::Isolate* isolate1 = v8::Isolate::New(); |
| 18396 v8::Isolate* isolate2 = v8::Isolate::New(); | 18396 v8::Isolate* isolate2 = v8::Isolate::New(); |
| 18397 | 18397 |
| 18398 IsolateThread thread1(isolate1, 21); | 18398 IsolateThread thread1(isolate1, 21); |
| 18399 IsolateThread thread2(isolate2, 12); | 18399 IsolateThread thread2(isolate2, 12); |
| 18400 | 18400 |
| 18401 // Compute some fibonacci numbers on 3 threads in 3 isolates. | 18401 // Compute some fibonacci numbers on 3 threads in 3 isolates. |
| 18402 thread1.Start(); | 18402 thread1.Start(); |
| 18403 thread2.Start(); | 18403 thread2.Start(); |
| 18404 | 18404 |
| 18405 int result1 = CalcFibonacci(v8::Isolate::GetCurrent(), 21); | 18405 int result1 = CalcFibonacci(CcTest::isolate(), 21); |
| 18406 int result2 = CalcFibonacci(v8::Isolate::GetCurrent(), 12); | 18406 int result2 = CalcFibonacci(CcTest::isolate(), 12); |
| 18407 | 18407 |
| 18408 thread1.Join(); | 18408 thread1.Join(); |
| 18409 thread2.Join(); | 18409 thread2.Join(); |
| 18410 | 18410 |
| 18411 // Compare results. The actual fibonacci numbers for 12 and 21 are taken | 18411 // Compare results. The actual fibonacci numbers for 12 and 21 are taken |
| 18412 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number | 18412 // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number |
| 18413 CHECK_EQ(result1, 10946); | 18413 CHECK_EQ(result1, 10946); |
| 18414 CHECK_EQ(result2, 144); | 18414 CHECK_EQ(result2, 144); |
| 18415 CHECK_EQ(result1, thread1.result()); | 18415 CHECK_EQ(result1, thread1.result()); |
| 18416 CHECK_EQ(result2, thread2.result()); | 18416 CHECK_EQ(result2, thread2.result()); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18710 | 18710 |
| 18711 class Visitor42 : public v8::PersistentHandleVisitor { | 18711 class Visitor42 : public v8::PersistentHandleVisitor { |
| 18712 public: | 18712 public: |
| 18713 explicit Visitor42(v8::Persistent<v8::Object>* object) | 18713 explicit Visitor42(v8::Persistent<v8::Object>* object) |
| 18714 : counter_(0), object_(object) { } | 18714 : counter_(0), object_(object) { } |
| 18715 | 18715 |
| 18716 virtual void VisitPersistentHandle(Persistent<Value>* value, | 18716 virtual void VisitPersistentHandle(Persistent<Value>* value, |
| 18717 uint16_t class_id) { | 18717 uint16_t class_id) { |
| 18718 if (class_id != 42) return; | 18718 if (class_id != 42) return; |
| 18719 CHECK_EQ(42, value->WrapperClassId()); | 18719 CHECK_EQ(42, value->WrapperClassId()); |
| 18720 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 18720 v8::Isolate* isolate = CcTest::isolate(); |
| 18721 v8::HandleScope handle_scope(isolate); | 18721 v8::HandleScope handle_scope(isolate); |
| 18722 v8::Handle<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value); | 18722 v8::Handle<v8::Value> handle = v8::Local<v8::Value>::New(isolate, *value); |
| 18723 v8::Handle<v8::Value> object = | 18723 v8::Handle<v8::Value> object = |
| 18724 v8::Local<v8::Object>::New(isolate, *object_); | 18724 v8::Local<v8::Object>::New(isolate, *object_); |
| 18725 CHECK(handle->IsObject()); | 18725 CHECK(handle->IsObject()); |
| 18726 CHECK_EQ(Handle<Object>::Cast(handle), object); | 18726 CHECK_EQ(Handle<Object>::Cast(handle), object); |
| 18727 ++counter_; | 18727 ++counter_; |
| 18728 } | 18728 } |
| 18729 | 18729 |
| 18730 int counter_; | 18730 int counter_; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18925 Set(v8_str("context_id"), v8::Integer::New(id)); | 18925 Set(v8_str("context_id"), v8::Integer::New(id)); |
| 18926 } | 18926 } |
| 18927 | 18927 |
| 18928 | 18928 |
| 18929 static void CheckContextId(v8::Handle<Object> object, int expected) { | 18929 static void CheckContextId(v8::Handle<Object> object, int expected) { |
| 18930 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); | 18930 CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value()); |
| 18931 } | 18931 } |
| 18932 | 18932 |
| 18933 | 18933 |
| 18934 THREADED_TEST(CreationContext) { | 18934 THREADED_TEST(CreationContext) { |
| 18935 HandleScope handle_scope(v8::Isolate::GetCurrent()); | 18935 HandleScope handle_scope(CcTest::isolate()); |
| 18936 Handle<Context> context1 = Context::New(v8::Isolate::GetCurrent()); | 18936 Handle<Context> context1 = Context::New(CcTest::isolate()); |
| 18937 InstallContextId(context1, 1); | 18937 InstallContextId(context1, 1); |
| 18938 Handle<Context> context2 = Context::New(v8::Isolate::GetCurrent()); | 18938 Handle<Context> context2 = Context::New(CcTest::isolate()); |
| 18939 InstallContextId(context2, 2); | 18939 InstallContextId(context2, 2); |
| 18940 Handle<Context> context3 = Context::New(v8::Isolate::GetCurrent()); | 18940 Handle<Context> context3 = Context::New(CcTest::isolate()); |
| 18941 InstallContextId(context3, 3); | 18941 InstallContextId(context3, 3); |
| 18942 | 18942 |
| 18943 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); | 18943 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(); |
| 18944 | 18944 |
| 18945 Local<Object> object1; | 18945 Local<Object> object1; |
| 18946 Local<Function> func1; | 18946 Local<Function> func1; |
| 18947 { | 18947 { |
| 18948 Context::Scope scope(context1); | 18948 Context::Scope scope(context1); |
| 18949 object1 = Object::New(); | 18949 object1 = Object::New(); |
| 18950 func1 = tmpl->GetFunction(); | 18950 func1 = tmpl->GetFunction(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19008 CheckContextId(object2, 2); | 19008 CheckContextId(object2, 2); |
| 19009 CHECK(func2->CreationContext() == context2); | 19009 CHECK(func2->CreationContext() == context2); |
| 19010 CheckContextId(func2, 2); | 19010 CheckContextId(func2, 2); |
| 19011 CHECK(instance2->CreationContext() == context2); | 19011 CHECK(instance2->CreationContext() == context2); |
| 19012 CheckContextId(instance2, 2); | 19012 CheckContextId(instance2, 2); |
| 19013 } | 19013 } |
| 19014 } | 19014 } |
| 19015 | 19015 |
| 19016 | 19016 |
| 19017 THREADED_TEST(CreationContextOfJsFunction) { | 19017 THREADED_TEST(CreationContextOfJsFunction) { |
| 19018 HandleScope handle_scope(v8::Isolate::GetCurrent()); | 19018 HandleScope handle_scope(CcTest::isolate()); |
| 19019 Handle<Context> context = Context::New(v8::Isolate::GetCurrent()); | 19019 Handle<Context> context = Context::New(CcTest::isolate()); |
| 19020 InstallContextId(context, 1); | 19020 InstallContextId(context, 1); |
| 19021 | 19021 |
| 19022 Local<Object> function; | 19022 Local<Object> function; |
| 19023 { | 19023 { |
| 19024 Context::Scope scope(context); | 19024 Context::Scope scope(context); |
| 19025 function = CompileRun("function foo() {}; foo").As<Object>(); | 19025 function = CompileRun("function foo() {}; foo").As<Object>(); |
| 19026 } | 19026 } |
| 19027 | 19027 |
| 19028 CHECK(function->CreationContext() == context); | 19028 CHECK(function->CreationContext() == context); |
| 19029 CheckContextId(function, 1); | 19029 CheckContextId(function, 1); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19138 0, | 19138 0, |
| 19139 HasOwnPropertyNamedPropertyQuery2); | 19139 HasOwnPropertyNamedPropertyQuery2); |
| 19140 Handle<Object> instance = templ->NewInstance(); | 19140 Handle<Object> instance = templ->NewInstance(); |
| 19141 CHECK(!instance->HasOwnProperty(v8_str("foo"))); | 19141 CHECK(!instance->HasOwnProperty(v8_str("foo"))); |
| 19142 CHECK(instance->HasOwnProperty(v8_str("bar"))); | 19142 CHECK(instance->HasOwnProperty(v8_str("bar"))); |
| 19143 } | 19143 } |
| 19144 } | 19144 } |
| 19145 | 19145 |
| 19146 | 19146 |
| 19147 TEST(IndexedInterceptorWithStringProto) { | 19147 TEST(IndexedInterceptorWithStringProto) { |
| 19148 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 19148 v8::HandleScope scope(CcTest::isolate()); |
| 19149 Handle<ObjectTemplate> templ = ObjectTemplate::New(); | 19149 Handle<ObjectTemplate> templ = ObjectTemplate::New(); |
| 19150 templ->SetIndexedPropertyHandler(NULL, | 19150 templ->SetIndexedPropertyHandler(NULL, |
| 19151 NULL, | 19151 NULL, |
| 19152 HasOwnPropertyIndexedPropertyQuery); | 19152 HasOwnPropertyIndexedPropertyQuery); |
| 19153 LocalContext context; | 19153 LocalContext context; |
| 19154 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 19154 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 19155 CompileRun("var s = new String('foobar'); obj.__proto__ = s;"); | 19155 CompileRun("var s = new String('foobar'); obj.__proto__ = s;"); |
| 19156 // These should be intercepted. | 19156 // These should be intercepted. |
| 19157 CHECK(CompileRun("42 in obj")->BooleanValue()); | 19157 CHECK(CompileRun("42 in obj")->BooleanValue()); |
| 19158 CHECK(CompileRun("'42' in obj")->BooleanValue()); | 19158 CHECK(CompileRun("'42' in obj")->BooleanValue()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19264 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); | 19264 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis); |
| 19265 Handle<Function> function = templ->GetFunction(); | 19265 Handle<Function> function = templ->GetFunction(); |
| 19266 context->Global()->Set(v8_str("f"), function); | 19266 context->Global()->Set(v8_str("f"), function); |
| 19267 TryCatch try_catch; | 19267 TryCatch try_catch; |
| 19268 CompileRun("f.call(2)"); | 19268 CompileRun("f.call(2)"); |
| 19269 } | 19269 } |
| 19270 | 19270 |
| 19271 | 19271 |
| 19272 // Regression test for issue 1470. | 19272 // Regression test for issue 1470. |
| 19273 THREADED_TEST(ReadOnlyIndexedProperties) { | 19273 THREADED_TEST(ReadOnlyIndexedProperties) { |
| 19274 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 19274 v8::HandleScope scope(CcTest::isolate()); |
| 19275 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 19275 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 19276 | 19276 |
| 19277 LocalContext context; | 19277 LocalContext context; |
| 19278 Local<v8::Object> obj = templ->NewInstance(); | 19278 Local<v8::Object> obj = templ->NewInstance(); |
| 19279 context->Global()->Set(v8_str("obj"), obj); | 19279 context->Global()->Set(v8_str("obj"), obj); |
| 19280 obj->Set(v8_str("1"), v8_str("DONT_CHANGE"), v8::ReadOnly); | 19280 obj->Set(v8_str("1"), v8_str("DONT_CHANGE"), v8::ReadOnly); |
| 19281 obj->Set(v8_str("1"), v8_str("foobar")); | 19281 obj->Set(v8_str("1"), v8_str("foobar")); |
| 19282 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); | 19282 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); |
| 19283 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); | 19283 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); |
| 19284 obj->Set(v8_num(2), v8_str("foobar")); | 19284 obj->Set(v8_num(2), v8_str("foobar")); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19329 char buffer[10]; | 19329 char buffer[10]; |
| 19330 CHECK_EQ(10, name->ToString()->WriteUtf8(buffer)); | 19330 CHECK_EQ(10, name->ToString()->WriteUtf8(buffer)); |
| 19331 return strncmp(buffer, "__proto__", 9) != 0; | 19331 return strncmp(buffer, "__proto__", 9) != 0; |
| 19332 } | 19332 } |
| 19333 | 19333 |
| 19334 return true; | 19334 return true; |
| 19335 } | 19335 } |
| 19336 | 19336 |
| 19337 | 19337 |
| 19338 THREADED_TEST(Regress93759) { | 19338 THREADED_TEST(Regress93759) { |
| 19339 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 19339 v8::Isolate* isolate = CcTest::isolate(); |
| 19340 HandleScope scope(isolate); | 19340 HandleScope scope(isolate); |
| 19341 | 19341 |
| 19342 // Template for object with security check. | 19342 // Template for object with security check. |
| 19343 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New(); | 19343 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New(); |
| 19344 // We don't do indexing, so any callback can be used for that. | 19344 // We don't do indexing, so any callback can be used for that. |
| 19345 no_proto_template->SetAccessCheckCallbacks( | 19345 no_proto_template->SetAccessCheckCallbacks( |
| 19346 BlockProtoNamedSecurityTestCallback, | 19346 BlockProtoNamedSecurityTestCallback, |
| 19347 IndexedSecurityTestCallback); | 19347 IndexedSecurityTestCallback); |
| 19348 | 19348 |
| 19349 // Templates for objects with hidden prototypes and possibly security check. | 19349 // Templates for objects with hidden prototypes and possibly security check. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19419 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); | 19419 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); |
| 19420 CHECK(result5->Equals( | 19420 CHECK(result5->Equals( |
| 19421 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); | 19421 object_with_hidden->GetPrototype()->ToObject()->GetPrototype())); |
| 19422 | 19422 |
| 19423 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); | 19423 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); |
| 19424 CHECK(result6->Equals(Undefined())); | 19424 CHECK(result6->Equals(Undefined())); |
| 19425 } | 19425 } |
| 19426 | 19426 |
| 19427 | 19427 |
| 19428 THREADED_TEST(Regress125988) { | 19428 THREADED_TEST(Regress125988) { |
| 19429 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 19429 v8::HandleScope scope(CcTest::isolate()); |
| 19430 Handle<FunctionTemplate> intercept = FunctionTemplate::New(); | 19430 Handle<FunctionTemplate> intercept = FunctionTemplate::New(); |
| 19431 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); | 19431 AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 19432 LocalContext env; | 19432 LocalContext env; |
| 19433 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); | 19433 env->Global()->Set(v8_str("Intercept"), intercept->GetFunction()); |
| 19434 CompileRun("var a = new Object();" | 19434 CompileRun("var a = new Object();" |
| 19435 "var b = new Intercept();" | 19435 "var b = new Intercept();" |
| 19436 "var c = new Object();" | 19436 "var c = new Object();" |
| 19437 "c.__proto__ = b;" | 19437 "c.__proto__ = b;" |
| 19438 "b.__proto__ = a;" | 19438 "b.__proto__ = a;" |
| 19439 "a.x = 23;" | 19439 "a.x = 23;" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 19453 Local<Value> expected_receiver, | 19453 Local<Value> expected_receiver, |
| 19454 const char* code) { | 19454 const char* code) { |
| 19455 Local<Value> result = CompileRun(code); | 19455 Local<Value> result = CompileRun(code); |
| 19456 CHECK(result->IsObject()); | 19456 CHECK(result->IsObject()); |
| 19457 CHECK(expected_receiver->Equals(result->ToObject()->Get(1))); | 19457 CHECK(expected_receiver->Equals(result->ToObject()->Get(1))); |
| 19458 CHECK(expected_result->Equals(result->ToObject()->Get(0))); | 19458 CHECK(expected_result->Equals(result->ToObject()->Get(0))); |
| 19459 } | 19459 } |
| 19460 | 19460 |
| 19461 | 19461 |
| 19462 THREADED_TEST(ForeignFunctionReceiver) { | 19462 THREADED_TEST(ForeignFunctionReceiver) { |
| 19463 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 19463 v8::Isolate* isolate = CcTest::isolate(); |
| 19464 HandleScope scope(isolate); | 19464 HandleScope scope(isolate); |
| 19465 | 19465 |
| 19466 // Create two contexts with different "id" properties ('i' and 'o'). | 19466 // Create two contexts with different "id" properties ('i' and 'o'). |
| 19467 // Call a function both from its own context and from a the foreign | 19467 // Call a function both from its own context and from a the foreign |
| 19468 // context, and see what "this" is bound to (returning both "this" | 19468 // context, and see what "this" is bound to (returning both "this" |
| 19469 // and "this.id" for comparison). | 19469 // and "this.id" for comparison). |
| 19470 | 19470 |
| 19471 Local<Context> foreign_context = v8::Context::New(isolate); | 19471 Local<Context> foreign_context = v8::Context::New(isolate); |
| 19472 foreign_context->Enter(); | 19472 foreign_context->Enter(); |
| 19473 Local<Value> foreign_function = | 19473 Local<Value> foreign_function = |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19612 callback_fired = 0; | 19612 callback_fired = 0; |
| 19613 Local<Function> recursive_function = | 19613 Local<Function> recursive_function = |
| 19614 Local<Function>::Cast(env->Global()->Get(v8_str("recursion"))); | 19614 Local<Function>::Cast(env->Global()->Get(v8_str("recursion"))); |
| 19615 v8::Handle<Value> args[] = { v8_num(0) }; | 19615 v8::Handle<Value> args[] = { v8_num(0) }; |
| 19616 recursive_function->Call(env->Global(), 1, args); | 19616 recursive_function->Call(env->Global(), 1, args); |
| 19617 CHECK_EQ(2, callback_fired); | 19617 CHECK_EQ(2, callback_fired); |
| 19618 } | 19618 } |
| 19619 | 19619 |
| 19620 | 19620 |
| 19621 void CallCompletedCallbackNoException() { | 19621 void CallCompletedCallbackNoException() { |
| 19622 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 19622 v8::HandleScope scope(CcTest::isolate()); |
| 19623 CompileRun("1+1;"); | 19623 CompileRun("1+1;"); |
| 19624 } | 19624 } |
| 19625 | 19625 |
| 19626 | 19626 |
| 19627 void CallCompletedCallbackException() { | 19627 void CallCompletedCallbackException() { |
| 19628 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 19628 v8::HandleScope scope(CcTest::isolate()); |
| 19629 CompileRun("throw 'second exception';"); | 19629 CompileRun("throw 'second exception';"); |
| 19630 } | 19630 } |
| 19631 | 19631 |
| 19632 | 19632 |
| 19633 TEST(CallCompletedCallbackOneException) { | 19633 TEST(CallCompletedCallbackOneException) { |
| 19634 LocalContext env; | 19634 LocalContext env; |
| 19635 v8::HandleScope scope(env->GetIsolate()); | 19635 v8::HandleScope scope(env->GetIsolate()); |
| 19636 v8::V8::AddCallCompletedCallback(CallCompletedCallbackNoException); | 19636 v8::V8::AddCallCompletedCallback(CallCompletedCallbackNoException); |
| 19637 CompileRun("throw 'exception';"); | 19637 CompileRun("throw 'exception';"); |
| 19638 } | 19638 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19710 | 19710 |
| 19711 | 19711 |
| 19712 TEST(PrimaryStubCache) { | 19712 TEST(PrimaryStubCache) { |
| 19713 StubCacheHelper(false); | 19713 StubCacheHelper(false); |
| 19714 } | 19714 } |
| 19715 | 19715 |
| 19716 | 19716 |
| 19717 TEST(StaticGetters) { | 19717 TEST(StaticGetters) { |
| 19718 LocalContext context; | 19718 LocalContext context; |
| 19719 i::Factory* factory = i::Isolate::Current()->factory(); | 19719 i::Factory* factory = i::Isolate::Current()->factory(); |
| 19720 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 19720 v8::Isolate* isolate = CcTest::isolate(); |
| 19721 v8::HandleScope scope(isolate); | 19721 v8::HandleScope scope(isolate); |
| 19722 i::Handle<i::Object> undefined_value = factory->undefined_value(); | 19722 i::Handle<i::Object> undefined_value = factory->undefined_value(); |
| 19723 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value); | 19723 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value); |
| 19724 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); | 19724 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); |
| 19725 i::Handle<i::Object> null_value = factory->null_value(); | 19725 i::Handle<i::Object> null_value = factory->null_value(); |
| 19726 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value); | 19726 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value); |
| 19727 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); | 19727 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); |
| 19728 i::Handle<i::Object> true_value = factory->true_value(); | 19728 i::Handle<i::Object> true_value = factory->true_value(); |
| 19729 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); | 19729 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); |
| 19730 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); | 19730 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); |
| 19731 i::Handle<i::Object> false_value = factory->false_value(); | 19731 i::Handle<i::Object> false_value = factory->false_value(); |
| 19732 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); | 19732 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); |
| 19733 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); | 19733 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); |
| 19734 } | 19734 } |
| 19735 | 19735 |
| 19736 | 19736 |
| 19737 UNINITIALIZED_TEST(IsolateEmbedderData) { | 19737 UNINITIALIZED_TEST(IsolateEmbedderData) { |
| 19738 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 19738 v8::Isolate* isolate = CcTest::isolate(); |
| 19739 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 19739 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 19740 CHECK_EQ(NULL, isolate->GetData()); | 19740 CHECK_EQ(NULL, isolate->GetData()); |
| 19741 CHECK_EQ(NULL, i_isolate->GetData()); | 19741 CHECK_EQ(NULL, i_isolate->GetData()); |
| 19742 static void* data1 = reinterpret_cast<void*>(0xacce55ed); | 19742 static void* data1 = reinterpret_cast<void*>(0xacce55ed); |
| 19743 isolate->SetData(data1); | 19743 isolate->SetData(data1); |
| 19744 CHECK_EQ(data1, isolate->GetData()); | 19744 CHECK_EQ(data1, isolate->GetData()); |
| 19745 CHECK_EQ(data1, i_isolate->GetData()); | 19745 CHECK_EQ(data1, i_isolate->GetData()); |
| 19746 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); | 19746 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); |
| 19747 i_isolate->SetData(data2); | 19747 i_isolate->SetData(data2); |
| 19748 CHECK_EQ(data2, isolate->GetData()); | 19748 CHECK_EQ(data2, isolate->GetData()); |
| 19749 CHECK_EQ(data2, i_isolate->GetData()); | 19749 CHECK_EQ(data2, i_isolate->GetData()); |
| 19750 i_isolate->TearDown(); | 19750 i_isolate->TearDown(); |
| 19751 CHECK_EQ(data2, isolate->GetData()); | 19751 CHECK_EQ(data2, isolate->GetData()); |
| 19752 CHECK_EQ(data2, i_isolate->GetData()); | 19752 CHECK_EQ(data2, i_isolate->GetData()); |
| 19753 } | 19753 } |
| 19754 | 19754 |
| 19755 | 19755 |
| 19756 TEST(StringEmpty) { | 19756 TEST(StringEmpty) { |
| 19757 LocalContext context; | 19757 LocalContext context; |
| 19758 i::Factory* factory = i::Isolate::Current()->factory(); | 19758 i::Factory* factory = i::Isolate::Current()->factory(); |
| 19759 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 19759 v8::Isolate* isolate = CcTest::isolate(); |
| 19760 v8::HandleScope scope(isolate); | 19760 v8::HandleScope scope(isolate); |
| 19761 i::Handle<i::Object> empty_string = factory->empty_string(); | 19761 i::Handle<i::Object> empty_string = factory->empty_string(); |
| 19762 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); | 19762 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); |
| 19763 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); | 19763 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); |
| 19764 } | 19764 } |
| 19765 | 19765 |
| 19766 | 19766 |
| 19767 static int instance_checked_getter_count = 0; | 19767 static int instance_checked_getter_count = 0; |
| 19768 static void InstanceCheckedGetter( | 19768 static void InstanceCheckedGetter( |
| 19769 Local<String> name, | 19769 Local<String> name, |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20023 } else { | 20023 } else { |
| 20024 CHECK_EQ(do_store ? 23 : 42, | 20024 CHECK_EQ(do_store ? 23 : 42, |
| 20025 context->Global()->Get(v8_str("result"))->Int32Value()); | 20025 context->Global()->Get(v8_str("result"))->Int32Value()); |
| 20026 } | 20026 } |
| 20027 } | 20027 } |
| 20028 | 20028 |
| 20029 | 20029 |
| 20030 THREADED_TEST(Regress137002a) { | 20030 THREADED_TEST(Regress137002a) { |
| 20031 i::FLAG_allow_natives_syntax = true; | 20031 i::FLAG_allow_natives_syntax = true; |
| 20032 i::FLAG_compilation_cache = false; | 20032 i::FLAG_compilation_cache = false; |
| 20033 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 20033 v8::HandleScope scope(CcTest::isolate()); |
| 20034 for (int i = 0; i < 16; i++) { | 20034 for (int i = 0; i < 16; i++) { |
| 20035 Helper137002(i & 8, i & 4, i & 2, i & 1); | 20035 Helper137002(i & 8, i & 4, i & 2, i & 1); |
| 20036 } | 20036 } |
| 20037 } | 20037 } |
| 20038 | 20038 |
| 20039 | 20039 |
| 20040 THREADED_TEST(Regress137002b) { | 20040 THREADED_TEST(Regress137002b) { |
| 20041 i::FLAG_allow_natives_syntax = true; | 20041 i::FLAG_allow_natives_syntax = true; |
| 20042 LocalContext context; | 20042 LocalContext context; |
| 20043 v8::HandleScope scope(context->GetIsolate()); | 20043 v8::HandleScope scope(context->GetIsolate()); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20291 } | 20291 } |
| 20292 | 20292 |
| 20293 | 20293 |
| 20294 void UnreachableCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 20294 void UnreachableCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 20295 CHECK(false); | 20295 CHECK(false); |
| 20296 } | 20296 } |
| 20297 | 20297 |
| 20298 | 20298 |
| 20299 TEST(JSONStringifyAccessCheck) { | 20299 TEST(JSONStringifyAccessCheck) { |
| 20300 v8::V8::Initialize(); | 20300 v8::V8::Initialize(); |
| 20301 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 20301 v8::HandleScope scope(CcTest::isolate()); |
| 20302 | 20302 |
| 20303 // Create an ObjectTemplate for global objects and install access | 20303 // Create an ObjectTemplate for global objects and install access |
| 20304 // check callbacks that will block access. | 20304 // check callbacks that will block access. |
| 20305 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 20305 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 20306 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked, | 20306 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked, |
| 20307 IndexAccessAlwaysBlocked); | 20307 IndexAccessAlwaysBlocked); |
| 20308 | 20308 |
| 20309 // Create a context and set an x property on it's global object. | 20309 // Create a context and set an x property on it's global object. |
| 20310 LocalContext context0(NULL, global_template); | 20310 LocalContext context0(NULL, global_template); |
| 20311 v8::Handle<v8::Object> global0 = context0->Global(); | 20311 v8::Handle<v8::Object> global0 = context0->Global(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20388 CompileRun("try { [1, 2, 3].sort(); } catch (e) { catcher(e) };"); | 20388 CompileRun("try { [1, 2, 3].sort(); } catch (e) { catcher(e) };"); |
| 20389 CHECK(!access_check_fail_thrown); | 20389 CHECK(!access_check_fail_thrown); |
| 20390 CHECK(!catch_callback_called); | 20390 CHECK(!catch_callback_called); |
| 20391 } | 20391 } |
| 20392 | 20392 |
| 20393 | 20393 |
| 20394 TEST(AccessCheckThrows) { | 20394 TEST(AccessCheckThrows) { |
| 20395 i::FLAG_allow_natives_syntax = true; | 20395 i::FLAG_allow_natives_syntax = true; |
| 20396 v8::V8::Initialize(); | 20396 v8::V8::Initialize(); |
| 20397 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckThrows); | 20397 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckThrows); |
| 20398 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 20398 v8::HandleScope scope(CcTest::isolate()); |
| 20399 | 20399 |
| 20400 // Create an ObjectTemplate for global objects and install access | 20400 // Create an ObjectTemplate for global objects and install access |
| 20401 // check callbacks that will block access. | 20401 // check callbacks that will block access. |
| 20402 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 20402 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
| 20403 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked, | 20403 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked, |
| 20404 IndexAccessAlwaysBlocked); | 20404 IndexAccessAlwaysBlocked); |
| 20405 | 20405 |
| 20406 // Create a context and set an x property on it's global object. | 20406 // Create a context and set an x property on it's global object. |
| 20407 LocalContext context0(NULL, global_template); | 20407 LocalContext context0(NULL, global_template); |
| 20408 context0->Global()->Set(v8_str("x"), v8_num(42)); | 20408 context0->Global()->Set(v8_str("x"), v8_num(42)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20464 "function f(o) { o.x = 10; };" | 20464 "function f(o) { o.x = 10; };" |
| 20465 "f(o); f(o); f(o);" | 20465 "f(o); f(o); f(o);" |
| 20466 "%OptimizeFunctionOnNextCall(f);" | 20466 "%OptimizeFunctionOnNextCall(f);" |
| 20467 "f(o);"); | 20467 "f(o);"); |
| 20468 ExpectBoolean("%GetOptimizationStatus(f) != 2", true); | 20468 ExpectBoolean("%GetOptimizationStatus(f) != 2", true); |
| 20469 } | 20469 } |
| 20470 | 20470 |
| 20471 | 20471 |
| 20472 THREADED_TEST(CrankshaftInterceptorSetter) { | 20472 THREADED_TEST(CrankshaftInterceptorSetter) { |
| 20473 i::FLAG_allow_natives_syntax = true; | 20473 i::FLAG_allow_natives_syntax = true; |
| 20474 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 20474 v8::HandleScope scope(CcTest::isolate()); |
| 20475 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20475 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 20476 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20476 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20477 LocalContext env; | 20477 LocalContext env; |
| 20478 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20478 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20479 CompileRun("var obj = new Obj;" | 20479 CompileRun("var obj = new Obj;" |
| 20480 // Initialize fields to avoid transitions later. | 20480 // Initialize fields to avoid transitions later. |
| 20481 "obj.age = 0;" | 20481 "obj.age = 0;" |
| 20482 "obj.accessor_age = 42;" | 20482 "obj.accessor_age = 42;" |
| 20483 "function setter(i) { this.accessor_age = i; };" | 20483 "function setter(i) { this.accessor_age = i; };" |
| 20484 "function getter() { return this.accessor_age; };" | 20484 "function getter() { return this.accessor_age; };" |
| 20485 "function setAge(i) { obj.age = i; };" | 20485 "function setAge(i) { obj.age = i; };" |
| 20486 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" | 20486 "Object.defineProperty(obj, 'age', { get:getter, set:setter });" |
| 20487 "setAge(1);" | 20487 "setAge(1);" |
| 20488 "setAge(2);" | 20488 "setAge(2);" |
| 20489 "setAge(3);" | 20489 "setAge(3);" |
| 20490 "%OptimizeFunctionOnNextCall(setAge);" | 20490 "%OptimizeFunctionOnNextCall(setAge);" |
| 20491 "setAge(4);"); | 20491 "setAge(4);"); |
| 20492 // All stores went through the interceptor. | 20492 // All stores went through the interceptor. |
| 20493 ExpectInt32("obj.interceptor_age", 4); | 20493 ExpectInt32("obj.interceptor_age", 4); |
| 20494 ExpectInt32("obj.accessor_age", 42); | 20494 ExpectInt32("obj.accessor_age", 42); |
| 20495 } | 20495 } |
| 20496 | 20496 |
| 20497 | 20497 |
| 20498 THREADED_TEST(CrankshaftInterceptorGetter) { | 20498 THREADED_TEST(CrankshaftInterceptorGetter) { |
| 20499 i::FLAG_allow_natives_syntax = true; | 20499 i::FLAG_allow_natives_syntax = true; |
| 20500 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 20500 v8::HandleScope scope(CcTest::isolate()); |
| 20501 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20501 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 20502 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20502 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20503 LocalContext env; | 20503 LocalContext env; |
| 20504 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20504 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20505 CompileRun("var obj = new Obj;" | 20505 CompileRun("var obj = new Obj;" |
| 20506 // Initialize fields to avoid transitions later. | 20506 // Initialize fields to avoid transitions later. |
| 20507 "obj.age = 1;" | 20507 "obj.age = 1;" |
| 20508 "obj.accessor_age = 42;" | 20508 "obj.accessor_age = 42;" |
| 20509 "function getter() { return this.accessor_age; };" | 20509 "function getter() { return this.accessor_age; };" |
| 20510 "function getAge() { return obj.interceptor_age; };" | 20510 "function getAge() { return obj.interceptor_age; };" |
| 20511 "Object.defineProperty(obj, 'interceptor_age', { get:getter });" | 20511 "Object.defineProperty(obj, 'interceptor_age', { get:getter });" |
| 20512 "getAge();" | 20512 "getAge();" |
| 20513 "getAge();" | 20513 "getAge();" |
| 20514 "getAge();" | 20514 "getAge();" |
| 20515 "%OptimizeFunctionOnNextCall(getAge);"); | 20515 "%OptimizeFunctionOnNextCall(getAge);"); |
| 20516 // Access through interceptor. | 20516 // Access through interceptor. |
| 20517 ExpectInt32("getAge()", 1); | 20517 ExpectInt32("getAge()", 1); |
| 20518 } | 20518 } |
| 20519 | 20519 |
| 20520 | 20520 |
| 20521 THREADED_TEST(CrankshaftInterceptorFieldRead) { | 20521 THREADED_TEST(CrankshaftInterceptorFieldRead) { |
| 20522 i::FLAG_allow_natives_syntax = true; | 20522 i::FLAG_allow_natives_syntax = true; |
| 20523 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 20523 v8::HandleScope scope(CcTest::isolate()); |
| 20524 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20524 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 20525 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20525 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20526 LocalContext env; | 20526 LocalContext env; |
| 20527 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20527 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20528 CompileRun("var obj = new Obj;" | 20528 CompileRun("var obj = new Obj;" |
| 20529 "obj.__proto__.interceptor_age = 42;" | 20529 "obj.__proto__.interceptor_age = 42;" |
| 20530 "obj.age = 100;" | 20530 "obj.age = 100;" |
| 20531 "function getAge() { return obj.interceptor_age; };"); | 20531 "function getAge() { return obj.interceptor_age; };"); |
| 20532 ExpectInt32("getAge();", 100); | 20532 ExpectInt32("getAge();", 100); |
| 20533 ExpectInt32("getAge();", 100); | 20533 ExpectInt32("getAge();", 100); |
| 20534 ExpectInt32("getAge();", 100); | 20534 ExpectInt32("getAge();", 100); |
| 20535 CompileRun("%OptimizeFunctionOnNextCall(getAge);"); | 20535 CompileRun("%OptimizeFunctionOnNextCall(getAge);"); |
| 20536 // Access through interceptor. | 20536 // Access through interceptor. |
| 20537 ExpectInt32("getAge();", 100); | 20537 ExpectInt32("getAge();", 100); |
| 20538 } | 20538 } |
| 20539 | 20539 |
| 20540 | 20540 |
| 20541 THREADED_TEST(CrankshaftInterceptorFieldWrite) { | 20541 THREADED_TEST(CrankshaftInterceptorFieldWrite) { |
| 20542 i::FLAG_allow_natives_syntax = true; | 20542 i::FLAG_allow_natives_syntax = true; |
| 20543 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 20543 v8::HandleScope scope(CcTest::isolate()); |
| 20544 Handle<FunctionTemplate> templ = FunctionTemplate::New(); | 20544 Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
| 20545 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 20545 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
| 20546 LocalContext env; | 20546 LocalContext env; |
| 20547 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); | 20547 env->Global()->Set(v8_str("Obj"), templ->GetFunction()); |
| 20548 CompileRun("var obj = new Obj;" | 20548 CompileRun("var obj = new Obj;" |
| 20549 "obj.age = 100000;" | 20549 "obj.age = 100000;" |
| 20550 "function setAge(i) { obj.age = i };" | 20550 "function setAge(i) { obj.age = i };" |
| 20551 "setAge(100);" | 20551 "setAge(100);" |
| 20552 "setAge(101);" | 20552 "setAge(101);" |
| 20553 "setAge(102);" | 20553 "setAge(102);" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20590 Local<Object> data2 = v8::Object::New(); | 20590 Local<Object> data2 = v8::Object::New(); |
| 20591 function_new_expected_env = data2; | 20591 function_new_expected_env = data2; |
| 20592 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 20592 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
| 20593 CHECK(!func2->IsNull()); | 20593 CHECK(!func2->IsNull()); |
| 20594 CHECK_NE(func, func2); | 20594 CHECK_NE(func, func2); |
| 20595 env->Global()->Set(v8_str("func2"), func2); | 20595 env->Global()->Set(v8_str("func2"), func2); |
| 20596 Local<Value> result2 = CompileRun("func2();"); | 20596 Local<Value> result2 = CompileRun("func2();"); |
| 20597 CHECK_EQ(v8::Integer::New(17, isolate), result2); | 20597 CHECK_EQ(v8::Integer::New(17, isolate), result2); |
| 20598 } | 20598 } |
| 20599 | 20599 |
| OLD | NEW |