| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 | 144 |
| 145 static int signature_callback_count; | 145 static int signature_callback_count; |
| 146 static Local<Value> signature_expected_receiver; | 146 static Local<Value> signature_expected_receiver; |
| 147 static void IncrementingSignatureCallback( | 147 static void IncrementingSignatureCallback( |
| 148 const v8::FunctionCallbackInfo<v8::Value>& args) { | 148 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 149 ApiTestFuzzer::Fuzz(); | 149 ApiTestFuzzer::Fuzz(); |
| 150 signature_callback_count++; | 150 signature_callback_count++; |
| 151 CHECK_EQ(signature_expected_receiver, args.Holder()); | 151 CHECK_EQ(signature_expected_receiver, args.Holder()); |
| 152 CHECK_EQ(signature_expected_receiver, args.This()); | 152 CHECK_EQ(signature_expected_receiver, args.This()); |
| 153 v8::Handle<v8::Array> result = v8::Array::New(args.Length()); | 153 v8::Handle<v8::Array> result = |
| 154 v8::Array::New(args.GetIsolate(), args.Length()); |
| 154 for (int i = 0; i < args.Length(); i++) | 155 for (int i = 0; i < args.Length(); i++) |
| 155 result->Set(v8::Integer::New(i), args[i]); | 156 result->Set(v8::Integer::New(i), args[i]); |
| 156 args.GetReturnValue().Set(result); | 157 args.GetReturnValue().Set(result); |
| 157 } | 158 } |
| 158 | 159 |
| 159 | 160 |
| 160 static void SignatureCallback( | 161 static void SignatureCallback( |
| 161 const v8::FunctionCallbackInfo<v8::Value>& args) { | 162 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 162 ApiTestFuzzer::Fuzz(); | 163 ApiTestFuzzer::Fuzz(); |
| 163 v8::Handle<v8::Array> result = v8::Array::New(args.Length()); | 164 v8::Handle<v8::Array> result = |
| 165 v8::Array::New(args.GetIsolate(), args.Length()); |
| 164 for (int i = 0; i < args.Length(); i++) { | 166 for (int i = 0; i < args.Length(); i++) { |
| 165 result->Set(v8::Integer::New(i), args[i]); | 167 result->Set(v8::Integer::New(i), args[i]); |
| 166 } | 168 } |
| 167 args.GetReturnValue().Set(result); | 169 args.GetReturnValue().Set(result); |
| 168 } | 170 } |
| 169 | 171 |
| 170 | 172 |
| 171 // Tests that call v8::V8::Dispose() cannot be threaded. | 173 // Tests that call v8::V8::Dispose() cannot be threaded. |
| 172 TEST(InitializeAndDisposeOnce) { | 174 TEST(InitializeAndDisposeOnce) { |
| 173 CHECK(v8::V8::Initialize()); | 175 CHECK(v8::V8::Initialize()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 try_catch.Exception()->ToString()); | 248 try_catch.Exception()->ToString()); |
| 247 } | 249 } |
| 248 } | 250 } |
| 249 | 251 |
| 250 | 252 |
| 251 THREADED_TEST(ReceiverSignature) { | 253 THREADED_TEST(ReceiverSignature) { |
| 252 LocalContext env; | 254 LocalContext env; |
| 253 v8::HandleScope scope(env->GetIsolate()); | 255 v8::HandleScope scope(env->GetIsolate()); |
| 254 // Setup templates. | 256 // Setup templates. |
| 255 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); | 257 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); |
| 256 v8::Handle<v8::Signature> sig = v8::Signature::New(fun); | 258 v8::Handle<v8::Signature> sig = v8::Signature::New(env->GetIsolate(), fun); |
| 257 v8::Handle<v8::FunctionTemplate> callback_sig = | 259 v8::Handle<v8::FunctionTemplate> callback_sig = |
| 258 v8::FunctionTemplate::New( | 260 v8::FunctionTemplate::New( |
| 259 IncrementingSignatureCallback, Local<Value>(), sig); | 261 IncrementingSignatureCallback, Local<Value>(), sig); |
| 260 v8::Handle<v8::FunctionTemplate> callback = | 262 v8::Handle<v8::FunctionTemplate> callback = |
| 261 v8::FunctionTemplate::New(IncrementingSignatureCallback); | 263 v8::FunctionTemplate::New(IncrementingSignatureCallback); |
| 262 v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(); | 264 v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New(); |
| 263 sub_fun->Inherit(fun); | 265 sub_fun->Inherit(fun); |
| 264 v8::Handle<v8::FunctionTemplate> unrel_fun = v8::FunctionTemplate::New(); | 266 v8::Handle<v8::FunctionTemplate> unrel_fun = v8::FunctionTemplate::New(); |
| 265 // Install properties. | 267 // Install properties. |
| 266 v8::Handle<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate(); | 268 v8::Handle<v8::ObjectTemplate> fun_proto = fun->PrototypeTemplate(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 TestSignature("test_object[accessor_sig_key] = 1;", test_object); | 321 TestSignature("test_object[accessor_sig_key] = 1;", test_object); |
| 320 } | 322 } |
| 321 } | 323 } |
| 322 | 324 |
| 323 | 325 |
| 324 THREADED_TEST(ArgumentSignature) { | 326 THREADED_TEST(ArgumentSignature) { |
| 325 LocalContext env; | 327 LocalContext env; |
| 326 v8::HandleScope scope(env->GetIsolate()); | 328 v8::HandleScope scope(env->GetIsolate()); |
| 327 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(); | 329 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New(); |
| 328 cons->SetClassName(v8_str("Cons")); | 330 cons->SetClassName(v8_str("Cons")); |
| 329 v8::Handle<v8::Signature> sig = | 331 v8::Handle<v8::Signature> sig = v8::Signature::New( |
| 330 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 1, &cons); | 332 env->GetIsolate(), v8::Handle<v8::FunctionTemplate>(), 1, &cons); |
| 331 v8::Handle<v8::FunctionTemplate> fun = | 333 v8::Handle<v8::FunctionTemplate> fun = |
| 332 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), sig); | 334 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), sig); |
| 333 env->Global()->Set(v8_str("Cons"), cons->GetFunction()); | 335 env->Global()->Set(v8_str("Cons"), cons->GetFunction()); |
| 334 env->Global()->Set(v8_str("Fun1"), fun->GetFunction()); | 336 env->Global()->Set(v8_str("Fun1"), fun->GetFunction()); |
| 335 | 337 |
| 336 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';"); | 338 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';"); |
| 337 CHECK(value1->IsTrue()); | 339 CHECK(value1->IsTrue()); |
| 338 | 340 |
| 339 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';"); | 341 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';"); |
| 340 CHECK(value2->IsTrue()); | 342 CHECK(value2->IsTrue()); |
| 341 | 343 |
| 342 v8::Handle<Value> value3 = CompileRun("Fun1() == '';"); | 344 v8::Handle<Value> value3 = CompileRun("Fun1() == '';"); |
| 343 CHECK(value3->IsTrue()); | 345 CHECK(value3->IsTrue()); |
| 344 | 346 |
| 345 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(); | 347 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New(); |
| 346 cons1->SetClassName(v8_str("Cons1")); | 348 cons1->SetClassName(v8_str("Cons1")); |
| 347 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(); | 349 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New(); |
| 348 cons2->SetClassName(v8_str("Cons2")); | 350 cons2->SetClassName(v8_str("Cons2")); |
| 349 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(); | 351 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New(); |
| 350 cons3->SetClassName(v8_str("Cons3")); | 352 cons3->SetClassName(v8_str("Cons3")); |
| 351 | 353 |
| 352 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 }; | 354 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 }; |
| 353 v8::Handle<v8::Signature> wsig = | 355 v8::Handle<v8::Signature> wsig = v8::Signature::New( |
| 354 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 3, args); | 356 env->GetIsolate(), v8::Handle<v8::FunctionTemplate>(), 3, args); |
| 355 v8::Handle<v8::FunctionTemplate> fun2 = | 357 v8::Handle<v8::FunctionTemplate> fun2 = |
| 356 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), wsig); | 358 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), wsig); |
| 357 | 359 |
| 358 env->Global()->Set(v8_str("Cons1"), cons1->GetFunction()); | 360 env->Global()->Set(v8_str("Cons1"), cons1->GetFunction()); |
| 359 env->Global()->Set(v8_str("Cons2"), cons2->GetFunction()); | 361 env->Global()->Set(v8_str("Cons2"), cons2->GetFunction()); |
| 360 env->Global()->Set(v8_str("Cons3"), cons3->GetFunction()); | 362 env->Global()->Set(v8_str("Cons3"), cons3->GetFunction()); |
| 361 env->Global()->Set(v8_str("Fun2"), fun2->GetFunction()); | 363 env->Global()->Set(v8_str("Fun2"), fun2->GetFunction()); |
| 362 v8::Handle<Value> value4 = CompileRun( | 364 v8::Handle<Value> value4 = CompileRun( |
| 363 "Fun2(new Cons1(), new Cons2(), new Cons3()) ==" | 365 "Fun2(new Cons1(), new Cons2(), new Cons3()) ==" |
| 364 "'[object Cons1],[object Cons2],[object Cons3]'"); | 366 "'[object Cons1],[object Cons2],[object Cons3]'"); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 502 |
| 501 | 503 |
| 502 THREADED_TEST(ScriptUsingStringResource) { | 504 THREADED_TEST(ScriptUsingStringResource) { |
| 503 int dispose_count = 0; | 505 int dispose_count = 0; |
| 504 const char* c_source = "1 + 2 * 3"; | 506 const char* c_source = "1 + 2 * 3"; |
| 505 uint16_t* two_byte_source = AsciiToTwoByteString(c_source); | 507 uint16_t* two_byte_source = AsciiToTwoByteString(c_source); |
| 506 { | 508 { |
| 507 LocalContext env; | 509 LocalContext env; |
| 508 v8::HandleScope scope(env->GetIsolate()); | 510 v8::HandleScope scope(env->GetIsolate()); |
| 509 TestResource* resource = new TestResource(two_byte_source, &dispose_count); | 511 TestResource* resource = new TestResource(two_byte_source, &dispose_count); |
| 510 Local<String> source = String::NewExternal(resource); | 512 Local<String> source = String::NewExternal(env->GetIsolate(), resource); |
| 511 Local<Script> script = Script::Compile(source); | 513 Local<Script> script = Script::Compile(source); |
| 512 Local<Value> value = script->Run(); | 514 Local<Value> value = script->Run(); |
| 513 CHECK(value->IsNumber()); | 515 CHECK(value->IsNumber()); |
| 514 CHECK_EQ(7, value->Int32Value()); | 516 CHECK_EQ(7, value->Int32Value()); |
| 515 CHECK(source->IsExternal()); | 517 CHECK(source->IsExternal()); |
| 516 CHECK_EQ(resource, | 518 CHECK_EQ(resource, |
| 517 static_cast<TestResource*>(source->GetExternalStringResource())); | 519 static_cast<TestResource*>(source->GetExternalStringResource())); |
| 518 String::Encoding encoding = String::UNKNOWN_ENCODING; | 520 String::Encoding encoding = String::UNKNOWN_ENCODING; |
| 519 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 521 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
| 520 source->GetExternalStringResourceBase(&encoding)); | 522 source->GetExternalStringResourceBase(&encoding)); |
| 521 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); | 523 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); |
| 522 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 524 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 523 CHECK_EQ(0, dispose_count); | 525 CHECK_EQ(0, dispose_count); |
| 524 } | 526 } |
| 525 CcTest::i_isolate()->compilation_cache()->Clear(); | 527 CcTest::i_isolate()->compilation_cache()->Clear(); |
| 526 CcTest::heap()->CollectAllAvailableGarbage(); | 528 CcTest::heap()->CollectAllAvailableGarbage(); |
| 527 CHECK_EQ(1, dispose_count); | 529 CHECK_EQ(1, dispose_count); |
| 528 } | 530 } |
| 529 | 531 |
| 530 | 532 |
| 531 THREADED_TEST(ScriptUsingAsciiStringResource) { | 533 THREADED_TEST(ScriptUsingAsciiStringResource) { |
| 532 int dispose_count = 0; | 534 int dispose_count = 0; |
| 533 const char* c_source = "1 + 2 * 3"; | 535 const char* c_source = "1 + 2 * 3"; |
| 534 { | 536 { |
| 535 LocalContext env; | 537 LocalContext env; |
| 536 v8::HandleScope scope(env->GetIsolate()); | 538 v8::HandleScope scope(env->GetIsolate()); |
| 537 TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source), | 539 TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source), |
| 538 &dispose_count); | 540 &dispose_count); |
| 539 Local<String> source = String::NewExternal(resource); | 541 Local<String> source = String::NewExternal(env->GetIsolate(), resource); |
| 540 CHECK(source->IsExternalAscii()); | 542 CHECK(source->IsExternalAscii()); |
| 541 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 543 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
| 542 source->GetExternalAsciiStringResource()); | 544 source->GetExternalAsciiStringResource()); |
| 543 String::Encoding encoding = String::UNKNOWN_ENCODING; | 545 String::Encoding encoding = String::UNKNOWN_ENCODING; |
| 544 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 546 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
| 545 source->GetExternalStringResourceBase(&encoding)); | 547 source->GetExternalStringResourceBase(&encoding)); |
| 546 CHECK_EQ(String::ASCII_ENCODING, encoding); | 548 CHECK_EQ(String::ASCII_ENCODING, encoding); |
| 547 Local<Script> script = Script::Compile(source); | 549 Local<Script> script = Script::Compile(source); |
| 548 Local<Value> value = script->Run(); | 550 Local<Value> value = script->Run(); |
| 549 CHECK(value->IsNumber()); | 551 CHECK(value->IsNumber()); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 735 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 734 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); | 736 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); |
| 735 } | 737 } |
| 736 | 738 |
| 737 | 739 |
| 738 THREADED_TEST(UsingExternalString) { | 740 THREADED_TEST(UsingExternalString) { |
| 739 i::Factory* factory = CcTest::i_isolate()->factory(); | 741 i::Factory* factory = CcTest::i_isolate()->factory(); |
| 740 { | 742 { |
| 741 v8::HandleScope scope(CcTest::isolate()); | 743 v8::HandleScope scope(CcTest::isolate()); |
| 742 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 744 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 743 Local<String> string = | 745 Local<String> string = String::NewExternal( |
| 744 String::NewExternal(new TestResource(two_byte_string)); | 746 CcTest::isolate(), new TestResource(two_byte_string)); |
| 745 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 747 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 746 // Trigger GCs so that the newly allocated string moves to old gen. | 748 // Trigger GCs so that the newly allocated string moves to old gen. |
| 747 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 749 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 748 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 750 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 749 i::Handle<i::String> isymbol = | 751 i::Handle<i::String> isymbol = |
| 750 factory->InternalizedStringFromString(istring); | 752 factory->InternalizedStringFromString(istring); |
| 751 CHECK(isymbol->IsInternalizedString()); | 753 CHECK(isymbol->IsInternalizedString()); |
| 752 } | 754 } |
| 753 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 755 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 754 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 756 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 755 } | 757 } |
| 756 | 758 |
| 757 | 759 |
| 758 THREADED_TEST(UsingExternalAsciiString) { | 760 THREADED_TEST(UsingExternalAsciiString) { |
| 759 i::Factory* factory = CcTest::i_isolate()->factory(); | 761 i::Factory* factory = CcTest::i_isolate()->factory(); |
| 760 { | 762 { |
| 761 v8::HandleScope scope(CcTest::isolate()); | 763 v8::HandleScope scope(CcTest::isolate()); |
| 762 const char* one_byte_string = "test string"; | 764 const char* one_byte_string = "test string"; |
| 763 Local<String> string = String::NewExternal( | 765 Local<String> string = String::NewExternal( |
| 764 new TestAsciiResource(i::StrDup(one_byte_string))); | 766 CcTest::isolate(), new TestAsciiResource(i::StrDup(one_byte_string))); |
| 765 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 767 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 766 // Trigger GCs so that the newly allocated string moves to old gen. | 768 // Trigger GCs so that the newly allocated string moves to old gen. |
| 767 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 769 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
| 768 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 770 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
| 769 i::Handle<i::String> isymbol = | 771 i::Handle<i::String> isymbol = |
| 770 factory->InternalizedStringFromString(istring); | 772 factory->InternalizedStringFromString(istring); |
| 771 CHECK(isymbol->IsInternalizedString()); | 773 CHECK(isymbol->IsInternalizedString()); |
| 772 } | 774 } |
| 773 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 775 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 774 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 776 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 775 } | 777 } |
| 776 | 778 |
| 777 | 779 |
| 778 THREADED_TEST(ScavengeExternalString) { | 780 THREADED_TEST(ScavengeExternalString) { |
| 779 i::FLAG_stress_compaction = false; | 781 i::FLAG_stress_compaction = false; |
| 780 i::FLAG_gc_global = false; | 782 i::FLAG_gc_global = false; |
| 781 int dispose_count = 0; | 783 int dispose_count = 0; |
| 782 bool in_new_space = false; | 784 bool in_new_space = false; |
| 783 { | 785 { |
| 784 v8::HandleScope scope(CcTest::isolate()); | 786 v8::HandleScope scope(CcTest::isolate()); |
| 785 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 787 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
| 786 Local<String> string = | 788 Local<String> string = String::NewExternal( |
| 787 String::NewExternal(new TestResource(two_byte_string, | 789 CcTest::isolate(), new TestResource(two_byte_string, &dispose_count)); |
| 788 &dispose_count)); | |
| 789 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 790 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 790 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 791 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
| 791 in_new_space = CcTest::heap()->InNewSpace(*istring); | 792 in_new_space = CcTest::heap()->InNewSpace(*istring); |
| 792 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); | 793 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); |
| 793 CHECK_EQ(0, dispose_count); | 794 CHECK_EQ(0, dispose_count); |
| 794 } | 795 } |
| 795 CcTest::heap()->CollectGarbage( | 796 CcTest::heap()->CollectGarbage( |
| 796 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 797 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
| 797 CHECK_EQ(1, dispose_count); | 798 CHECK_EQ(1, dispose_count); |
| 798 } | 799 } |
| 799 | 800 |
| 800 | 801 |
| 801 THREADED_TEST(ScavengeExternalAsciiString) { | 802 THREADED_TEST(ScavengeExternalAsciiString) { |
| 802 i::FLAG_stress_compaction = false; | 803 i::FLAG_stress_compaction = false; |
| 803 i::FLAG_gc_global = false; | 804 i::FLAG_gc_global = false; |
| 804 int dispose_count = 0; | 805 int dispose_count = 0; |
| 805 bool in_new_space = false; | 806 bool in_new_space = false; |
| 806 { | 807 { |
| 807 v8::HandleScope scope(CcTest::isolate()); | 808 v8::HandleScope scope(CcTest::isolate()); |
| 808 const char* one_byte_string = "test string"; | 809 const char* one_byte_string = "test string"; |
| 809 Local<String> string = String::NewExternal( | 810 Local<String> string = String::NewExternal( |
| 811 CcTest::isolate(), |
| 810 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); | 812 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); |
| 811 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 813 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
| 812 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 814 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
| 813 in_new_space = CcTest::heap()->InNewSpace(*istring); | 815 in_new_space = CcTest::heap()->InNewSpace(*istring); |
| 814 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); | 816 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); |
| 815 CHECK_EQ(0, dispose_count); | 817 CHECK_EQ(0, dispose_count); |
| 816 } | 818 } |
| 817 CcTest::heap()->CollectGarbage( | 819 CcTest::heap()->CollectGarbage( |
| 818 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 820 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
| 819 CHECK_EQ(1, dispose_count); | 821 CHECK_EQ(1, dispose_count); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 846 TEST(ExternalStringWithDisposeHandling) { | 848 TEST(ExternalStringWithDisposeHandling) { |
| 847 const char* c_source = "1 + 2 * 3"; | 849 const char* c_source = "1 + 2 * 3"; |
| 848 | 850 |
| 849 // Use a stack allocated external string resource allocated object. | 851 // Use a stack allocated external string resource allocated object. |
| 850 TestAsciiResourceWithDisposeControl::dispose_count = 0; | 852 TestAsciiResourceWithDisposeControl::dispose_count = 0; |
| 851 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 853 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 852 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); | 854 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); |
| 853 { | 855 { |
| 854 LocalContext env; | 856 LocalContext env; |
| 855 v8::HandleScope scope(env->GetIsolate()); | 857 v8::HandleScope scope(env->GetIsolate()); |
| 856 Local<String> source = String::NewExternal(&res_stack); | 858 Local<String> source = String::NewExternal(env->GetIsolate(), &res_stack); |
| 857 Local<Script> script = Script::Compile(source); | 859 Local<Script> script = Script::Compile(source); |
| 858 Local<Value> value = script->Run(); | 860 Local<Value> value = script->Run(); |
| 859 CHECK(value->IsNumber()); | 861 CHECK(value->IsNumber()); |
| 860 CHECK_EQ(7, value->Int32Value()); | 862 CHECK_EQ(7, value->Int32Value()); |
| 861 CcTest::heap()->CollectAllAvailableGarbage(); | 863 CcTest::heap()->CollectAllAvailableGarbage(); |
| 862 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 864 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 863 } | 865 } |
| 864 CcTest::i_isolate()->compilation_cache()->Clear(); | 866 CcTest::i_isolate()->compilation_cache()->Clear(); |
| 865 CcTest::heap()->CollectAllAvailableGarbage(); | 867 CcTest::heap()->CollectAllAvailableGarbage(); |
| 866 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 868 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| 867 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 869 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 868 | 870 |
| 869 // Use a heap allocated external string resource allocated object. | 871 // Use a heap allocated external string resource allocated object. |
| 870 TestAsciiResourceWithDisposeControl::dispose_count = 0; | 872 TestAsciiResourceWithDisposeControl::dispose_count = 0; |
| 871 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 873 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
| 872 TestAsciiResource* res_heap = | 874 TestAsciiResource* res_heap = |
| 873 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); | 875 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); |
| 874 { | 876 { |
| 875 LocalContext env; | 877 LocalContext env; |
| 876 v8::HandleScope scope(env->GetIsolate()); | 878 v8::HandleScope scope(env->GetIsolate()); |
| 877 Local<String> source = String::NewExternal(res_heap); | 879 Local<String> source = String::NewExternal(env->GetIsolate(), res_heap); |
| 878 Local<Script> script = Script::Compile(source); | 880 Local<Script> script = Script::Compile(source); |
| 879 Local<Value> value = script->Run(); | 881 Local<Value> value = script->Run(); |
| 880 CHECK(value->IsNumber()); | 882 CHECK(value->IsNumber()); |
| 881 CHECK_EQ(7, value->Int32Value()); | 883 CHECK_EQ(7, value->Int32Value()); |
| 882 CcTest::heap()->CollectAllAvailableGarbage(); | 884 CcTest::heap()->CollectAllAvailableGarbage(); |
| 883 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 885 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
| 884 } | 886 } |
| 885 CcTest::i_isolate()->compilation_cache()->Clear(); | 887 CcTest::i_isolate()->compilation_cache()->Clear(); |
| 886 CcTest::heap()->CollectAllAvailableGarbage(); | 888 CcTest::heap()->CollectAllAvailableGarbage(); |
| 887 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 889 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 902 const char* two_byte_extern_2 = "a_times_two_plus_b(1, 2);"; | 904 const char* two_byte_extern_2 = "a_times_two_plus_b(1, 2);"; |
| 903 Local<String> left = v8_str(one_byte_string_1); | 905 Local<String> left = v8_str(one_byte_string_1); |
| 904 | 906 |
| 905 uint16_t* two_byte_source = AsciiToTwoByteString(two_byte_string_1); | 907 uint16_t* two_byte_source = AsciiToTwoByteString(two_byte_string_1); |
| 906 Local<String> right = | 908 Local<String> right = |
| 907 String::NewFromTwoByte(env->GetIsolate(), two_byte_source); | 909 String::NewFromTwoByte(env->GetIsolate(), two_byte_source); |
| 908 i::DeleteArray(two_byte_source); | 910 i::DeleteArray(two_byte_source); |
| 909 | 911 |
| 910 Local<String> source = String::Concat(left, right); | 912 Local<String> source = String::Concat(left, right); |
| 911 right = String::NewExternal( | 913 right = String::NewExternal( |
| 912 new TestAsciiResource(i::StrDup(one_byte_extern_1))); | 914 env->GetIsolate(), new TestAsciiResource(i::StrDup(one_byte_extern_1))); |
| 913 source = String::Concat(source, right); | 915 source = String::Concat(source, right); |
| 914 right = String::NewExternal( | 916 right = String::NewExternal( |
| 917 env->GetIsolate(), |
| 915 new TestResource(AsciiToTwoByteString(two_byte_extern_1))); | 918 new TestResource(AsciiToTwoByteString(two_byte_extern_1))); |
| 916 source = String::Concat(source, right); | 919 source = String::Concat(source, right); |
| 917 right = v8_str(one_byte_string_2); | 920 right = v8_str(one_byte_string_2); |
| 918 source = String::Concat(source, right); | 921 source = String::Concat(source, right); |
| 919 | 922 |
| 920 two_byte_source = AsciiToTwoByteString(two_byte_string_2); | 923 two_byte_source = AsciiToTwoByteString(two_byte_string_2); |
| 921 right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source); | 924 right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source); |
| 922 i::DeleteArray(two_byte_source); | 925 i::DeleteArray(two_byte_source); |
| 923 | 926 |
| 924 source = String::Concat(source, right); | 927 source = String::Concat(source, right); |
| 925 right = String::NewExternal( | 928 right = String::NewExternal( |
| 929 env->GetIsolate(), |
| 926 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); | 930 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); |
| 927 source = String::Concat(source, right); | 931 source = String::Concat(source, right); |
| 928 Local<Script> script = Script::Compile(source); | 932 Local<Script> script = Script::Compile(source); |
| 929 Local<Value> value = script->Run(); | 933 Local<Value> value = script->Run(); |
| 930 CHECK(value->IsNumber()); | 934 CHECK(value->IsNumber()); |
| 931 CHECK_EQ(68, value->Int32Value()); | 935 CHECK_EQ(68, value->Int32Value()); |
| 932 } | 936 } |
| 933 CcTest::i_isolate()->compilation_cache()->Clear(); | 937 CcTest::i_isolate()->compilation_cache()->Clear(); |
| 934 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 938 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 935 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 939 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 info.GetReturnValue().Set(v8_num(51423 + info.Length())); | 1088 info.GetReturnValue().Set(v8_num(51423 + info.Length())); |
| 1085 } | 1089 } |
| 1086 | 1090 |
| 1087 | 1091 |
| 1088 template<typename Callback> | 1092 template<typename Callback> |
| 1089 static void TestSimpleCallback(Callback callback) { | 1093 static void TestSimpleCallback(Callback callback) { |
| 1090 LocalContext env; | 1094 LocalContext env; |
| 1091 v8::HandleScope scope(env->GetIsolate()); | 1095 v8::HandleScope scope(env->GetIsolate()); |
| 1092 | 1096 |
| 1093 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 1097 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 1094 object_template->Set("callback", v8::FunctionTemplate::New(callback)); | 1098 object_template->Set(env->GetIsolate(), "callback", |
| 1099 v8::FunctionTemplate::New(callback)); |
| 1095 v8::Local<v8::Object> object = object_template->NewInstance(); | 1100 v8::Local<v8::Object> object = object_template->NewInstance(); |
| 1096 (*env)->Global()->Set(v8_str("callback_object"), object); | 1101 (*env)->Global()->Set(v8_str("callback_object"), object); |
| 1097 v8::Handle<v8::Script> script; | 1102 v8::Handle<v8::Script> script; |
| 1098 script = v8_compile("callback_object.callback(17)"); | 1103 script = v8_compile("callback_object.callback(17)"); |
| 1099 for (int i = 0; i < 30; i++) { | 1104 for (int i = 0; i < 30; i++) { |
| 1100 CHECK_EQ(51424, script->Run()->Int32Value()); | 1105 CHECK_EQ(51424, script->Run()->Int32Value()); |
| 1101 } | 1106 } |
| 1102 script = v8_compile("callback_object.callback(17, 24)"); | 1107 script = v8_compile("callback_object.callback(17, 24)"); |
| 1103 for (int i = 0; i < 30; i++) { | 1108 for (int i = 0; i < 30; i++) { |
| 1104 CHECK_EQ(51425, script->Run()->Int32Value()); | 1109 CHECK_EQ(51425, script->Run()->Int32Value()); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 if (!fast_return_value_object_is_empty) object = Object::New(); | 1191 if (!fast_return_value_object_is_empty) object = Object::New(); |
| 1187 info.GetReturnValue().Set(object); | 1192 info.GetReturnValue().Set(object); |
| 1188 } | 1193 } |
| 1189 | 1194 |
| 1190 template<typename T> | 1195 template<typename T> |
| 1191 Handle<Value> TestFastReturnValues() { | 1196 Handle<Value> TestFastReturnValues() { |
| 1192 LocalContext env; | 1197 LocalContext env; |
| 1193 v8::HandleScope scope(env->GetIsolate()); | 1198 v8::HandleScope scope(env->GetIsolate()); |
| 1194 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); | 1199 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); |
| 1195 v8::FunctionCallback callback = &FastReturnValueCallback<T>; | 1200 v8::FunctionCallback callback = &FastReturnValueCallback<T>; |
| 1196 object_template->Set("callback", v8::FunctionTemplate::New(callback)); | 1201 object_template->Set(env->GetIsolate(), "callback", |
| 1202 v8::FunctionTemplate::New(callback)); |
| 1197 v8::Local<v8::Object> object = object_template->NewInstance(); | 1203 v8::Local<v8::Object> object = object_template->NewInstance(); |
| 1198 (*env)->Global()->Set(v8_str("callback_object"), object); | 1204 (*env)->Global()->Set(v8_str("callback_object"), object); |
| 1199 return scope.Close(CompileRun("callback_object.callback()")); | 1205 return scope.Close(CompileRun("callback_object.callback()")); |
| 1200 } | 1206 } |
| 1201 | 1207 |
| 1202 | 1208 |
| 1203 THREADED_PROFILED_TEST(FastReturnValues) { | 1209 THREADED_PROFILED_TEST(FastReturnValues) { |
| 1204 LocalContext env; | 1210 LocalContext env; |
| 1205 v8::HandleScope scope(CcTest::isolate()); | 1211 v8::HandleScope scope(CcTest::isolate()); |
| 1206 v8::Handle<v8::Value> value; | 1212 v8::Handle<v8::Value> value; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); | 1593 v8::Handle<Value> boxed_number = CompileRun("new Number(42)"); |
| 1588 CHECK(boxed_number->IsNumberObject()); | 1594 CHECK(boxed_number->IsNumberObject()); |
| 1589 v8::Handle<Value> unboxed_number = CompileRun("42"); | 1595 v8::Handle<Value> unboxed_number = CompileRun("42"); |
| 1590 CHECK(!unboxed_number->IsNumberObject()); | 1596 CHECK(!unboxed_number->IsNumberObject()); |
| 1591 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); | 1597 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)"); |
| 1592 CHECK(!boxed_not_number->IsNumberObject()); | 1598 CHECK(!boxed_not_number->IsNumberObject()); |
| 1593 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>(); | 1599 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>(); |
| 1594 CHECK(!as_boxed.IsEmpty()); | 1600 CHECK(!as_boxed.IsEmpty()); |
| 1595 double the_number = as_boxed->ValueOf(); | 1601 double the_number = as_boxed->ValueOf(); |
| 1596 CHECK_EQ(42.0, the_number); | 1602 CHECK_EQ(42.0, the_number); |
| 1597 v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43); | 1603 v8::Handle<v8::Value> new_boxed_number = |
| 1604 v8::NumberObject::New(env->GetIsolate(), 43); |
| 1598 CHECK(new_boxed_number->IsNumberObject()); | 1605 CHECK(new_boxed_number->IsNumberObject()); |
| 1599 as_boxed = new_boxed_number.As<v8::NumberObject>(); | 1606 as_boxed = new_boxed_number.As<v8::NumberObject>(); |
| 1600 the_number = as_boxed->ValueOf(); | 1607 the_number = as_boxed->ValueOf(); |
| 1601 CHECK_EQ(43.0, the_number); | 1608 CHECK_EQ(43.0, the_number); |
| 1602 } | 1609 } |
| 1603 | 1610 |
| 1604 | 1611 |
| 1605 THREADED_TEST(BooleanObject) { | 1612 THREADED_TEST(BooleanObject) { |
| 1606 LocalContext env; | 1613 LocalContext env; |
| 1607 v8::HandleScope scope(env->GetIsolate()); | 1614 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 CHECK_EQ(1.0, t->NumberValue()); | 1705 CHECK_EQ(1.0, t->NumberValue()); |
| 1699 v8::Handle<v8::Boolean> f = v8::False(isolate); | 1706 v8::Handle<v8::Boolean> f = v8::False(isolate); |
| 1700 CHECK_EQ(0.0, f->NumberValue()); | 1707 CHECK_EQ(0.0, f->NumberValue()); |
| 1701 } | 1708 } |
| 1702 | 1709 |
| 1703 | 1710 |
| 1704 THREADED_TEST(Date) { | 1711 THREADED_TEST(Date) { |
| 1705 LocalContext env; | 1712 LocalContext env; |
| 1706 v8::HandleScope scope(env->GetIsolate()); | 1713 v8::HandleScope scope(env->GetIsolate()); |
| 1707 double PI = 3.1415926; | 1714 double PI = 3.1415926; |
| 1708 Local<Value> date = v8::Date::New(PI); | 1715 Local<Value> date = v8::Date::New(env->GetIsolate(), PI); |
| 1709 CHECK_EQ(3.0, date->NumberValue()); | 1716 CHECK_EQ(3.0, date->NumberValue()); |
| 1710 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42)); | 1717 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42)); |
| 1711 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value()); | 1718 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value()); |
| 1712 } | 1719 } |
| 1713 | 1720 |
| 1714 | 1721 |
| 1715 THREADED_TEST(Boolean) { | 1722 THREADED_TEST(Boolean) { |
| 1716 LocalContext env; | 1723 LocalContext env; |
| 1717 v8::HandleScope scope(env->GetIsolate()); | 1724 v8::HandleScope scope(env->GetIsolate()); |
| 1718 v8::Handle<v8::Boolean> t = v8::True(CcTest::isolate()); | 1725 v8::Handle<v8::Boolean> t = v8::True(CcTest::isolate()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1745 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1752 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1746 ApiTestFuzzer::Fuzz(); | 1753 ApiTestFuzzer::Fuzz(); |
| 1747 info.GetReturnValue().Set(v8_num(876)); | 1754 info.GetReturnValue().Set(v8_num(876)); |
| 1748 } | 1755 } |
| 1749 | 1756 |
| 1750 | 1757 |
| 1751 THREADED_TEST(GlobalPrototype) { | 1758 THREADED_TEST(GlobalPrototype) { |
| 1752 v8::HandleScope scope(CcTest::isolate()); | 1759 v8::HandleScope scope(CcTest::isolate()); |
| 1753 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); | 1760 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); |
| 1754 func_templ->PrototypeTemplate()->Set( | 1761 func_templ->PrototypeTemplate()->Set( |
| 1755 "dummy", | 1762 CcTest::isolate(), "dummy", v8::FunctionTemplate::New(DummyCallHandler)); |
| 1756 v8::FunctionTemplate::New(DummyCallHandler)); | |
| 1757 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); | 1763 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate(); |
| 1758 templ->Set("x", v8_num(200)); | 1764 templ->Set(CcTest::isolate(), "x", v8_num(200)); |
| 1759 templ->SetAccessor(v8_str("m"), GetM); | 1765 templ->SetAccessor(v8_str("m"), GetM); |
| 1760 LocalContext env(0, templ); | 1766 LocalContext env(0, templ); |
| 1761 v8::Handle<Script> script(v8_compile("dummy()")); | 1767 v8::Handle<Script> script(v8_compile("dummy()")); |
| 1762 v8::Handle<Value> result(script->Run()); | 1768 v8::Handle<Value> result(script->Run()); |
| 1763 CHECK_EQ(13.4, result->NumberValue()); | 1769 CHECK_EQ(13.4, result->NumberValue()); |
| 1764 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); | 1770 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); |
| 1765 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); | 1771 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); |
| 1766 } | 1772 } |
| 1767 | 1773 |
| 1768 | 1774 |
| 1769 THREADED_TEST(ObjectTemplate) { | 1775 THREADED_TEST(ObjectTemplate) { |
| 1770 v8::HandleScope scope(CcTest::isolate()); | 1776 v8::HandleScope scope(CcTest::isolate()); |
| 1771 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); | 1777 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); |
| 1772 templ1->Set("x", v8_num(10)); | 1778 templ1->Set(CcTest::isolate(), "x", v8_num(10)); |
| 1773 templ1->Set("y", v8_num(13)); | 1779 templ1->Set(CcTest::isolate(), "y", v8_num(13)); |
| 1774 LocalContext env; | 1780 LocalContext env; |
| 1775 Local<v8::Object> instance1 = templ1->NewInstance(); | 1781 Local<v8::Object> instance1 = templ1->NewInstance(); |
| 1776 env->Global()->Set(v8_str("p"), instance1); | 1782 env->Global()->Set(v8_str("p"), instance1); |
| 1777 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); | 1783 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); |
| 1778 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); | 1784 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); |
| 1779 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); | 1785 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); |
| 1780 fun->PrototypeTemplate()->Set("nirk", v8_num(123)); | 1786 fun->PrototypeTemplate()->Set(CcTest::isolate(), "nirk", v8_num(123)); |
| 1781 Local<ObjectTemplate> templ2 = fun->InstanceTemplate(); | 1787 Local<ObjectTemplate> templ2 = fun->InstanceTemplate(); |
| 1782 templ2->Set("a", v8_num(12)); | 1788 templ2->Set(CcTest::isolate(), "a", v8_num(12)); |
| 1783 templ2->Set("b", templ1); | 1789 templ2->Set(CcTest::isolate(), "b", templ1); |
| 1784 Local<v8::Object> instance2 = templ2->NewInstance(); | 1790 Local<v8::Object> instance2 = templ2->NewInstance(); |
| 1785 env->Global()->Set(v8_str("q"), instance2); | 1791 env->Global()->Set(v8_str("q"), instance2); |
| 1786 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue()); | 1792 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue()); |
| 1787 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue()); | 1793 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue()); |
| 1788 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue()); | 1794 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue()); |
| 1789 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue()); | 1795 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue()); |
| 1790 } | 1796 } |
| 1791 | 1797 |
| 1792 | 1798 |
| 1793 static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) { | 1799 static void GetFlabby(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 1794 ApiTestFuzzer::Fuzz(); | 1800 ApiTestFuzzer::Fuzz(); |
| 1795 args.GetReturnValue().Set(v8_num(17.2)); | 1801 args.GetReturnValue().Set(v8_num(17.2)); |
| 1796 } | 1802 } |
| 1797 | 1803 |
| 1798 | 1804 |
| 1799 static void GetKnurd(Local<String> property, | 1805 static void GetKnurd(Local<String> property, |
| 1800 const v8::PropertyCallbackInfo<v8::Value>& info) { | 1806 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 1801 ApiTestFuzzer::Fuzz(); | 1807 ApiTestFuzzer::Fuzz(); |
| 1802 info.GetReturnValue().Set(v8_num(15.2)); | 1808 info.GetReturnValue().Set(v8_num(15.2)); |
| 1803 } | 1809 } |
| 1804 | 1810 |
| 1805 | 1811 |
| 1806 THREADED_TEST(DescriptorInheritance) { | 1812 THREADED_TEST(DescriptorInheritance) { |
| 1807 v8::HandleScope scope(CcTest::isolate()); | 1813 v8::HandleScope scope(CcTest::isolate()); |
| 1808 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); | 1814 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); |
| 1809 super->PrototypeTemplate()->Set("flabby", | 1815 super->PrototypeTemplate()->Set(CcTest::isolate(), "flabby", |
| 1810 v8::FunctionTemplate::New(GetFlabby)); | 1816 v8::FunctionTemplate::New(GetFlabby)); |
| 1811 super->PrototypeTemplate()->Set("PI", v8_num(3.14)); | 1817 super->PrototypeTemplate()->Set(CcTest::isolate(), "PI", v8_num(3.14)); |
| 1812 | 1818 |
| 1813 super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd); | 1819 super->InstanceTemplate()->SetAccessor(v8_str("knurd"), GetKnurd); |
| 1814 | 1820 |
| 1815 v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(); | 1821 v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New(); |
| 1816 base1->Inherit(super); | 1822 base1->Inherit(super); |
| 1817 base1->PrototypeTemplate()->Set("v1", v8_num(20.1)); | 1823 base1->PrototypeTemplate()->Set(CcTest::isolate(), "v1", v8_num(20.1)); |
| 1818 | 1824 |
| 1819 v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(); | 1825 v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New(); |
| 1820 base2->Inherit(super); | 1826 base2->Inherit(super); |
| 1821 base2->PrototypeTemplate()->Set("v2", v8_num(10.1)); | 1827 base2->PrototypeTemplate()->Set(CcTest::isolate(), "v2", v8_num(10.1)); |
| 1822 | 1828 |
| 1823 LocalContext env; | 1829 LocalContext env; |
| 1824 | 1830 |
| 1825 env->Global()->Set(v8_str("s"), super->GetFunction()); | 1831 env->Global()->Set(v8_str("s"), super->GetFunction()); |
| 1826 env->Global()->Set(v8_str("base1"), base1->GetFunction()); | 1832 env->Global()->Set(v8_str("base1"), base1->GetFunction()); |
| 1827 env->Global()->Set(v8_str("base2"), base2->GetFunction()); | 1833 env->Global()->Set(v8_str("base2"), base2->GetFunction()); |
| 1828 | 1834 |
| 1829 // Checks right __proto__ chain. | 1835 // Checks right __proto__ chain. |
| 1830 CHECK(CompileRun("base1.prototype.__proto__ == s.prototype")->BooleanValue()); | 1836 CHECK(CompileRun("base1.prototype.__proto__ == s.prototype")->BooleanValue()); |
| 1831 CHECK(CompileRun("base2.prototype.__proto__ == s.prototype")->BooleanValue()); | 1837 CHECK(CompileRun("base2.prototype.__proto__ == s.prototype")->BooleanValue()); |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2840 CHECK_EQ(0, value->GetInternalField(i)->Int32Value()); | 2846 CHECK_EQ(0, value->GetInternalField(i)->Int32Value()); |
| 2841 } | 2847 } |
| 2842 } | 2848 } |
| 2843 | 2849 |
| 2844 | 2850 |
| 2845 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { | 2851 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { |
| 2846 LocalContext env; | 2852 LocalContext env; |
| 2847 v8::Isolate* isolate = env->GetIsolate(); | 2853 v8::Isolate* isolate = env->GetIsolate(); |
| 2848 v8::HandleScope handle_scope(isolate); | 2854 v8::HandleScope handle_scope(isolate); |
| 2849 | 2855 |
| 2850 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(1024); | 2856 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 1024); |
| 2851 CheckInternalFieldsAreZero(ab); | 2857 CheckInternalFieldsAreZero(ab); |
| 2852 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); | 2858 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); |
| 2853 CHECK(!ab->IsExternal()); | 2859 CHECK(!ab->IsExternal()); |
| 2854 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | 2860 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 2855 | 2861 |
| 2856 ScopedArrayBufferContents ab_contents(ab->Externalize()); | 2862 ScopedArrayBufferContents ab_contents(ab->Externalize()); |
| 2857 CHECK(ab->IsExternal()); | 2863 CHECK(ab->IsExternal()); |
| 2858 | 2864 |
| 2859 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); | 2865 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); |
| 2860 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); | 2866 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2920 } | 2926 } |
| 2921 | 2927 |
| 2922 | 2928 |
| 2923 THREADED_TEST(ArrayBuffer_External) { | 2929 THREADED_TEST(ArrayBuffer_External) { |
| 2924 LocalContext env; | 2930 LocalContext env; |
| 2925 v8::Isolate* isolate = env->GetIsolate(); | 2931 v8::Isolate* isolate = env->GetIsolate(); |
| 2926 v8::HandleScope handle_scope(isolate); | 2932 v8::HandleScope handle_scope(isolate); |
| 2927 | 2933 |
| 2928 i::ScopedVector<uint8_t> my_data(100); | 2934 i::ScopedVector<uint8_t> my_data(100); |
| 2929 memset(my_data.start(), 0, 100); | 2935 memset(my_data.start(), 0, 100); |
| 2930 Local<v8::ArrayBuffer> ab3 = v8::ArrayBuffer::New(my_data.start(), 100); | 2936 Local<v8::ArrayBuffer> ab3 = |
| 2937 v8::ArrayBuffer::New(isolate, my_data.start(), 100); |
| 2931 CheckInternalFieldsAreZero(ab3); | 2938 CheckInternalFieldsAreZero(ab3); |
| 2932 CHECK_EQ(100, static_cast<int>(ab3->ByteLength())); | 2939 CHECK_EQ(100, static_cast<int>(ab3->ByteLength())); |
| 2933 CHECK(ab3->IsExternal()); | 2940 CHECK(ab3->IsExternal()); |
| 2934 | 2941 |
| 2935 env->Global()->Set(v8_str("ab3"), ab3); | 2942 env->Global()->Set(v8_str("ab3"), ab3); |
| 2936 | 2943 |
| 2937 v8::Handle<v8::Value> result = CompileRun("ab3.byteLength"); | 2944 v8::Handle<v8::Value> result = CompileRun("ab3.byteLength"); |
| 2938 CHECK_EQ(100, result->Int32Value()); | 2945 CHECK_EQ(100, result->Int32Value()); |
| 2939 | 2946 |
| 2940 result = CompileRun("var u8_b = new Uint8Array(ab3);" | 2947 result = CompileRun("var u8_b = new Uint8Array(ab3);" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 CHECK_EQ(length * kElementSize, static_cast<int>(ta->ByteLength())); | 2994 CHECK_EQ(length * kElementSize, static_cast<int>(ta->ByteLength())); |
| 2988 return ta; | 2995 return ta; |
| 2989 } | 2996 } |
| 2990 | 2997 |
| 2991 | 2998 |
| 2992 THREADED_TEST(ArrayBuffer_NeuteringApi) { | 2999 THREADED_TEST(ArrayBuffer_NeuteringApi) { |
| 2993 LocalContext env; | 3000 LocalContext env; |
| 2994 v8::Isolate* isolate = env->GetIsolate(); | 3001 v8::Isolate* isolate = env->GetIsolate(); |
| 2995 v8::HandleScope handle_scope(isolate); | 3002 v8::HandleScope handle_scope(isolate); |
| 2996 | 3003 |
| 2997 v8::Handle<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(1024); | 3004 v8::Handle<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(isolate, 1024); |
| 2998 | 3005 |
| 2999 v8::Handle<v8::Uint8Array> u8a = | 3006 v8::Handle<v8::Uint8Array> u8a = |
| 3000 CreateAndCheck<v8::Uint8Array, 1>(buffer, 1, 1023); | 3007 CreateAndCheck<v8::Uint8Array, 1>(buffer, 1, 1023); |
| 3001 v8::Handle<v8::Uint8ClampedArray> u8c = | 3008 v8::Handle<v8::Uint8ClampedArray> u8c = |
| 3002 CreateAndCheck<v8::Uint8ClampedArray, 1>(buffer, 1, 1023); | 3009 CreateAndCheck<v8::Uint8ClampedArray, 1>(buffer, 1, 1023); |
| 3003 v8::Handle<v8::Int8Array> i8a = | 3010 v8::Handle<v8::Int8Array> i8a = |
| 3004 CreateAndCheck<v8::Int8Array, 1>(buffer, 1, 1023); | 3011 CreateAndCheck<v8::Int8Array, 1>(buffer, 1, 1023); |
| 3005 | 3012 |
| 3006 v8::Handle<v8::Uint16Array> u16a = | 3013 v8::Handle<v8::Uint16Array> u16a = |
| 3007 CreateAndCheck<v8::Uint16Array, 2>(buffer, 2, 511); | 3014 CreateAndCheck<v8::Uint16Array, 2>(buffer, 2, 511); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3292 { | 3299 { |
| 3293 v8::HandleScope scope(isolate); | 3300 v8::HandleScope scope(isolate); |
| 3294 Local<String> empty; | 3301 Local<String> empty; |
| 3295 global.Reset(isolate, empty); | 3302 global.Reset(isolate, empty); |
| 3296 } | 3303 } |
| 3297 CHECK(global.IsEmpty()); | 3304 CHECK(global.IsEmpty()); |
| 3298 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); | 3305 CHECK_EQ(global_handles->global_handles_count(), initial_handle_count - 1); |
| 3299 } | 3306 } |
| 3300 | 3307 |
| 3301 | 3308 |
| 3309 template<class T> |
| 3310 static v8::UniquePersistent<T> PassUnique(v8::UniquePersistent<T> unique) { |
| 3311 return unique.Pass(); |
| 3312 } |
| 3313 |
| 3314 |
| 3315 template<class T> |
| 3316 static v8::UniquePersistent<T> ReturnUnique(v8::Isolate* isolate, |
| 3317 const v8::Persistent<T> & global) { |
| 3318 v8::UniquePersistent<String> unique(isolate, global); |
| 3319 return unique.Pass(); |
| 3320 } |
| 3321 |
| 3322 |
| 3323 THREADED_TEST(UniquePersistent) { |
| 3324 v8::Isolate* isolate = CcTest::isolate(); |
| 3325 v8::Persistent<String> global; |
| 3326 { |
| 3327 v8::HandleScope scope(isolate); |
| 3328 global.Reset(isolate, v8_str("str")); |
| 3329 } |
| 3330 v8::internal::GlobalHandles* global_handles = |
| 3331 reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles(); |
| 3332 int initial_handle_count = global_handles->global_handles_count(); |
| 3333 { |
| 3334 v8::UniquePersistent<String> unique(isolate, global); |
| 3335 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); |
| 3336 // Test assignment via Pass |
| 3337 { |
| 3338 v8::UniquePersistent<String> copy = unique.Pass(); |
| 3339 CHECK(unique.IsEmpty()); |
| 3340 CHECK(copy == global); |
| 3341 CHECK_EQ(initial_handle_count + 1, |
| 3342 global_handles->global_handles_count()); |
| 3343 unique = copy.Pass(); |
| 3344 } |
| 3345 // Test ctor via Pass |
| 3346 { |
| 3347 v8::UniquePersistent<String> copy(unique.Pass()); |
| 3348 CHECK(unique.IsEmpty()); |
| 3349 CHECK(copy == global); |
| 3350 CHECK_EQ(initial_handle_count + 1, |
| 3351 global_handles->global_handles_count()); |
| 3352 unique = copy.Pass(); |
| 3353 } |
| 3354 // Test pass through function call |
| 3355 { |
| 3356 v8::UniquePersistent<String> copy = PassUnique(unique.Pass()); |
| 3357 CHECK(unique.IsEmpty()); |
| 3358 CHECK(copy == global); |
| 3359 CHECK_EQ(initial_handle_count + 1, |
| 3360 global_handles->global_handles_count()); |
| 3361 unique = copy.Pass(); |
| 3362 } |
| 3363 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); |
| 3364 } |
| 3365 // Test pass from function call |
| 3366 { |
| 3367 v8::UniquePersistent<String> unique = ReturnUnique(isolate, global); |
| 3368 CHECK(unique == global); |
| 3369 CHECK_EQ(initial_handle_count + 1, global_handles->global_handles_count()); |
| 3370 } |
| 3371 CHECK_EQ(initial_handle_count, global_handles->global_handles_count()); |
| 3372 global.Reset(); |
| 3373 } |
| 3374 |
| 3375 |
| 3302 THREADED_TEST(GlobalHandleUpcast) { | 3376 THREADED_TEST(GlobalHandleUpcast) { |
| 3303 v8::Isolate* isolate = CcTest::isolate(); | 3377 v8::Isolate* isolate = CcTest::isolate(); |
| 3304 v8::HandleScope scope(isolate); | 3378 v8::HandleScope scope(isolate); |
| 3305 v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str")); | 3379 v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str")); |
| 3306 v8::Persistent<String> global_string(isolate, local); | 3380 v8::Persistent<String> global_string(isolate, local); |
| 3307 v8::Persistent<Value>& global_value = | 3381 v8::Persistent<Value>& global_value = |
| 3308 v8::Persistent<Value>::Cast(global_string); | 3382 v8::Persistent<Value>::Cast(global_string); |
| 3309 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); | 3383 CHECK(v8::Local<v8::Value>::New(isolate, global_value)->IsString()); |
| 3310 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); | 3384 CHECK(global_string == v8::Persistent<String>::Cast(global_value)); |
| 3311 global_string.Reset(); | 3385 global_string.Reset(); |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4067 CHECK(try_catch.HasCaught()); | 4141 CHECK(try_catch.HasCaught()); |
| 4068 String::Utf8Value exception_value(try_catch.Exception()); | 4142 String::Utf8Value exception_value(try_catch.Exception()); |
| 4069 CHECK_EQ("exception", *exception_value); | 4143 CHECK_EQ("exception", *exception_value); |
| 4070 try_catch.Reset(); | 4144 try_catch.Reset(); |
| 4071 } | 4145 } |
| 4072 | 4146 |
| 4073 | 4147 |
| 4074 THREADED_TEST(Array) { | 4148 THREADED_TEST(Array) { |
| 4075 LocalContext context; | 4149 LocalContext context; |
| 4076 v8::HandleScope scope(context->GetIsolate()); | 4150 v8::HandleScope scope(context->GetIsolate()); |
| 4077 Local<v8::Array> array = v8::Array::New(); | 4151 Local<v8::Array> array = v8::Array::New(context->GetIsolate()); |
| 4078 CHECK_EQ(0, array->Length()); | 4152 CHECK_EQ(0, array->Length()); |
| 4079 CHECK(array->Get(0)->IsUndefined()); | 4153 CHECK(array->Get(0)->IsUndefined()); |
| 4080 CHECK(!array->Has(0)); | 4154 CHECK(!array->Has(0)); |
| 4081 CHECK(array->Get(100)->IsUndefined()); | 4155 CHECK(array->Get(100)->IsUndefined()); |
| 4082 CHECK(!array->Has(100)); | 4156 CHECK(!array->Has(100)); |
| 4083 array->Set(2, v8_num(7)); | 4157 array->Set(2, v8_num(7)); |
| 4084 CHECK_EQ(3, array->Length()); | 4158 CHECK_EQ(3, array->Length()); |
| 4085 CHECK(!array->Has(0)); | 4159 CHECK(!array->Has(0)); |
| 4086 CHECK(!array->Has(1)); | 4160 CHECK(!array->Has(1)); |
| 4087 CHECK(array->Has(2)); | 4161 CHECK(array->Has(2)); |
| 4088 CHECK_EQ(7, array->Get(2)->Int32Value()); | 4162 CHECK_EQ(7, array->Get(2)->Int32Value()); |
| 4089 Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run(); | 4163 Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run(); |
| 4090 Local<v8::Array> arr = obj.As<v8::Array>(); | 4164 Local<v8::Array> arr = obj.As<v8::Array>(); |
| 4091 CHECK_EQ(3, arr->Length()); | 4165 CHECK_EQ(3, arr->Length()); |
| 4092 CHECK_EQ(1, arr->Get(0)->Int32Value()); | 4166 CHECK_EQ(1, arr->Get(0)->Int32Value()); |
| 4093 CHECK_EQ(2, arr->Get(1)->Int32Value()); | 4167 CHECK_EQ(2, arr->Get(1)->Int32Value()); |
| 4094 CHECK_EQ(3, arr->Get(2)->Int32Value()); | 4168 CHECK_EQ(3, arr->Get(2)->Int32Value()); |
| 4095 array = v8::Array::New(27); | 4169 array = v8::Array::New(context->GetIsolate(), 27); |
| 4096 CHECK_EQ(27, array->Length()); | 4170 CHECK_EQ(27, array->Length()); |
| 4097 array = v8::Array::New(-27); | 4171 array = v8::Array::New(context->GetIsolate(), -27); |
| 4098 CHECK_EQ(0, array->Length()); | 4172 CHECK_EQ(0, array->Length()); |
| 4099 } | 4173 } |
| 4100 | 4174 |
| 4101 | 4175 |
| 4102 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) { | 4176 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 4103 v8::HandleScope scope(args.GetIsolate()); | 4177 v8::HandleScope scope(args.GetIsolate()); |
| 4104 ApiTestFuzzer::Fuzz(); | 4178 ApiTestFuzzer::Fuzz(); |
| 4105 Local<v8::Array> result = v8::Array::New(args.Length()); | 4179 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length()); |
| 4106 for (int i = 0; i < args.Length(); i++) | 4180 for (int i = 0; i < args.Length(); i++) |
| 4107 result->Set(i, args[i]); | 4181 result->Set(i, args[i]); |
| 4108 args.GetReturnValue().Set(scope.Close(result)); | 4182 args.GetReturnValue().Set(scope.Close(result)); |
| 4109 } | 4183 } |
| 4110 | 4184 |
| 4111 | 4185 |
| 4112 THREADED_TEST(Vector) { | 4186 THREADED_TEST(Vector) { |
| 4113 v8::HandleScope scope(CcTest::isolate()); | 4187 v8::HandleScope scope(CcTest::isolate()); |
| 4114 Local<ObjectTemplate> global = ObjectTemplate::New(); | 4188 Local<ObjectTemplate> global = ObjectTemplate::New(); |
| 4115 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); | 4189 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); |
| (...skipping 2499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6615 | 6689 |
| 6616 | 6690 |
| 6617 class NativeFunctionExtension : public Extension { | 6691 class NativeFunctionExtension : public Extension { |
| 6618 public: | 6692 public: |
| 6619 NativeFunctionExtension(const char* name, | 6693 NativeFunctionExtension(const char* name, |
| 6620 const char* source, | 6694 const char* source, |
| 6621 v8::FunctionCallback fun = &Echo) | 6695 v8::FunctionCallback fun = &Echo) |
| 6622 : Extension(name, source), | 6696 : Extension(name, source), |
| 6623 function_(fun) { } | 6697 function_(fun) { } |
| 6624 | 6698 |
| 6625 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 6699 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 6700 v8::Isolate* isolate, |
| 6626 v8::Handle<v8::String> name) { | 6701 v8::Handle<v8::String> name) { |
| 6627 return v8::FunctionTemplate::New(function_); | 6702 return v8::FunctionTemplate::New(function_); |
| 6628 } | 6703 } |
| 6629 | 6704 |
| 6630 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { | 6705 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 6631 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); | 6706 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); |
| 6632 } | 6707 } |
| 6633 private: | 6708 private: |
| 6634 v8::FunctionCallback function_; | 6709 v8::FunctionCallback function_; |
| 6635 }; | 6710 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6736 args.GetReturnValue().SetNull(); | 6811 args.GetReturnValue().SetNull(); |
| 6737 return; | 6812 return; |
| 6738 } | 6813 } |
| 6739 args.GetReturnValue().Set(args.Data()); | 6814 args.GetReturnValue().Set(args.Data()); |
| 6740 } | 6815 } |
| 6741 | 6816 |
| 6742 | 6817 |
| 6743 class FunctionExtension : public Extension { | 6818 class FunctionExtension : public Extension { |
| 6744 public: | 6819 public: |
| 6745 FunctionExtension() : Extension("functiontest", kExtensionTestScript) { } | 6820 FunctionExtension() : Extension("functiontest", kExtensionTestScript) { } |
| 6746 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 6821 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
| 6822 v8::Isolate* isolate, |
| 6747 v8::Handle<String> name); | 6823 v8::Handle<String> name); |
| 6748 }; | 6824 }; |
| 6749 | 6825 |
| 6750 | 6826 |
| 6751 static int lookup_count = 0; | 6827 static int lookup_count = 0; |
| 6752 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunction( | 6828 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate( |
| 6753 v8::Handle<String> name) { | 6829 v8::Isolate* isolate, v8::Handle<String> name) { |
| 6754 lookup_count++; | 6830 lookup_count++; |
| 6755 if (name->Equals(v8_str("A"))) { | 6831 if (name->Equals(v8_str("A"))) { |
| 6756 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(8)); | 6832 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(8)); |
| 6757 } else if (name->Equals(v8_str("B"))) { | 6833 } else if (name->Equals(v8_str("B"))) { |
| 6758 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(7)); | 6834 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(7)); |
| 6759 } else if (name->Equals(v8_str("C"))) { | 6835 } else if (name->Equals(v8_str("C"))) { |
| 6760 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6)); | 6836 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6)); |
| 6761 } else { | 6837 } else { |
| 6762 return v8::Handle<v8::FunctionTemplate>(); | 6838 return v8::Handle<v8::FunctionTemplate>(); |
| 6763 } | 6839 } |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7181 | 7257 |
| 7182 static void IndexedGetK(uint32_t index, | 7258 static void IndexedGetK(uint32_t index, |
| 7183 const v8::PropertyCallbackInfo<v8::Value>& info) { | 7259 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 7184 ApiTestFuzzer::Fuzz(); | 7260 ApiTestFuzzer::Fuzz(); |
| 7185 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); | 7261 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); |
| 7186 } | 7262 } |
| 7187 | 7263 |
| 7188 | 7264 |
| 7189 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 7265 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 7190 ApiTestFuzzer::Fuzz(); | 7266 ApiTestFuzzer::Fuzz(); |
| 7191 v8::Handle<v8::Array> result = v8::Array::New(3); | 7267 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3); |
| 7192 result->Set(v8::Integer::New(0), v8_str("foo")); | 7268 result->Set(v8::Integer::New(0), v8_str("foo")); |
| 7193 result->Set(v8::Integer::New(1), v8_str("bar")); | 7269 result->Set(v8::Integer::New(1), v8_str("bar")); |
| 7194 result->Set(v8::Integer::New(2), v8_str("baz")); | 7270 result->Set(v8::Integer::New(2), v8_str("baz")); |
| 7195 info.GetReturnValue().Set(result); | 7271 info.GetReturnValue().Set(result); |
| 7196 } | 7272 } |
| 7197 | 7273 |
| 7198 | 7274 |
| 7199 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { | 7275 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 7200 ApiTestFuzzer::Fuzz(); | 7276 ApiTestFuzzer::Fuzz(); |
| 7201 v8::Handle<v8::Array> result = v8::Array::New(2); | 7277 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
| 7202 result->Set(v8::Integer::New(0), v8_str("0")); | 7278 result->Set(v8::Integer::New(0), v8_str("0")); |
| 7203 result->Set(v8::Integer::New(1), v8_str("1")); | 7279 result->Set(v8::Integer::New(1), v8_str("1")); |
| 7204 info.GetReturnValue().Set(result); | 7280 info.GetReturnValue().Set(result); |
| 7205 } | 7281 } |
| 7206 | 7282 |
| 7207 | 7283 |
| 7208 THREADED_TEST(Enumerators) { | 7284 THREADED_TEST(Enumerators) { |
| 7209 v8::HandleScope scope(CcTest::isolate()); | 7285 v8::HandleScope scope(CcTest::isolate()); |
| 7210 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 7286 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 7211 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); | 7287 obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum); |
| (...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9013 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); | 9089 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); |
| 9014 CHECK(value->IsTrue()); | 9090 CHECK(value->IsTrue()); |
| 9015 | 9091 |
| 9016 context1->Exit(); | 9092 context1->Exit(); |
| 9017 context0->Exit(); | 9093 context0->Exit(); |
| 9018 } | 9094 } |
| 9019 | 9095 |
| 9020 | 9096 |
| 9021 static void IndexedPropertyEnumerator( | 9097 static void IndexedPropertyEnumerator( |
| 9022 const v8::PropertyCallbackInfo<v8::Array>& info) { | 9098 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 9023 v8::Handle<v8::Array> result = v8::Array::New(2); | 9099 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
| 9024 result->Set(0, v8::Integer::New(7)); | 9100 result->Set(0, v8::Integer::New(7)); |
| 9025 result->Set(1, v8::Object::New()); | 9101 result->Set(1, v8::Object::New()); |
| 9026 info.GetReturnValue().Set(result); | 9102 info.GetReturnValue().Set(result); |
| 9027 } | 9103 } |
| 9028 | 9104 |
| 9029 | 9105 |
| 9030 static void NamedPropertyEnumerator( | 9106 static void NamedPropertyEnumerator( |
| 9031 const v8::PropertyCallbackInfo<v8::Array>& info) { | 9107 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 9032 v8::Handle<v8::Array> result = v8::Array::New(2); | 9108 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); |
| 9033 result->Set(0, v8_str("x")); | 9109 result->Set(0, v8_str("x")); |
| 9034 result->Set(1, v8::Object::New()); | 9110 result->Set(1, v8::Object::New()); |
| 9035 info.GetReturnValue().Set(result); | 9111 info.GetReturnValue().Set(result); |
| 9036 } | 9112 } |
| 9037 | 9113 |
| 9038 | 9114 |
| 9039 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { | 9115 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
| 9040 v8::HandleScope handle_scope(CcTest::isolate()); | 9116 v8::HandleScope handle_scope(CcTest::isolate()); |
| 9041 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); | 9117 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 9042 | 9118 |
| (...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11520 // This should move the stub | 11596 // This should move the stub |
| 11521 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed | 11597 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed |
| 11522 } | 11598 } |
| 11523 } | 11599 } |
| 11524 | 11600 |
| 11525 | 11601 |
| 11526 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { | 11602 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { |
| 11527 LocalContext context; | 11603 LocalContext context; |
| 11528 v8::HandleScope scope(context->GetIsolate()); | 11604 v8::HandleScope scope(context->GetIsolate()); |
| 11529 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 11605 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
| 11530 nativeobject_templ->Set("callback", | 11606 nativeobject_templ->Set(context->GetIsolate(), "callback", |
| 11531 v8::FunctionTemplate::New(DirectApiCallback)); | 11607 v8::FunctionTemplate::New(DirectApiCallback)); |
| 11532 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); | 11608 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); |
| 11533 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); | 11609 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); |
| 11534 // call the api function multiple times to ensure direct call stub creation. | 11610 // call the api function multiple times to ensure direct call stub creation. |
| 11535 CompileRun( | 11611 CompileRun( |
| 11536 "function f() {" | 11612 "function f() {" |
| 11537 " for (var i = 1; i <= 30; i++) {" | 11613 " for (var i = 1; i <= 30; i++) {" |
| 11538 " nativeobject.callback();" | 11614 " nativeobject.callback();" |
| 11539 " }" | 11615 " }" |
| 11540 "}" | 11616 "}" |
| 11541 "f();"); | 11617 "f();"); |
| 11542 } | 11618 } |
| 11543 | 11619 |
| 11544 | 11620 |
| 11545 void ThrowingDirectApiCallback( | 11621 void ThrowingDirectApiCallback( |
| 11546 const v8::FunctionCallbackInfo<v8::Value>& args) { | 11622 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 11547 args.GetIsolate()->ThrowException(v8_str("g")); | 11623 args.GetIsolate()->ThrowException(v8_str("g")); |
| 11548 } | 11624 } |
| 11549 | 11625 |
| 11550 | 11626 |
| 11551 THREADED_TEST(CallICFastApi_DirectCall_Throw) { | 11627 THREADED_TEST(CallICFastApi_DirectCall_Throw) { |
| 11552 LocalContext context; | 11628 LocalContext context; |
| 11553 v8::HandleScope scope(context->GetIsolate()); | 11629 v8::HandleScope scope(context->GetIsolate()); |
| 11554 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 11630 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
| 11555 nativeobject_templ->Set("callback", | 11631 nativeobject_templ->Set(context->GetIsolate(), "callback", |
| 11556 v8::FunctionTemplate::New(ThrowingDirectApiCallback)); | 11632 v8::FunctionTemplate::New(ThrowingDirectApiCallback)); |
| 11557 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); | 11633 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); |
| 11558 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); | 11634 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); |
| 11559 // call the api function multiple times to ensure direct call stub creation. | 11635 // call the api function multiple times to ensure direct call stub creation. |
| 11560 v8::Handle<Value> result = CompileRun( | 11636 v8::Handle<Value> result = CompileRun( |
| 11561 "var result = '';" | 11637 "var result = '';" |
| 11562 "function f() {" | 11638 "function f() {" |
| 11563 " for (var i = 1; i <= 5; i++) {" | 11639 " for (var i = 1; i <= 5; i++) {" |
| 11564 " try { nativeobject.callback(); } catch (e) { result += e; }" | 11640 " try { nativeobject.callback(); } catch (e) { result += e; }" |
| 11565 " }" | 11641 " }" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11657 "}"); | 11733 "}"); |
| 11658 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11734 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11659 CHECK_EQ(100, interceptor_call_count); | 11735 CHECK_EQ(100, interceptor_call_count); |
| 11660 } | 11736 } |
| 11661 | 11737 |
| 11662 | 11738 |
| 11663 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { | 11739 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { |
| 11664 int interceptor_call_count = 0; | 11740 int interceptor_call_count = 0; |
| 11665 v8::HandleScope scope(CcTest::isolate()); | 11741 v8::HandleScope scope(CcTest::isolate()); |
| 11666 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11742 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11667 v8::Handle<v8::FunctionTemplate> method_templ = | 11743 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11668 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11744 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11669 v8_str("method_data"), | 11745 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11670 v8::Signature::New(fun_templ)); | |
| 11671 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11746 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11672 proto_templ->Set(v8_str("method"), method_templ); | 11747 proto_templ->Set(v8_str("method"), method_templ); |
| 11673 fun_templ->SetHiddenPrototype(true); | 11748 fun_templ->SetHiddenPrototype(true); |
| 11674 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11749 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11675 templ->SetNamedPropertyHandler( | 11750 templ->SetNamedPropertyHandler( |
| 11676 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11751 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11677 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11752 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11678 LocalContext context; | 11753 LocalContext context; |
| 11679 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11754 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11680 GenerateSomeGarbage(); | 11755 GenerateSomeGarbage(); |
| 11681 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11756 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11682 CompileRun( | 11757 CompileRun( |
| 11683 "o.foo = 17;" | 11758 "o.foo = 17;" |
| 11684 "var receiver = {};" | 11759 "var receiver = {};" |
| 11685 "receiver.__proto__ = o;" | 11760 "receiver.__proto__ = o;" |
| 11686 "var result = 0;" | 11761 "var result = 0;" |
| 11687 "for (var i = 0; i < 100; i++) {" | 11762 "for (var i = 0; i < 100; i++) {" |
| 11688 " result = receiver.method(41);" | 11763 " result = receiver.method(41);" |
| 11689 "}"); | 11764 "}"); |
| 11690 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11765 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11691 CHECK_EQ(100, interceptor_call_count); | 11766 CHECK_EQ(100, interceptor_call_count); |
| 11692 } | 11767 } |
| 11693 | 11768 |
| 11694 | 11769 |
| 11695 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { | 11770 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { |
| 11696 int interceptor_call_count = 0; | 11771 int interceptor_call_count = 0; |
| 11697 v8::HandleScope scope(CcTest::isolate()); | 11772 v8::HandleScope scope(CcTest::isolate()); |
| 11698 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11773 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11699 v8::Handle<v8::FunctionTemplate> method_templ = | 11774 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11700 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11775 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11701 v8_str("method_data"), | 11776 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11702 v8::Signature::New(fun_templ)); | |
| 11703 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11777 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11704 proto_templ->Set(v8_str("method"), method_templ); | 11778 proto_templ->Set(v8_str("method"), method_templ); |
| 11705 fun_templ->SetHiddenPrototype(true); | 11779 fun_templ->SetHiddenPrototype(true); |
| 11706 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11780 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11707 templ->SetNamedPropertyHandler( | 11781 templ->SetNamedPropertyHandler( |
| 11708 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11782 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11709 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11783 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11710 LocalContext context; | 11784 LocalContext context; |
| 11711 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11785 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11712 GenerateSomeGarbage(); | 11786 GenerateSomeGarbage(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 11727 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 11801 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11728 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11802 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11729 CHECK_GE(interceptor_call_count, 50); | 11803 CHECK_GE(interceptor_call_count, 50); |
| 11730 } | 11804 } |
| 11731 | 11805 |
| 11732 | 11806 |
| 11733 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { | 11807 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { |
| 11734 int interceptor_call_count = 0; | 11808 int interceptor_call_count = 0; |
| 11735 v8::HandleScope scope(CcTest::isolate()); | 11809 v8::HandleScope scope(CcTest::isolate()); |
| 11736 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11810 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11737 v8::Handle<v8::FunctionTemplate> method_templ = | 11811 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11738 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11812 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11739 v8_str("method_data"), | 11813 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11740 v8::Signature::New(fun_templ)); | |
| 11741 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11814 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11742 proto_templ->Set(v8_str("method"), method_templ); | 11815 proto_templ->Set(v8_str("method"), method_templ); |
| 11743 fun_templ->SetHiddenPrototype(true); | 11816 fun_templ->SetHiddenPrototype(true); |
| 11744 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11817 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11745 templ->SetNamedPropertyHandler( | 11818 templ->SetNamedPropertyHandler( |
| 11746 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11819 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11747 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11820 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11748 LocalContext context; | 11821 LocalContext context; |
| 11749 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11822 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11750 GenerateSomeGarbage(); | 11823 GenerateSomeGarbage(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 11765 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 11838 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11766 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11839 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11767 CHECK_GE(interceptor_call_count, 50); | 11840 CHECK_GE(interceptor_call_count, 50); |
| 11768 } | 11841 } |
| 11769 | 11842 |
| 11770 | 11843 |
| 11771 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { | 11844 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { |
| 11772 int interceptor_call_count = 0; | 11845 int interceptor_call_count = 0; |
| 11773 v8::HandleScope scope(CcTest::isolate()); | 11846 v8::HandleScope scope(CcTest::isolate()); |
| 11774 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11847 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11775 v8::Handle<v8::FunctionTemplate> method_templ = | 11848 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11776 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11849 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11777 v8_str("method_data"), | 11850 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11778 v8::Signature::New(fun_templ)); | |
| 11779 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11851 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11780 proto_templ->Set(v8_str("method"), method_templ); | 11852 proto_templ->Set(v8_str("method"), method_templ); |
| 11781 fun_templ->SetHiddenPrototype(true); | 11853 fun_templ->SetHiddenPrototype(true); |
| 11782 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11854 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11783 templ->SetNamedPropertyHandler( | 11855 templ->SetNamedPropertyHandler( |
| 11784 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11856 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11785 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11857 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11786 LocalContext context; | 11858 LocalContext context; |
| 11787 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11859 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11788 GenerateSomeGarbage(); | 11860 GenerateSomeGarbage(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 11806 try_catch.Exception()->ToString()); | 11878 try_catch.Exception()->ToString()); |
| 11807 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 11879 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11808 CHECK_GE(interceptor_call_count, 50); | 11880 CHECK_GE(interceptor_call_count, 50); |
| 11809 } | 11881 } |
| 11810 | 11882 |
| 11811 | 11883 |
| 11812 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { | 11884 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { |
| 11813 int interceptor_call_count = 0; | 11885 int interceptor_call_count = 0; |
| 11814 v8::HandleScope scope(CcTest::isolate()); | 11886 v8::HandleScope scope(CcTest::isolate()); |
| 11815 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11887 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11816 v8::Handle<v8::FunctionTemplate> method_templ = | 11888 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11817 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11889 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11818 v8_str("method_data"), | 11890 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11819 v8::Signature::New(fun_templ)); | |
| 11820 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11891 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11821 proto_templ->Set(v8_str("method"), method_templ); | 11892 proto_templ->Set(v8_str("method"), method_templ); |
| 11822 fun_templ->SetHiddenPrototype(true); | 11893 fun_templ->SetHiddenPrototype(true); |
| 11823 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); | 11894 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); |
| 11824 templ->SetNamedPropertyHandler( | 11895 templ->SetNamedPropertyHandler( |
| 11825 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, | 11896 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, |
| 11826 v8::External::New(CcTest::isolate(), &interceptor_call_count)); | 11897 v8::External::New(CcTest::isolate(), &interceptor_call_count)); |
| 11827 LocalContext context; | 11898 LocalContext context; |
| 11828 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11899 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11829 GenerateSomeGarbage(); | 11900 GenerateSomeGarbage(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11871 " result = o.method(41);" | 11942 " result = o.method(41);" |
| 11872 "}"); | 11943 "}"); |
| 11873 | 11944 |
| 11874 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11945 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11875 } | 11946 } |
| 11876 | 11947 |
| 11877 | 11948 |
| 11878 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) { | 11949 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) { |
| 11879 v8::HandleScope scope(CcTest::isolate()); | 11950 v8::HandleScope scope(CcTest::isolate()); |
| 11880 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11951 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11881 v8::Handle<v8::FunctionTemplate> method_templ = | 11952 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11882 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11953 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11883 v8_str("method_data"), | 11954 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11884 v8::Signature::New(fun_templ)); | |
| 11885 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11955 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11886 proto_templ->Set(v8_str("method"), method_templ); | 11956 proto_templ->Set(v8_str("method"), method_templ); |
| 11887 fun_templ->SetHiddenPrototype(true); | 11957 fun_templ->SetHiddenPrototype(true); |
| 11888 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 11958 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11889 CHECK(!templ.IsEmpty()); | 11959 CHECK(!templ.IsEmpty()); |
| 11890 LocalContext context; | 11960 LocalContext context; |
| 11891 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11961 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11892 GenerateSomeGarbage(); | 11962 GenerateSomeGarbage(); |
| 11893 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11963 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11894 CompileRun( | 11964 CompileRun( |
| 11895 "o.foo = 17;" | 11965 "o.foo = 17;" |
| 11896 "var receiver = {};" | 11966 "var receiver = {};" |
| 11897 "receiver.__proto__ = o;" | 11967 "receiver.__proto__ = o;" |
| 11898 "var result = 0;" | 11968 "var result = 0;" |
| 11899 "for (var i = 0; i < 100; i++) {" | 11969 "for (var i = 0; i < 100; i++) {" |
| 11900 " result = receiver.method(41);" | 11970 " result = receiver.method(41);" |
| 11901 "}"); | 11971 "}"); |
| 11902 | 11972 |
| 11903 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); | 11973 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11904 } | 11974 } |
| 11905 | 11975 |
| 11906 | 11976 |
| 11907 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) { | 11977 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) { |
| 11908 v8::HandleScope scope(CcTest::isolate()); | 11978 v8::HandleScope scope(CcTest::isolate()); |
| 11909 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 11979 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11910 v8::Handle<v8::FunctionTemplate> method_templ = | 11980 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11911 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 11981 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11912 v8_str("method_data"), | 11982 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11913 v8::Signature::New(fun_templ)); | |
| 11914 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 11983 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11915 proto_templ->Set(v8_str("method"), method_templ); | 11984 proto_templ->Set(v8_str("method"), method_templ); |
| 11916 fun_templ->SetHiddenPrototype(true); | 11985 fun_templ->SetHiddenPrototype(true); |
| 11917 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 11986 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11918 CHECK(!templ.IsEmpty()); | 11987 CHECK(!templ.IsEmpty()); |
| 11919 LocalContext context; | 11988 LocalContext context; |
| 11920 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 11989 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11921 GenerateSomeGarbage(); | 11990 GenerateSomeGarbage(); |
| 11922 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 11991 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11923 CompileRun( | 11992 CompileRun( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 11934 " }" | 12003 " }" |
| 11935 "}"); | 12004 "}"); |
| 11936 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); | 12005 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); |
| 11937 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12006 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11938 } | 12007 } |
| 11939 | 12008 |
| 11940 | 12009 |
| 11941 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) { | 12010 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) { |
| 11942 v8::HandleScope scope(CcTest::isolate()); | 12011 v8::HandleScope scope(CcTest::isolate()); |
| 11943 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12012 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11944 v8::Handle<v8::FunctionTemplate> method_templ = | 12013 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11945 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 12014 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11946 v8_str("method_data"), | 12015 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11947 v8::Signature::New(fun_templ)); | |
| 11948 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12016 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11949 proto_templ->Set(v8_str("method"), method_templ); | 12017 proto_templ->Set(v8_str("method"), method_templ); |
| 11950 fun_templ->SetHiddenPrototype(true); | 12018 fun_templ->SetHiddenPrototype(true); |
| 11951 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 12019 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11952 CHECK(!templ.IsEmpty()); | 12020 CHECK(!templ.IsEmpty()); |
| 11953 LocalContext context; | 12021 LocalContext context; |
| 11954 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12022 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11955 GenerateSomeGarbage(); | 12023 GenerateSomeGarbage(); |
| 11956 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12024 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11957 v8::TryCatch try_catch; | 12025 v8::TryCatch try_catch; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 11971 CHECK(try_catch.HasCaught()); | 12039 CHECK(try_catch.HasCaught()); |
| 11972 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), | 12040 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), |
| 11973 try_catch.Exception()->ToString()); | 12041 try_catch.Exception()->ToString()); |
| 11974 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 12042 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
| 11975 } | 12043 } |
| 11976 | 12044 |
| 11977 | 12045 |
| 11978 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { | 12046 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { |
| 11979 v8::HandleScope scope(CcTest::isolate()); | 12047 v8::HandleScope scope(CcTest::isolate()); |
| 11980 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 12048 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
| 11981 v8::Handle<v8::FunctionTemplate> method_templ = | 12049 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New( |
| 11982 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, | 12050 FastApiCallback_SimpleSignature, v8_str("method_data"), |
| 11983 v8_str("method_data"), | 12051 v8::Signature::New(CcTest::isolate(), fun_templ)); |
| 11984 v8::Signature::New(fun_templ)); | |
| 11985 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); | 12052 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); |
| 11986 proto_templ->Set(v8_str("method"), method_templ); | 12053 proto_templ->Set(v8_str("method"), method_templ); |
| 11987 fun_templ->SetHiddenPrototype(true); | 12054 fun_templ->SetHiddenPrototype(true); |
| 11988 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); | 12055 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); |
| 11989 CHECK(!templ.IsEmpty()); | 12056 CHECK(!templ.IsEmpty()); |
| 11990 LocalContext context; | 12057 LocalContext context; |
| 11991 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); | 12058 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); |
| 11992 GenerateSomeGarbage(); | 12059 GenerateSomeGarbage(); |
| 11993 context->Global()->Set(v8_str("o"), fun->NewInstance()); | 12060 context->Global()->Set(v8_str("o"), fun->NewInstance()); |
| 11994 v8::TryCatch try_catch; | 12061 v8::TryCatch try_catch; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12293 } | 12360 } |
| 12294 | 12361 |
| 12295 | 12362 |
| 12296 // Test that we ignore null interceptors. | 12363 // Test that we ignore null interceptors. |
| 12297 THREADED_TEST(NullNamedInterceptor) { | 12364 THREADED_TEST(NullNamedInterceptor) { |
| 12298 v8::HandleScope scope(CcTest::isolate()); | 12365 v8::HandleScope scope(CcTest::isolate()); |
| 12299 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 12366 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 12300 templ->SetNamedPropertyHandler( | 12367 templ->SetNamedPropertyHandler( |
| 12301 static_cast<v8::NamedPropertyGetterCallback>(0)); | 12368 static_cast<v8::NamedPropertyGetterCallback>(0)); |
| 12302 LocalContext context; | 12369 LocalContext context; |
| 12303 templ->Set("x", v8_num(42)); | 12370 templ->Set(CcTest::isolate(), "x", v8_num(42)); |
| 12304 v8::Handle<v8::Object> obj = templ->NewInstance(); | 12371 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 12305 context->Global()->Set(v8_str("obj"), obj); | 12372 context->Global()->Set(v8_str("obj"), obj); |
| 12306 v8::Handle<Value> value = CompileRun("obj.x"); | 12373 v8::Handle<Value> value = CompileRun("obj.x"); |
| 12307 CHECK(value->IsInt32()); | 12374 CHECK(value->IsInt32()); |
| 12308 CHECK_EQ(42, value->Int32Value()); | 12375 CHECK_EQ(42, value->Int32Value()); |
| 12309 } | 12376 } |
| 12310 | 12377 |
| 12311 | 12378 |
| 12312 // Test that we ignore null interceptors. | 12379 // Test that we ignore null interceptors. |
| 12313 THREADED_TEST(NullIndexedInterceptor) { | 12380 THREADED_TEST(NullIndexedInterceptor) { |
| 12314 v8::HandleScope scope(CcTest::isolate()); | 12381 v8::HandleScope scope(CcTest::isolate()); |
| 12315 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); | 12382 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); |
| 12316 templ->SetIndexedPropertyHandler( | 12383 templ->SetIndexedPropertyHandler( |
| 12317 static_cast<v8::IndexedPropertyGetterCallback>(0)); | 12384 static_cast<v8::IndexedPropertyGetterCallback>(0)); |
| 12318 LocalContext context; | 12385 LocalContext context; |
| 12319 templ->Set("42", v8_num(42)); | 12386 templ->Set(CcTest::isolate(), "42", v8_num(42)); |
| 12320 v8::Handle<v8::Object> obj = templ->NewInstance(); | 12387 v8::Handle<v8::Object> obj = templ->NewInstance(); |
| 12321 context->Global()->Set(v8_str("obj"), obj); | 12388 context->Global()->Set(v8_str("obj"), obj); |
| 12322 v8::Handle<Value> value = CompileRun("obj[42]"); | 12389 v8::Handle<Value> value = CompileRun("obj[42]"); |
| 12323 CHECK(value->IsInt32()); | 12390 CHECK(value->IsInt32()); |
| 12324 CHECK_EQ(42, value->Int32Value()); | 12391 CHECK_EQ(42, value->Int32Value()); |
| 12325 } | 12392 } |
| 12326 | 12393 |
| 12327 | 12394 |
| 12328 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { | 12395 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { |
| 12329 v8::HandleScope scope(CcTest::isolate()); | 12396 v8::HandleScope scope(CcTest::isolate()); |
| (...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13907 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); | 13974 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); |
| 13908 CHECK(value->IsString()); | 13975 CHECK(value->IsString()); |
| 13909 v8::String::Utf8Value name(value); | 13976 v8::String::Utf8Value name(value); |
| 13910 CHECK_EQ("asdf", *name); | 13977 CHECK_EQ("asdf", *name); |
| 13911 } | 13978 } |
| 13912 | 13979 |
| 13913 | 13980 |
| 13914 THREADED_TEST(DateAccess) { | 13981 THREADED_TEST(DateAccess) { |
| 13915 LocalContext context; | 13982 LocalContext context; |
| 13916 v8::HandleScope scope(context->GetIsolate()); | 13983 v8::HandleScope scope(context->GetIsolate()); |
| 13917 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); | 13984 v8::Handle<v8::Value> date = |
| 13985 v8::Date::New(context->GetIsolate(), 1224744689038.0); |
| 13918 CHECK(date->IsDate()); | 13986 CHECK(date->IsDate()); |
| 13919 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); | 13987 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); |
| 13920 } | 13988 } |
| 13921 | 13989 |
| 13922 | 13990 |
| 13923 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) { | 13991 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) { |
| 13924 v8::Handle<v8::Object> obj = val.As<v8::Object>(); | 13992 v8::Handle<v8::Object> obj = val.As<v8::Object>(); |
| 13925 v8::Handle<v8::Array> props = obj->GetPropertyNames(); | 13993 v8::Handle<v8::Array> props = obj->GetPropertyNames(); |
| 13926 CHECK_EQ(elmc, props->Length()); | 13994 CHECK_EQ(elmc, props->Length()); |
| 13927 for (int i = 0; i < elmc; i++) { | 13995 for (int i = 0; i < elmc; i++) { |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14414 v8::Isolate* isolate = CcTest::isolate(); | 14482 v8::Isolate* isolate = CcTest::isolate(); |
| 14415 v8::HandleScope scope(isolate); | 14483 v8::HandleScope scope(isolate); |
| 14416 | 14484 |
| 14417 const char* cstring = "function foo(a) { return a+1; }"; | 14485 const char* cstring = "function foo(a) { return a+1; }"; |
| 14418 | 14486 |
| 14419 v8::ScriptData* sd_from_cstring = | 14487 v8::ScriptData* sd_from_cstring = |
| 14420 v8::ScriptData::PreCompile(isolate, cstring, i::StrLength(cstring)); | 14488 v8::ScriptData::PreCompile(isolate, cstring, i::StrLength(cstring)); |
| 14421 | 14489 |
| 14422 TestAsciiResource* resource = new TestAsciiResource(cstring); | 14490 TestAsciiResource* resource = new TestAsciiResource(cstring); |
| 14423 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile( | 14491 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile( |
| 14424 v8::String::NewExternal(resource)); | 14492 v8::String::NewExternal(isolate, resource)); |
| 14425 | 14493 |
| 14426 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile( | 14494 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile( |
| 14427 v8::String::NewFromUtf8(isolate, cstring)); | 14495 v8::String::NewFromUtf8(isolate, cstring)); |
| 14428 | 14496 |
| 14429 CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length()); | 14497 CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length()); |
| 14430 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), | 14498 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), |
| 14431 sd_from_external_string->Data(), | 14499 sd_from_external_string->Data(), |
| 14432 sd_from_cstring->Length())); | 14500 sd_from_cstring->Length())); |
| 14433 | 14501 |
| 14434 CHECK_EQ(sd_from_cstring->Length(), sd_from_string->Length()); | 14502 CHECK_EQ(sd_from_cstring->Length(), sd_from_string->Length()); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14662 "--0.5", // This mainly testes PushBack in the Scanner. | 14730 "--0.5", // This mainly testes PushBack in the Scanner. |
| 14663 NULL | 14731 NULL |
| 14664 }; | 14732 }; |
| 14665 | 14733 |
| 14666 // Compile the sources as external two byte strings. | 14734 // Compile the sources as external two byte strings. |
| 14667 for (int i = 0; ascii_sources[i] != NULL; i++) { | 14735 for (int i = 0; ascii_sources[i] != NULL; i++) { |
| 14668 uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]); | 14736 uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]); |
| 14669 UC16VectorResource uc16_resource( | 14737 UC16VectorResource uc16_resource( |
| 14670 i::Vector<const uint16_t>(two_byte_string, | 14738 i::Vector<const uint16_t>(two_byte_string, |
| 14671 i::StrLength(ascii_sources[i]))); | 14739 i::StrLength(ascii_sources[i]))); |
| 14672 v8::Local<v8::String> source = v8::String::NewExternal(&uc16_resource); | 14740 v8::Local<v8::String> source = |
| 14741 v8::String::NewExternal(context->GetIsolate(), &uc16_resource); |
| 14673 v8::Script::Compile(source); | 14742 v8::Script::Compile(source); |
| 14674 i::DeleteArray(two_byte_string); | 14743 i::DeleteArray(two_byte_string); |
| 14675 } | 14744 } |
| 14676 } | 14745 } |
| 14677 | 14746 |
| 14678 | 14747 |
| 14679 #ifndef V8_INTERPRETED_REGEXP | 14748 #ifndef V8_INTERPRETED_REGEXP |
| 14680 | 14749 |
| 14681 struct RegExpInterruptionData { | 14750 struct RegExpInterruptionData { |
| 14682 int loop_count; | 14751 int loop_count; |
| (...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16301 void TypedArrayTestHelper(v8::ExternalArrayType array_type, | 16370 void TypedArrayTestHelper(v8::ExternalArrayType array_type, |
| 16302 int64_t low, int64_t high) { | 16371 int64_t low, int64_t high) { |
| 16303 const int kElementCount = 50; | 16372 const int kElementCount = 50; |
| 16304 | 16373 |
| 16305 i::ScopedVector<ElementType> backing_store(kElementCount+2); | 16374 i::ScopedVector<ElementType> backing_store(kElementCount+2); |
| 16306 | 16375 |
| 16307 LocalContext env; | 16376 LocalContext env; |
| 16308 v8::Isolate* isolate = env->GetIsolate(); | 16377 v8::Isolate* isolate = env->GetIsolate(); |
| 16309 v8::HandleScope handle_scope(isolate); | 16378 v8::HandleScope handle_scope(isolate); |
| 16310 | 16379 |
| 16311 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New( | 16380 Local<v8::ArrayBuffer> ab = |
| 16312 backing_store.start(), (kElementCount+2)*sizeof(ElementType)); | 16381 v8::ArrayBuffer::New(isolate, backing_store.start(), |
| 16382 (kElementCount + 2) * sizeof(ElementType)); |
| 16313 Local<TypedArray> ta = | 16383 Local<TypedArray> ta = |
| 16314 TypedArray::New(ab, 2*sizeof(ElementType), kElementCount); | 16384 TypedArray::New(ab, 2*sizeof(ElementType), kElementCount); |
| 16315 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta); | 16385 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta); |
| 16316 CHECK_EQ(kElementCount, static_cast<int>(ta->Length())); | 16386 CHECK_EQ(kElementCount, static_cast<int>(ta->Length())); |
| 16317 CHECK_EQ(2*sizeof(ElementType), static_cast<int>(ta->ByteOffset())); | 16387 CHECK_EQ(2*sizeof(ElementType), static_cast<int>(ta->ByteOffset())); |
| 16318 CHECK_EQ(kElementCount*sizeof(ElementType), | 16388 CHECK_EQ(kElementCount*sizeof(ElementType), |
| 16319 static_cast<int>(ta->ByteLength())); | 16389 static_cast<int>(ta->ByteLength())); |
| 16320 CHECK_EQ(ab, ta->Buffer()); | 16390 CHECK_EQ(ab, ta->Buffer()); |
| 16321 | 16391 |
| 16322 ElementType* data = backing_store.start() + 2; | 16392 ElementType* data = backing_store.start() + 2; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16387 | 16457 |
| 16388 THREADED_TEST(DataView) { | 16458 THREADED_TEST(DataView) { |
| 16389 const int kSize = 50; | 16459 const int kSize = 50; |
| 16390 | 16460 |
| 16391 i::ScopedVector<uint8_t> backing_store(kSize+2); | 16461 i::ScopedVector<uint8_t> backing_store(kSize+2); |
| 16392 | 16462 |
| 16393 LocalContext env; | 16463 LocalContext env; |
| 16394 v8::Isolate* isolate = env->GetIsolate(); | 16464 v8::Isolate* isolate = env->GetIsolate(); |
| 16395 v8::HandleScope handle_scope(isolate); | 16465 v8::HandleScope handle_scope(isolate); |
| 16396 | 16466 |
| 16397 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New( | 16467 Local<v8::ArrayBuffer> ab = |
| 16398 backing_store.start(), 2 + kSize); | 16468 v8::ArrayBuffer::New(isolate, backing_store.start(), 2 + kSize); |
| 16399 Local<v8::DataView> dv = | 16469 Local<v8::DataView> dv = |
| 16400 v8::DataView::New(ab, 2, kSize); | 16470 v8::DataView::New(ab, 2, kSize); |
| 16401 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv); | 16471 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv); |
| 16402 CHECK_EQ(2, static_cast<int>(dv->ByteOffset())); | 16472 CHECK_EQ(2, static_cast<int>(dv->ByteOffset())); |
| 16403 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength())); | 16473 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength())); |
| 16404 CHECK_EQ(ab, dv->Buffer()); | 16474 CHECK_EQ(ab, dv->Buffer()); |
| 16405 } | 16475 } |
| 16406 | 16476 |
| 16407 | 16477 |
| 16408 #define IS_ARRAY_BUFFER_VIEW_TEST(View) \ | 16478 #define IS_ARRAY_BUFFER_VIEW_TEST(View) \ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16495 void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) { | 16565 void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16496 v8::HandleScope scope(args.GetIsolate()); | 16566 v8::HandleScope scope(args.GetIsolate()); |
| 16497 const char* origin = "capture-stack-trace-test"; | 16567 const char* origin = "capture-stack-trace-test"; |
| 16498 const int kOverviewTest = 1; | 16568 const int kOverviewTest = 1; |
| 16499 const int kDetailedTest = 2; | 16569 const int kDetailedTest = 2; |
| 16500 | 16570 |
| 16501 ASSERT(args.Length() == 1); | 16571 ASSERT(args.Length() == 1); |
| 16502 | 16572 |
| 16503 int testGroup = args[0]->Int32Value(); | 16573 int testGroup = args[0]->Int32Value(); |
| 16504 if (testGroup == kOverviewTest) { | 16574 if (testGroup == kOverviewTest) { |
| 16505 v8::Handle<v8::StackTrace> stackTrace = | 16575 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
| 16506 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kOverview); | 16576 args.GetIsolate(), 10, v8::StackTrace::kOverview); |
| 16507 CHECK_EQ(4, stackTrace->GetFrameCount()); | 16577 CHECK_EQ(4, stackTrace->GetFrameCount()); |
| 16508 checkStackFrame(origin, "bar", 2, 10, false, false, | 16578 checkStackFrame(origin, "bar", 2, 10, false, false, |
| 16509 stackTrace->GetFrame(0)); | 16579 stackTrace->GetFrame(0)); |
| 16510 checkStackFrame(origin, "foo", 6, 3, false, false, | 16580 checkStackFrame(origin, "foo", 6, 3, false, false, |
| 16511 stackTrace->GetFrame(1)); | 16581 stackTrace->GetFrame(1)); |
| 16512 // This is the source string inside the eval which has the call to foo. | 16582 // This is the source string inside the eval which has the call to foo. |
| 16513 checkStackFrame(NULL, "", 1, 5, false, false, | 16583 checkStackFrame(NULL, "", 1, 5, false, false, |
| 16514 stackTrace->GetFrame(2)); | 16584 stackTrace->GetFrame(2)); |
| 16515 // The last frame is an anonymous function which has the initial eval call. | 16585 // The last frame is an anonymous function which has the initial eval call. |
| 16516 checkStackFrame(origin, "", 8, 7, false, false, | 16586 checkStackFrame(origin, "", 8, 7, false, false, |
| 16517 stackTrace->GetFrame(3)); | 16587 stackTrace->GetFrame(3)); |
| 16518 | 16588 |
| 16519 CHECK(stackTrace->AsArray()->IsArray()); | 16589 CHECK(stackTrace->AsArray()->IsArray()); |
| 16520 } else if (testGroup == kDetailedTest) { | 16590 } else if (testGroup == kDetailedTest) { |
| 16521 v8::Handle<v8::StackTrace> stackTrace = | 16591 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
| 16522 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16592 args.GetIsolate(), 10, v8::StackTrace::kDetailed); |
| 16523 CHECK_EQ(4, stackTrace->GetFrameCount()); | 16593 CHECK_EQ(4, stackTrace->GetFrameCount()); |
| 16524 checkStackFrame(origin, "bat", 4, 22, false, false, | 16594 checkStackFrame(origin, "bat", 4, 22, false, false, |
| 16525 stackTrace->GetFrame(0)); | 16595 stackTrace->GetFrame(0)); |
| 16526 checkStackFrame(origin, "baz", 8, 3, false, true, | 16596 checkStackFrame(origin, "baz", 8, 3, false, true, |
| 16527 stackTrace->GetFrame(1)); | 16597 stackTrace->GetFrame(1)); |
| 16528 #ifdef ENABLE_DEBUGGER_SUPPORT | 16598 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 16529 bool is_eval = true; | 16599 bool is_eval = true; |
| 16530 #else // ENABLE_DEBUGGER_SUPPORT | 16600 #else // ENABLE_DEBUGGER_SUPPORT |
| 16531 bool is_eval = false; | 16601 bool is_eval = false; |
| 16532 #endif // ENABLE_DEBUGGER_SUPPORT | 16602 #endif // ENABLE_DEBUGGER_SUPPORT |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16778 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); | 16848 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
| 16779 CompileRun(source); | 16849 CompileRun(source); |
| 16780 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); | 16850 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); |
| 16781 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler); | 16851 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler); |
| 16782 } | 16852 } |
| 16783 | 16853 |
| 16784 | 16854 |
| 16785 void AnalyzeStackOfEvalWithSourceURL( | 16855 void AnalyzeStackOfEvalWithSourceURL( |
| 16786 const v8::FunctionCallbackInfo<v8::Value>& args) { | 16856 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16787 v8::HandleScope scope(args.GetIsolate()); | 16857 v8::HandleScope scope(args.GetIsolate()); |
| 16788 v8::Handle<v8::StackTrace> stackTrace = | 16858 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
| 16789 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16859 args.GetIsolate(), 10, v8::StackTrace::kDetailed); |
| 16790 CHECK_EQ(5, stackTrace->GetFrameCount()); | 16860 CHECK_EQ(5, stackTrace->GetFrameCount()); |
| 16791 v8::Handle<v8::String> url = v8_str("eval_url"); | 16861 v8::Handle<v8::String> url = v8_str("eval_url"); |
| 16792 for (int i = 0; i < 3; i++) { | 16862 for (int i = 0; i < 3; i++) { |
| 16793 v8::Handle<v8::String> name = | 16863 v8::Handle<v8::String> name = |
| 16794 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16864 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16795 CHECK(!name.IsEmpty()); | 16865 CHECK(!name.IsEmpty()); |
| 16796 CHECK_EQ(url, name); | 16866 CHECK_EQ(url, name); |
| 16797 } | 16867 } |
| 16798 } | 16868 } |
| 16799 | 16869 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 16824 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); | 16894 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); |
| 16825 CHECK(CompileRun(code.start())->IsUndefined()); | 16895 CHECK(CompileRun(code.start())->IsUndefined()); |
| 16826 } | 16896 } |
| 16827 | 16897 |
| 16828 | 16898 |
| 16829 static int scriptIdInStack[2]; | 16899 static int scriptIdInStack[2]; |
| 16830 | 16900 |
| 16831 void AnalyzeScriptIdInStack( | 16901 void AnalyzeScriptIdInStack( |
| 16832 const v8::FunctionCallbackInfo<v8::Value>& args) { | 16902 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16833 v8::HandleScope scope(args.GetIsolate()); | 16903 v8::HandleScope scope(args.GetIsolate()); |
| 16834 v8::Handle<v8::StackTrace> stackTrace = | 16904 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
| 16835 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kScriptId); | 16905 args.GetIsolate(), 10, v8::StackTrace::kScriptId); |
| 16836 CHECK_EQ(2, stackTrace->GetFrameCount()); | 16906 CHECK_EQ(2, stackTrace->GetFrameCount()); |
| 16837 for (int i = 0; i < 2; i++) { | 16907 for (int i = 0; i < 2; i++) { |
| 16838 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); | 16908 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); |
| 16839 } | 16909 } |
| 16840 } | 16910 } |
| 16841 | 16911 |
| 16842 | 16912 |
| 16843 TEST(ScriptIdInStackTrace) { | 16913 TEST(ScriptIdInStackTrace) { |
| 16844 v8::HandleScope scope(CcTest::isolate()); | 16914 v8::HandleScope scope(CcTest::isolate()); |
| 16845 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 16915 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 16860 for (int i = 0; i < 2; i++) { | 16930 for (int i = 0; i < 2; i++) { |
| 16861 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); | 16931 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); |
| 16862 CHECK_EQ(scriptIdInStack[i], script->GetId()); | 16932 CHECK_EQ(scriptIdInStack[i], script->GetId()); |
| 16863 } | 16933 } |
| 16864 } | 16934 } |
| 16865 | 16935 |
| 16866 | 16936 |
| 16867 void AnalyzeStackOfInlineScriptWithSourceURL( | 16937 void AnalyzeStackOfInlineScriptWithSourceURL( |
| 16868 const v8::FunctionCallbackInfo<v8::Value>& args) { | 16938 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16869 v8::HandleScope scope(args.GetIsolate()); | 16939 v8::HandleScope scope(args.GetIsolate()); |
| 16870 v8::Handle<v8::StackTrace> stackTrace = | 16940 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
| 16871 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16941 args.GetIsolate(), 10, v8::StackTrace::kDetailed); |
| 16872 CHECK_EQ(4, stackTrace->GetFrameCount()); | 16942 CHECK_EQ(4, stackTrace->GetFrameCount()); |
| 16873 v8::Handle<v8::String> url = v8_str("url"); | 16943 v8::Handle<v8::String> url = v8_str("url"); |
| 16874 for (int i = 0; i < 3; i++) { | 16944 for (int i = 0; i < 3; i++) { |
| 16875 v8::Handle<v8::String> name = | 16945 v8::Handle<v8::String> name = |
| 16876 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16946 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16877 CHECK(!name.IsEmpty()); | 16947 CHECK(!name.IsEmpty()); |
| 16878 CHECK_EQ(url, name); | 16948 CHECK_EQ(url, name); |
| 16879 } | 16949 } |
| 16880 } | 16950 } |
| 16881 | 16951 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 16905 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); | 16975 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); |
| 16906 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); | 16976 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); |
| 16907 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); | 16977 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); |
| 16908 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); | 16978 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); |
| 16909 } | 16979 } |
| 16910 | 16980 |
| 16911 | 16981 |
| 16912 void AnalyzeStackOfDynamicScriptWithSourceURL( | 16982 void AnalyzeStackOfDynamicScriptWithSourceURL( |
| 16913 const v8::FunctionCallbackInfo<v8::Value>& args) { | 16983 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 16914 v8::HandleScope scope(args.GetIsolate()); | 16984 v8::HandleScope scope(args.GetIsolate()); |
| 16915 v8::Handle<v8::StackTrace> stackTrace = | 16985 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( |
| 16916 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16986 args.GetIsolate(), 10, v8::StackTrace::kDetailed); |
| 16917 CHECK_EQ(4, stackTrace->GetFrameCount()); | 16987 CHECK_EQ(4, stackTrace->GetFrameCount()); |
| 16918 v8::Handle<v8::String> url = v8_str("source_url"); | 16988 v8::Handle<v8::String> url = v8_str("source_url"); |
| 16919 for (int i = 0; i < 3; i++) { | 16989 for (int i = 0; i < 3; i++) { |
| 16920 v8::Handle<v8::String> name = | 16990 v8::Handle<v8::String> name = |
| 16921 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16991 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
| 16922 CHECK(!name.IsEmpty()); | 16992 CHECK(!name.IsEmpty()); |
| 16923 CHECK_EQ(url, name); | 16993 CHECK_EQ(url, name); |
| 16924 } | 16994 } |
| 16925 } | 16995 } |
| 16926 | 16996 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17190 }; | 17260 }; |
| 17191 | 17261 |
| 17192 | 17262 |
| 17193 TEST(VisitExternalStrings) { | 17263 TEST(VisitExternalStrings) { |
| 17194 LocalContext env; | 17264 LocalContext env; |
| 17195 v8::HandleScope scope(env->GetIsolate()); | 17265 v8::HandleScope scope(env->GetIsolate()); |
| 17196 const char* string = "Some string"; | 17266 const char* string = "Some string"; |
| 17197 uint16_t* two_byte_string = AsciiToTwoByteString(string); | 17267 uint16_t* two_byte_string = AsciiToTwoByteString(string); |
| 17198 TestResource* resource[4]; | 17268 TestResource* resource[4]; |
| 17199 resource[0] = new TestResource(two_byte_string); | 17269 resource[0] = new TestResource(two_byte_string); |
| 17200 v8::Local<v8::String> string0 = v8::String::NewExternal(resource[0]); | 17270 v8::Local<v8::String> string0 = |
| 17271 v8::String::NewExternal(env->GetIsolate(), resource[0]); |
| 17201 resource[1] = new TestResource(two_byte_string); | 17272 resource[1] = new TestResource(two_byte_string); |
| 17202 v8::Local<v8::String> string1 = v8::String::NewExternal(resource[1]); | 17273 v8::Local<v8::String> string1 = |
| 17274 v8::String::NewExternal(env->GetIsolate(), resource[1]); |
| 17203 | 17275 |
| 17204 // Externalized symbol. | 17276 // Externalized symbol. |
| 17205 resource[2] = new TestResource(two_byte_string); | 17277 resource[2] = new TestResource(two_byte_string); |
| 17206 v8::Local<v8::String> string2 = v8::String::NewFromUtf8( | 17278 v8::Local<v8::String> string2 = v8::String::NewFromUtf8( |
| 17207 env->GetIsolate(), string, v8::String::kInternalizedString); | 17279 env->GetIsolate(), string, v8::String::kInternalizedString); |
| 17208 CHECK(string2->MakeExternal(resource[2])); | 17280 CHECK(string2->MakeExternal(resource[2])); |
| 17209 | 17281 |
| 17210 // Symbolized External. | 17282 // Symbolized External. |
| 17211 resource[3] = new TestResource(AsciiToTwoByteString("Some other string")); | 17283 resource[3] = new TestResource(AsciiToTwoByteString("Some other string")); |
| 17212 v8::Local<v8::String> string3 = v8::String::NewExternal(resource[3]); | 17284 v8::Local<v8::String> string3 = |
| 17285 v8::String::NewExternal(env->GetIsolate(), resource[3]); |
| 17213 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string. | 17286 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string. |
| 17214 // Turn into a symbol. | 17287 // Turn into a symbol. |
| 17215 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3); | 17288 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3); |
| 17216 CHECK(!CcTest::heap()->InternalizeString(*string3_i)->IsFailure()); | 17289 CHECK(!CcTest::heap()->InternalizeString(*string3_i)->IsFailure()); |
| 17217 CHECK(string3_i->IsInternalizedString()); | 17290 CHECK(string3_i->IsInternalizedString()); |
| 17218 | 17291 |
| 17219 // We need to add usages for string* to avoid warnings in GCC 4.7 | 17292 // We need to add usages for string* to avoid warnings in GCC 4.7 |
| 17220 CHECK(string0->IsExternal()); | 17293 CHECK(string0->IsExternal()); |
| 17221 CHECK(string1->IsExternal()); | 17294 CHECK(string1->IsExternal()); |
| 17222 CHECK(string2->IsExternal()); | 17295 CHECK(string2->IsExternal()); |
| 17223 CHECK(string3->IsExternal()); | 17296 CHECK(string3->IsExternal()); |
| 17224 | 17297 |
| 17225 VisitorImpl visitor(resource); | 17298 VisitorImpl visitor(resource); |
| 17226 v8::V8::VisitExternalResources(&visitor); | 17299 v8::V8::VisitExternalResources(&visitor); |
| 17227 visitor.CheckVisitedResources(); | 17300 visitor.CheckVisitedResources(); |
| 17228 } | 17301 } |
| 17229 | 17302 |
| 17230 | 17303 |
| 17231 TEST(ExternalStringCollectedAtTearDown) { | 17304 TEST(ExternalStringCollectedAtTearDown) { |
| 17232 int destroyed = 0; | 17305 int destroyed = 0; |
| 17233 v8::Isolate* isolate = v8::Isolate::New(); | 17306 v8::Isolate* isolate = v8::Isolate::New(); |
| 17234 { v8::Isolate::Scope isolate_scope(isolate); | 17307 { v8::Isolate::Scope isolate_scope(isolate); |
| 17235 v8::HandleScope handle_scope(isolate); | 17308 v8::HandleScope handle_scope(isolate); |
| 17236 const char* s = "One string to test them all, one string to find them."; | 17309 const char* s = "One string to test them all, one string to find them."; |
| 17237 TestAsciiResource* inscription = | 17310 TestAsciiResource* inscription = |
| 17238 new TestAsciiResource(i::StrDup(s), &destroyed); | 17311 new TestAsciiResource(i::StrDup(s), &destroyed); |
| 17239 v8::Local<v8::String> ring = v8::String::NewExternal(inscription); | 17312 v8::Local<v8::String> ring = v8::String::NewExternal(isolate, inscription); |
| 17240 // Ring is still alive. Orcs are roaming freely across our lands. | 17313 // Ring is still alive. Orcs are roaming freely across our lands. |
| 17241 CHECK_EQ(0, destroyed); | 17314 CHECK_EQ(0, destroyed); |
| 17242 USE(ring); | 17315 USE(ring); |
| 17243 } | 17316 } |
| 17244 | 17317 |
| 17245 isolate->Dispose(); | 17318 isolate->Dispose(); |
| 17246 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice. | 17319 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice. |
| 17247 CHECK_EQ(1, destroyed); | 17320 CHECK_EQ(1, destroyed); |
| 17248 } | 17321 } |
| 17249 | 17322 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17335 // Most significant fraction bit for quiet nan is set to 0 | 17408 // Most significant fraction bit for quiet nan is set to 0 |
| 17336 // on MIPS architecture. Allowed by IEEE-754. | 17409 // on MIPS architecture. Allowed by IEEE-754. |
| 17337 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); | 17410 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); |
| 17338 #else | 17411 #else |
| 17339 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 17412 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
| 17340 #endif | 17413 #endif |
| 17341 } | 17414 } |
| 17342 | 17415 |
| 17343 // Check that Date::New preserves non-NaNs in the date range and | 17416 // Check that Date::New preserves non-NaNs in the date range and |
| 17344 // quiets SNaNs. | 17417 // quiets SNaNs. |
| 17345 v8::Handle<v8::Value> date = v8::Date::New(test_value); | 17418 v8::Handle<v8::Value> date = |
| 17419 v8::Date::New(context->GetIsolate(), test_value); |
| 17346 double expected_stored_date = DoubleToDateTime(test_value); | 17420 double expected_stored_date = DoubleToDateTime(test_value); |
| 17347 double stored_date = date->NumberValue(); | 17421 double stored_date = date->NumberValue(); |
| 17348 if (!std::isnan(expected_stored_date)) { | 17422 if (!std::isnan(expected_stored_date)) { |
| 17349 CHECK_EQ(expected_stored_date, stored_date); | 17423 CHECK_EQ(expected_stored_date, stored_date); |
| 17350 } else { | 17424 } else { |
| 17351 uint64_t stored_bits = DoubleToBits(stored_date); | 17425 uint64_t stored_bits = DoubleToBits(stored_date); |
| 17352 // Check if quiet nan (bits 51..62 all set). | 17426 // Check if quiet nan (bits 51..62 all set). |
| 17353 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) | 17427 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) |
| 17354 // Most significant fraction bit for quiet nan is set to 0 | 17428 // Most significant fraction bit for quiet nan is set to 0 |
| 17355 // on MIPS architecture. Allowed by IEEE-754. | 17429 // on MIPS architecture. Allowed by IEEE-754. |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18185 i::SmartArrayPointer<uintptr_t> | 18259 i::SmartArrayPointer<uintptr_t> |
| 18186 aligned_contents(new uintptr_t[aligned_length]); | 18260 aligned_contents(new uintptr_t[aligned_length]); |
| 18187 uint16_t* string_contents = reinterpret_cast<uint16_t*>(*aligned_contents); | 18261 uint16_t* string_contents = reinterpret_cast<uint16_t*>(*aligned_contents); |
| 18188 // Set to contain only one byte. | 18262 // Set to contain only one byte. |
| 18189 for (int i = 0; i < length-1; i++) { | 18263 for (int i = 0; i < length-1; i++) { |
| 18190 string_contents[i] = 0x41; | 18264 string_contents[i] = 0x41; |
| 18191 } | 18265 } |
| 18192 string_contents[length-1] = 0; | 18266 string_contents[length-1] = 0; |
| 18193 // Simple case. | 18267 // Simple case. |
| 18194 Handle<String> string; | 18268 Handle<String> string; |
| 18195 string = String::NewExternal(new TestResource(string_contents)); | 18269 string = String::NewExternal(isolate, new TestResource(string_contents)); |
| 18196 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); | 18270 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); |
| 18197 // Counter example. | 18271 // Counter example. |
| 18198 string = String::NewFromTwoByte(isolate, string_contents); | 18272 string = String::NewFromTwoByte(isolate, string_contents); |
| 18199 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); | 18273 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); |
| 18200 // Test left right and balanced cons strings. | 18274 // Test left right and balanced cons strings. |
| 18201 Handle<String> base = String::NewFromUtf8(isolate, "a"); | 18275 Handle<String> base = String::NewFromUtf8(isolate, "a"); |
| 18202 Handle<String> left = base; | 18276 Handle<String> left = base; |
| 18203 Handle<String> right = base; | 18277 Handle<String> right = base; |
| 18204 for (int i = 0; i < 1000; i++) { | 18278 for (int i = 0; i < 1000; i++) { |
| 18205 left = String::Concat(base, left); | 18279 left = String::Concat(base, left); |
| 18206 right = String::Concat(right, base); | 18280 right = String::Concat(right, base); |
| 18207 } | 18281 } |
| 18208 Handle<String> balanced = String::Concat(left, base); | 18282 Handle<String> balanced = String::Concat(left, base); |
| 18209 balanced = String::Concat(balanced, right); | 18283 balanced = String::Concat(balanced, right); |
| 18210 Handle<String> cons_strings[] = {left, balanced, right}; | 18284 Handle<String> cons_strings[] = {left, balanced, right}; |
| 18211 Handle<String> two_byte = | 18285 Handle<String> two_byte = |
| 18212 String::NewExternal(new TestResource(string_contents)); | 18286 String::NewExternal(isolate, new TestResource(string_contents)); |
| 18213 for (size_t i = 0; i < ARRAY_SIZE(cons_strings); i++) { | 18287 for (size_t i = 0; i < ARRAY_SIZE(cons_strings); i++) { |
| 18214 // Base assumptions. | 18288 // Base assumptions. |
| 18215 string = cons_strings[i]; | 18289 string = cons_strings[i]; |
| 18216 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); | 18290 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); |
| 18217 // Test left and right concatentation. | 18291 // Test left and right concatentation. |
| 18218 string = String::Concat(two_byte, cons_strings[i]); | 18292 string = String::Concat(two_byte, cons_strings[i]); |
| 18219 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); | 18293 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); |
| 18220 string = String::Concat(cons_strings[i], two_byte); | 18294 string = String::Concat(cons_strings[i], two_byte); |
| 18221 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); | 18295 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); |
| 18222 } | 18296 } |
| 18223 // Set bits in different positions | 18297 // Set bits in different positions |
| 18224 // for strings of different lengths and alignments. | 18298 // for strings of different lengths and alignments. |
| 18225 for (int alignment = 0; alignment < 7; alignment++) { | 18299 for (int alignment = 0; alignment < 7; alignment++) { |
| 18226 for (int size = 2; alignment + size < length; size *= 2) { | 18300 for (int size = 2; alignment + size < length; size *= 2) { |
| 18227 int zero_offset = size + alignment; | 18301 int zero_offset = size + alignment; |
| 18228 string_contents[zero_offset] = 0; | 18302 string_contents[zero_offset] = 0; |
| 18229 for (int i = 0; i < size; i++) { | 18303 for (int i = 0; i < size; i++) { |
| 18230 int shift = 8 + (i % 7); | 18304 int shift = 8 + (i % 7); |
| 18231 string_contents[alignment + i] = 1 << shift; | 18305 string_contents[alignment + i] = 1 << shift; |
| 18232 string = | 18306 string = String::NewExternal( |
| 18233 String::NewExternal(new TestResource(string_contents + alignment)); | 18307 isolate, new TestResource(string_contents + alignment)); |
| 18234 CHECK_EQ(size, string->Length()); | 18308 CHECK_EQ(size, string->Length()); |
| 18235 CHECK(!string->ContainsOnlyOneByte()); | 18309 CHECK(!string->ContainsOnlyOneByte()); |
| 18236 string_contents[alignment + i] = 0x41; | 18310 string_contents[alignment + i] = 0x41; |
| 18237 } | 18311 } |
| 18238 string_contents[zero_offset] = 0x41; | 18312 string_contents[zero_offset] = 0x41; |
| 18239 } | 18313 } |
| 18240 } | 18314 } |
| 18241 } | 18315 } |
| 18242 | 18316 |
| 18243 | 18317 |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19005 } | 19079 } |
| 19006 | 19080 |
| 19007 | 19081 |
| 19008 static void Getter(v8::Local<v8::String> property, | 19082 static void Getter(v8::Local<v8::String> property, |
| 19009 const v8::PropertyCallbackInfo<v8::Value>& info ) { | 19083 const v8::PropertyCallbackInfo<v8::Value>& info ) { |
| 19010 info.GetReturnValue().Set(v8_str("42!")); | 19084 info.GetReturnValue().Set(v8_str("42!")); |
| 19011 } | 19085 } |
| 19012 | 19086 |
| 19013 | 19087 |
| 19014 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { | 19088 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 19015 v8::Handle<v8::Array> result = v8::Array::New(); | 19089 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate()); |
| 19016 result->Set(0, v8_str("universalAnswer")); | 19090 result->Set(0, v8_str("universalAnswer")); |
| 19017 info.GetReturnValue().Set(result); | 19091 info.GetReturnValue().Set(result); |
| 19018 } | 19092 } |
| 19019 | 19093 |
| 19020 | 19094 |
| 19021 TEST(NamedEnumeratorAndForIn) { | 19095 TEST(NamedEnumeratorAndForIn) { |
| 19022 LocalContext context; | 19096 LocalContext context; |
| 19023 v8::HandleScope handle_scope(context->GetIsolate()); | 19097 v8::HandleScope handle_scope(context->GetIsolate()); |
| 19024 v8::Context::Scope context_scope(context.local()); | 19098 v8::Context::Scope context_scope(context.local()); |
| 19025 | 19099 |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20016 LocalContext context; | 20090 LocalContext context; |
| 20017 v8::HandleScope scope(context->GetIsolate()); | 20091 v8::HandleScope scope(context->GetIsolate()); |
| 20018 | 20092 |
| 20019 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 20093 Local<FunctionTemplate> templ = FunctionTemplate::New(); |
| 20020 Local<ObjectTemplate> inst = templ->InstanceTemplate(); | 20094 Local<ObjectTemplate> inst = templ->InstanceTemplate(); |
| 20021 inst->SetAccessor(v8_str("foo"), | 20095 inst->SetAccessor(v8_str("foo"), |
| 20022 InstanceCheckedGetter, InstanceCheckedSetter, | 20096 InstanceCheckedGetter, InstanceCheckedSetter, |
| 20023 Handle<Value>(), | 20097 Handle<Value>(), |
| 20024 v8::DEFAULT, | 20098 v8::DEFAULT, |
| 20025 v8::None, | 20099 v8::None, |
| 20026 v8::AccessorSignature::New(templ)); | 20100 v8::AccessorSignature::New(context->GetIsolate(), templ)); |
| 20027 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 20101 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 20028 | 20102 |
| 20029 printf("Testing positive ...\n"); | 20103 printf("Testing positive ...\n"); |
| 20030 CompileRun("var obj = new f();"); | 20104 CompileRun("var obj = new f();"); |
| 20031 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20105 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20032 CheckInstanceCheckedAccessors(true); | 20106 CheckInstanceCheckedAccessors(true); |
| 20033 | 20107 |
| 20034 printf("Testing negative ...\n"); | 20108 printf("Testing negative ...\n"); |
| 20035 CompileRun("var obj = {};" | 20109 CompileRun("var obj = {};" |
| 20036 "obj.__proto__ = new f();"); | 20110 "obj.__proto__ = new f();"); |
| 20037 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20111 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20038 CheckInstanceCheckedAccessors(false); | 20112 CheckInstanceCheckedAccessors(false); |
| 20039 } | 20113 } |
| 20040 | 20114 |
| 20041 | 20115 |
| 20042 THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) { | 20116 THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) { |
| 20043 v8::internal::FLAG_allow_natives_syntax = true; | 20117 v8::internal::FLAG_allow_natives_syntax = true; |
| 20044 LocalContext context; | 20118 LocalContext context; |
| 20045 v8::HandleScope scope(context->GetIsolate()); | 20119 v8::HandleScope scope(context->GetIsolate()); |
| 20046 | 20120 |
| 20047 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 20121 Local<FunctionTemplate> templ = FunctionTemplate::New(); |
| 20048 Local<ObjectTemplate> inst = templ->InstanceTemplate(); | 20122 Local<ObjectTemplate> inst = templ->InstanceTemplate(); |
| 20049 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); | 20123 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); |
| 20050 inst->SetAccessor(v8_str("foo"), | 20124 inst->SetAccessor(v8_str("foo"), |
| 20051 InstanceCheckedGetter, InstanceCheckedSetter, | 20125 InstanceCheckedGetter, InstanceCheckedSetter, |
| 20052 Handle<Value>(), | 20126 Handle<Value>(), |
| 20053 v8::DEFAULT, | 20127 v8::DEFAULT, |
| 20054 v8::None, | 20128 v8::None, |
| 20055 v8::AccessorSignature::New(templ)); | 20129 v8::AccessorSignature::New(context->GetIsolate(), templ)); |
| 20056 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 20130 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 20057 | 20131 |
| 20058 printf("Testing positive ...\n"); | 20132 printf("Testing positive ...\n"); |
| 20059 CompileRun("var obj = new f();"); | 20133 CompileRun("var obj = new f();"); |
| 20060 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20134 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20061 CheckInstanceCheckedAccessors(true); | 20135 CheckInstanceCheckedAccessors(true); |
| 20062 | 20136 |
| 20063 printf("Testing negative ...\n"); | 20137 printf("Testing negative ...\n"); |
| 20064 CompileRun("var obj = {};" | 20138 CompileRun("var obj = {};" |
| 20065 "obj.__proto__ = new f();"); | 20139 "obj.__proto__ = new f();"); |
| 20066 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20140 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20067 CheckInstanceCheckedAccessors(false); | 20141 CheckInstanceCheckedAccessors(false); |
| 20068 } | 20142 } |
| 20069 | 20143 |
| 20070 | 20144 |
| 20071 THREADED_TEST(InstanceCheckOnPrototypeAccessor) { | 20145 THREADED_TEST(InstanceCheckOnPrototypeAccessor) { |
| 20072 v8::internal::FLAG_allow_natives_syntax = true; | 20146 v8::internal::FLAG_allow_natives_syntax = true; |
| 20073 LocalContext context; | 20147 LocalContext context; |
| 20074 v8::HandleScope scope(context->GetIsolate()); | 20148 v8::HandleScope scope(context->GetIsolate()); |
| 20075 | 20149 |
| 20076 Local<FunctionTemplate> templ = FunctionTemplate::New(); | 20150 Local<FunctionTemplate> templ = FunctionTemplate::New(); |
| 20077 Local<ObjectTemplate> proto = templ->PrototypeTemplate(); | 20151 Local<ObjectTemplate> proto = templ->PrototypeTemplate(); |
| 20078 proto->SetAccessor(v8_str("foo"), | 20152 proto->SetAccessor(v8_str("foo"), |
| 20079 InstanceCheckedGetter, InstanceCheckedSetter, | 20153 InstanceCheckedGetter, InstanceCheckedSetter, |
| 20080 Handle<Value>(), | 20154 Handle<Value>(), |
| 20081 v8::DEFAULT, | 20155 v8::DEFAULT, |
| 20082 v8::None, | 20156 v8::None, |
| 20083 v8::AccessorSignature::New(templ)); | 20157 v8::AccessorSignature::New(context->GetIsolate(), templ)); |
| 20084 context->Global()->Set(v8_str("f"), templ->GetFunction()); | 20158 context->Global()->Set(v8_str("f"), templ->GetFunction()); |
| 20085 | 20159 |
| 20086 printf("Testing positive ...\n"); | 20160 printf("Testing positive ...\n"); |
| 20087 CompileRun("var obj = new f();"); | 20161 CompileRun("var obj = new f();"); |
| 20088 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); | 20162 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); |
| 20089 CheckInstanceCheckedAccessors(true); | 20163 CheckInstanceCheckedAccessors(true); |
| 20090 | 20164 |
| 20091 printf("Testing negative ...\n"); | 20165 printf("Testing negative ...\n"); |
| 20092 CompileRun("var obj = {};" | 20166 CompileRun("var obj = {};" |
| 20093 "obj.__proto__ = new f();"); | 20167 "obj.__proto__ = new f();"); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20492 // failed access check callback will be called on each access. | 20566 // failed access check callback will be called on each access. |
| 20493 LocalContext context1(NULL, global_template); | 20567 LocalContext context1(NULL, global_template); |
| 20494 context1->Global()->Set(v8_str("other"), global0); | 20568 context1->Global()->Set(v8_str("other"), global0); |
| 20495 | 20569 |
| 20496 ExpectString("JSON.stringify(other)", "{}"); | 20570 ExpectString("JSON.stringify(other)", "{}"); |
| 20497 ExpectString("JSON.stringify({ 'a' : other, 'b' : ['c'] })", | 20571 ExpectString("JSON.stringify({ 'a' : other, 'b' : ['c'] })", |
| 20498 "{\"a\":{},\"b\":[\"c\"]}"); | 20572 "{\"a\":{},\"b\":[\"c\"]}"); |
| 20499 ExpectString("JSON.stringify([other, 'b', 'c'])", | 20573 ExpectString("JSON.stringify([other, 'b', 'c'])", |
| 20500 "[{},\"b\",\"c\"]"); | 20574 "[{},\"b\",\"c\"]"); |
| 20501 | 20575 |
| 20502 v8::Handle<v8::Array> array = v8::Array::New(2); | 20576 v8::Handle<v8::Array> array = v8::Array::New(CcTest::isolate(), 2); |
| 20503 array->Set(0, v8_str("a")); | 20577 array->Set(0, v8_str("a")); |
| 20504 array->Set(1, v8_str("b")); | 20578 array->Set(1, v8_str("b")); |
| 20505 context1->Global()->Set(v8_str("array"), array); | 20579 context1->Global()->Set(v8_str("array"), array); |
| 20506 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]"); | 20580 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]"); |
| 20507 array->TurnOnAccessCheck(); | 20581 array->TurnOnAccessCheck(); |
| 20508 ExpectString("JSON.stringify(array)", "[]"); | 20582 ExpectString("JSON.stringify(array)", "[]"); |
| 20509 ExpectString("JSON.stringify([array])", "[[]]"); | 20583 ExpectString("JSON.stringify([array])", "[[]]"); |
| 20510 ExpectString("JSON.stringify({'a' : array})", "{\"a\":[]}"); | 20584 ExpectString("JSON.stringify({'a' : array})", "{\"a\":[]}"); |
| 20511 } | 20585 } |
| 20512 } | 20586 } |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20780 } | 20854 } |
| 20781 for (int i = 0; i < runs; i++) { | 20855 for (int i = 0; i < runs; i++) { |
| 20782 Local<String> expected; | 20856 Local<String> expected; |
| 20783 if (i != 0) { | 20857 if (i != 0) { |
| 20784 CHECK_EQ(v8_str("escape value"), values[i]); | 20858 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20785 } else { | 20859 } else { |
| 20786 CHECK(values[i].IsEmpty()); | 20860 CHECK(values[i].IsEmpty()); |
| 20787 } | 20861 } |
| 20788 } | 20862 } |
| 20789 } | 20863 } |
| OLD | NEW |