Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: test/cctest/test-api.cc

Issue 91503002: Mark deprecated APIs with relatively little use as deprecated (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-assembler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4134 CHECK(try_catch.HasCaught()); 4141 CHECK(try_catch.HasCaught());
4135 String::Utf8Value exception_value(try_catch.Exception()); 4142 String::Utf8Value exception_value(try_catch.Exception());
4136 CHECK_EQ("exception", *exception_value); 4143 CHECK_EQ("exception", *exception_value);
4137 try_catch.Reset(); 4144 try_catch.Reset();
4138 } 4145 }
4139 4146
4140 4147
4141 THREADED_TEST(Array) { 4148 THREADED_TEST(Array) {
4142 LocalContext context; 4149 LocalContext context;
4143 v8::HandleScope scope(context->GetIsolate()); 4150 v8::HandleScope scope(context->GetIsolate());
4144 Local<v8::Array> array = v8::Array::New(); 4151 Local<v8::Array> array = v8::Array::New(context->GetIsolate());
4145 CHECK_EQ(0, array->Length()); 4152 CHECK_EQ(0, array->Length());
4146 CHECK(array->Get(0)->IsUndefined()); 4153 CHECK(array->Get(0)->IsUndefined());
4147 CHECK(!array->Has(0)); 4154 CHECK(!array->Has(0));
4148 CHECK(array->Get(100)->IsUndefined()); 4155 CHECK(array->Get(100)->IsUndefined());
4149 CHECK(!array->Has(100)); 4156 CHECK(!array->Has(100));
4150 array->Set(2, v8_num(7)); 4157 array->Set(2, v8_num(7));
4151 CHECK_EQ(3, array->Length()); 4158 CHECK_EQ(3, array->Length());
4152 CHECK(!array->Has(0)); 4159 CHECK(!array->Has(0));
4153 CHECK(!array->Has(1)); 4160 CHECK(!array->Has(1));
4154 CHECK(array->Has(2)); 4161 CHECK(array->Has(2));
4155 CHECK_EQ(7, array->Get(2)->Int32Value()); 4162 CHECK_EQ(7, array->Get(2)->Int32Value());
4156 Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run(); 4163 Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run();
4157 Local<v8::Array> arr = obj.As<v8::Array>(); 4164 Local<v8::Array> arr = obj.As<v8::Array>();
4158 CHECK_EQ(3, arr->Length()); 4165 CHECK_EQ(3, arr->Length());
4159 CHECK_EQ(1, arr->Get(0)->Int32Value()); 4166 CHECK_EQ(1, arr->Get(0)->Int32Value());
4160 CHECK_EQ(2, arr->Get(1)->Int32Value()); 4167 CHECK_EQ(2, arr->Get(1)->Int32Value());
4161 CHECK_EQ(3, arr->Get(2)->Int32Value()); 4168 CHECK_EQ(3, arr->Get(2)->Int32Value());
4162 array = v8::Array::New(27); 4169 array = v8::Array::New(context->GetIsolate(), 27);
4163 CHECK_EQ(27, array->Length()); 4170 CHECK_EQ(27, array->Length());
4164 array = v8::Array::New(-27); 4171 array = v8::Array::New(context->GetIsolate(), -27);
4165 CHECK_EQ(0, array->Length()); 4172 CHECK_EQ(0, array->Length());
4166 } 4173 }
4167 4174
4168 4175
4169 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) { 4176 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) {
4170 v8::HandleScope scope(args.GetIsolate()); 4177 v8::HandleScope scope(args.GetIsolate());
4171 ApiTestFuzzer::Fuzz(); 4178 ApiTestFuzzer::Fuzz();
4172 Local<v8::Array> result = v8::Array::New(args.Length()); 4179 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length());
4173 for (int i = 0; i < args.Length(); i++) 4180 for (int i = 0; i < args.Length(); i++)
4174 result->Set(i, args[i]); 4181 result->Set(i, args[i]);
4175 args.GetReturnValue().Set(scope.Close(result)); 4182 args.GetReturnValue().Set(scope.Close(result));
4176 } 4183 }
4177 4184
4178 4185
4179 THREADED_TEST(Vector) { 4186 THREADED_TEST(Vector) {
4180 v8::HandleScope scope(CcTest::isolate()); 4187 v8::HandleScope scope(CcTest::isolate());
4181 Local<ObjectTemplate> global = ObjectTemplate::New(); 4188 Local<ObjectTemplate> global = ObjectTemplate::New();
4182 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
6682 6689
6683 6690
6684 class NativeFunctionExtension : public Extension { 6691 class NativeFunctionExtension : public Extension {
6685 public: 6692 public:
6686 NativeFunctionExtension(const char* name, 6693 NativeFunctionExtension(const char* name,
6687 const char* source, 6694 const char* source,
6688 v8::FunctionCallback fun = &Echo) 6695 v8::FunctionCallback fun = &Echo)
6689 : Extension(name, source), 6696 : Extension(name, source),
6690 function_(fun) { } 6697 function_(fun) { }
6691 6698
6692 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 6699 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
6700 v8::Isolate* isolate,
6693 v8::Handle<v8::String> name) { 6701 v8::Handle<v8::String> name) {
6694 return v8::FunctionTemplate::New(function_); 6702 return v8::FunctionTemplate::New(function_);
6695 } 6703 }
6696 6704
6697 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) { 6705 static void Echo(const v8::FunctionCallbackInfo<v8::Value>& args) {
6698 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]); 6706 if (args.Length() >= 1) args.GetReturnValue().Set(args[0]);
6699 } 6707 }
6700 private: 6708 private:
6701 v8::FunctionCallback function_; 6709 v8::FunctionCallback function_;
6702 }; 6710 };
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6803 args.GetReturnValue().SetNull(); 6811 args.GetReturnValue().SetNull();
6804 return; 6812 return;
6805 } 6813 }
6806 args.GetReturnValue().Set(args.Data()); 6814 args.GetReturnValue().Set(args.Data());
6807 } 6815 }
6808 6816
6809 6817
6810 class FunctionExtension : public Extension { 6818 class FunctionExtension : public Extension {
6811 public: 6819 public:
6812 FunctionExtension() : Extension("functiontest", kExtensionTestScript) { } 6820 FunctionExtension() : Extension("functiontest", kExtensionTestScript) { }
6813 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 6821 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
6822 v8::Isolate* isolate,
6814 v8::Handle<String> name); 6823 v8::Handle<String> name);
6815 }; 6824 };
6816 6825
6817 6826
6818 static int lookup_count = 0; 6827 static int lookup_count = 0;
6819 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunction( 6828 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunctionTemplate(
6820 v8::Handle<String> name) { 6829 v8::Isolate* isolate, v8::Handle<String> name) {
6821 lookup_count++; 6830 lookup_count++;
6822 if (name->Equals(v8_str("A"))) { 6831 if (name->Equals(v8_str("A"))) {
6823 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(8)); 6832 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(8));
6824 } else if (name->Equals(v8_str("B"))) { 6833 } else if (name->Equals(v8_str("B"))) {
6825 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(7)); 6834 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(7));
6826 } else if (name->Equals(v8_str("C"))) { 6835 } else if (name->Equals(v8_str("C"))) {
6827 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6)); 6836 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6));
6828 } else { 6837 } else {
6829 return v8::Handle<v8::FunctionTemplate>(); 6838 return v8::Handle<v8::FunctionTemplate>();
6830 } 6839 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
7248 7257
7249 static void IndexedGetK(uint32_t index, 7258 static void IndexedGetK(uint32_t index,
7250 const v8::PropertyCallbackInfo<v8::Value>& info) { 7259 const v8::PropertyCallbackInfo<v8::Value>& info) {
7251 ApiTestFuzzer::Fuzz(); 7260 ApiTestFuzzer::Fuzz();
7252 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined(); 7261 if (index == 0 || index == 1) info.GetReturnValue().SetUndefined();
7253 } 7262 }
7254 7263
7255 7264
7256 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 7265 static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
7257 ApiTestFuzzer::Fuzz(); 7266 ApiTestFuzzer::Fuzz();
7258 v8::Handle<v8::Array> result = v8::Array::New(3); 7267 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 3);
7259 result->Set(v8::Integer::New(0), v8_str("foo")); 7268 result->Set(v8::Integer::New(0), v8_str("foo"));
7260 result->Set(v8::Integer::New(1), v8_str("bar")); 7269 result->Set(v8::Integer::New(1), v8_str("bar"));
7261 result->Set(v8::Integer::New(2), v8_str("baz")); 7270 result->Set(v8::Integer::New(2), v8_str("baz"));
7262 info.GetReturnValue().Set(result); 7271 info.GetReturnValue().Set(result);
7263 } 7272 }
7264 7273
7265 7274
7266 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) { 7275 static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
7267 ApiTestFuzzer::Fuzz(); 7276 ApiTestFuzzer::Fuzz();
7268 v8::Handle<v8::Array> result = v8::Array::New(2); 7277 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
7269 result->Set(v8::Integer::New(0), v8_str("0")); 7278 result->Set(v8::Integer::New(0), v8_str("0"));
7270 result->Set(v8::Integer::New(1), v8_str("1")); 7279 result->Set(v8::Integer::New(1), v8_str("1"));
7271 info.GetReturnValue().Set(result); 7280 info.GetReturnValue().Set(result);
7272 } 7281 }
7273 7282
7274 7283
7275 THREADED_TEST(Enumerators) { 7284 THREADED_TEST(Enumerators) {
7276 v8::HandleScope scope(CcTest::isolate()); 7285 v8::HandleScope scope(CcTest::isolate());
7277 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 7286 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
7278 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
9080 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); 9089 value = CompileRun("Object.getOwnPropertyNames(object).length == 0");
9081 CHECK(value->IsTrue()); 9090 CHECK(value->IsTrue());
9082 9091
9083 context1->Exit(); 9092 context1->Exit();
9084 context0->Exit(); 9093 context0->Exit();
9085 } 9094 }
9086 9095
9087 9096
9088 static void IndexedPropertyEnumerator( 9097 static void IndexedPropertyEnumerator(
9089 const v8::PropertyCallbackInfo<v8::Array>& info) { 9098 const v8::PropertyCallbackInfo<v8::Array>& info) {
9090 v8::Handle<v8::Array> result = v8::Array::New(2); 9099 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
9091 result->Set(0, v8::Integer::New(7)); 9100 result->Set(0, v8::Integer::New(7));
9092 result->Set(1, v8::Object::New()); 9101 result->Set(1, v8::Object::New());
9093 info.GetReturnValue().Set(result); 9102 info.GetReturnValue().Set(result);
9094 } 9103 }
9095 9104
9096 9105
9097 static void NamedPropertyEnumerator( 9106 static void NamedPropertyEnumerator(
9098 const v8::PropertyCallbackInfo<v8::Array>& info) { 9107 const v8::PropertyCallbackInfo<v8::Array>& info) {
9099 v8::Handle<v8::Array> result = v8::Array::New(2); 9108 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
9100 result->Set(0, v8_str("x")); 9109 result->Set(0, v8_str("x"));
9101 result->Set(1, v8::Object::New()); 9110 result->Set(1, v8::Object::New());
9102 info.GetReturnValue().Set(result); 9111 info.GetReturnValue().Set(result);
9103 } 9112 }
9104 9113
9105 9114
9106 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { 9115 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
9107 v8::HandleScope handle_scope(CcTest::isolate()); 9116 v8::HandleScope handle_scope(CcTest::isolate());
9108 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); 9117 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
9109 9118
(...skipping 2477 matching lines...) Expand 10 before | Expand all | Expand 10 after
11587 // This should move the stub 11596 // This should move the stub
11588 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed 11597 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed
11589 } 11598 }
11590 } 11599 }
11591 11600
11592 11601
11593 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { 11602 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) {
11594 LocalContext context; 11603 LocalContext context;
11595 v8::HandleScope scope(context->GetIsolate()); 11604 v8::HandleScope scope(context->GetIsolate());
11596 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); 11605 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
11597 nativeobject_templ->Set("callback", 11606 nativeobject_templ->Set(context->GetIsolate(), "callback",
11598 v8::FunctionTemplate::New(DirectApiCallback)); 11607 v8::FunctionTemplate::New(DirectApiCallback));
11599 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); 11608 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
11600 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); 11609 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
11601 // 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.
11602 CompileRun( 11611 CompileRun(
11603 "function f() {" 11612 "function f() {"
11604 " for (var i = 1; i <= 30; i++) {" 11613 " for (var i = 1; i <= 30; i++) {"
11605 " nativeobject.callback();" 11614 " nativeobject.callback();"
11606 " }" 11615 " }"
11607 "}" 11616 "}"
11608 "f();"); 11617 "f();");
11609 } 11618 }
11610 11619
11611 11620
11612 void ThrowingDirectApiCallback( 11621 void ThrowingDirectApiCallback(
11613 const v8::FunctionCallbackInfo<v8::Value>& args) { 11622 const v8::FunctionCallbackInfo<v8::Value>& args) {
11614 args.GetIsolate()->ThrowException(v8_str("g")); 11623 args.GetIsolate()->ThrowException(v8_str("g"));
11615 } 11624 }
11616 11625
11617 11626
11618 THREADED_TEST(CallICFastApi_DirectCall_Throw) { 11627 THREADED_TEST(CallICFastApi_DirectCall_Throw) {
11619 LocalContext context; 11628 LocalContext context;
11620 v8::HandleScope scope(context->GetIsolate()); 11629 v8::HandleScope scope(context->GetIsolate());
11621 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); 11630 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
11622 nativeobject_templ->Set("callback", 11631 nativeobject_templ->Set(context->GetIsolate(), "callback",
11623 v8::FunctionTemplate::New(ThrowingDirectApiCallback)); 11632 v8::FunctionTemplate::New(ThrowingDirectApiCallback));
11624 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance(); 11633 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
11625 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj); 11634 context->Global()->Set(v8_str("nativeobject"), nativeobject_obj);
11626 // 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.
11627 v8::Handle<Value> result = CompileRun( 11636 v8::Handle<Value> result = CompileRun(
11628 "var result = '';" 11637 "var result = '';"
11629 "function f() {" 11638 "function f() {"
11630 " for (var i = 1; i <= 5; i++) {" 11639 " for (var i = 1; i <= 5; i++) {"
11631 " try { nativeobject.callback(); } catch (e) { result += e; }" 11640 " try { nativeobject.callback(); } catch (e) { result += e; }"
11632 " }" 11641 " }"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
11724 "}"); 11733 "}");
11725 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 11734 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
11726 CHECK_EQ(100, interceptor_call_count); 11735 CHECK_EQ(100, interceptor_call_count);
11727 } 11736 }
11728 11737
11729 11738
11730 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) { 11739 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature) {
11731 int interceptor_call_count = 0; 11740 int interceptor_call_count = 0;
11732 v8::HandleScope scope(CcTest::isolate()); 11741 v8::HandleScope scope(CcTest::isolate());
11733 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11742 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11734 v8::Handle<v8::FunctionTemplate> method_templ = 11743 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
11735 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11744 FastApiCallback_SimpleSignature, v8_str("method_data"),
11736 v8_str("method_data"), 11745 v8::Signature::New(CcTest::isolate(), fun_templ));
11737 v8::Signature::New(fun_templ));
11738 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11746 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11739 proto_templ->Set(v8_str("method"), method_templ); 11747 proto_templ->Set(v8_str("method"), method_templ);
11740 fun_templ->SetHiddenPrototype(true); 11748 fun_templ->SetHiddenPrototype(true);
11741 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 11749 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
11742 templ->SetNamedPropertyHandler( 11750 templ->SetNamedPropertyHandler(
11743 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, 11751 InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
11744 v8::External::New(CcTest::isolate(), &interceptor_call_count)); 11752 v8::External::New(CcTest::isolate(), &interceptor_call_count));
11745 LocalContext context; 11753 LocalContext context;
11746 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11754 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11747 GenerateSomeGarbage(); 11755 GenerateSomeGarbage();
11748 context->Global()->Set(v8_str("o"), fun->NewInstance()); 11756 context->Global()->Set(v8_str("o"), fun->NewInstance());
11749 CompileRun( 11757 CompileRun(
11750 "o.foo = 17;" 11758 "o.foo = 17;"
11751 "var receiver = {};" 11759 "var receiver = {};"
11752 "receiver.__proto__ = o;" 11760 "receiver.__proto__ = o;"
11753 "var result = 0;" 11761 "var result = 0;"
11754 "for (var i = 0; i < 100; i++) {" 11762 "for (var i = 0; i < 100; i++) {"
11755 " result = receiver.method(41);" 11763 " result = receiver.method(41);"
11756 "}"); 11764 "}");
11757 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 11765 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
11758 CHECK_EQ(100, interceptor_call_count); 11766 CHECK_EQ(100, interceptor_call_count);
11759 } 11767 }
11760 11768
11761 11769
11762 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) { 11770 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
11763 int interceptor_call_count = 0; 11771 int interceptor_call_count = 0;
11764 v8::HandleScope scope(CcTest::isolate()); 11772 v8::HandleScope scope(CcTest::isolate());
11765 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11773 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11766 v8::Handle<v8::FunctionTemplate> method_templ = 11774 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
11767 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11775 FastApiCallback_SimpleSignature, v8_str("method_data"),
11768 v8_str("method_data"), 11776 v8::Signature::New(CcTest::isolate(), fun_templ));
11769 v8::Signature::New(fun_templ));
11770 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11777 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11771 proto_templ->Set(v8_str("method"), method_templ); 11778 proto_templ->Set(v8_str("method"), method_templ);
11772 fun_templ->SetHiddenPrototype(true); 11779 fun_templ->SetHiddenPrototype(true);
11773 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 11780 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
11774 templ->SetNamedPropertyHandler( 11781 templ->SetNamedPropertyHandler(
11775 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, 11782 InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
11776 v8::External::New(CcTest::isolate(), &interceptor_call_count)); 11783 v8::External::New(CcTest::isolate(), &interceptor_call_count));
11777 LocalContext context; 11784 LocalContext context;
11778 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11785 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11779 GenerateSomeGarbage(); 11786 GenerateSomeGarbage();
(...skipping 14 matching lines...) Expand all
11794 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 11801 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
11795 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 11802 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
11796 CHECK_GE(interceptor_call_count, 50); 11803 CHECK_GE(interceptor_call_count, 50);
11797 } 11804 }
11798 11805
11799 11806
11800 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) { 11807 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
11801 int interceptor_call_count = 0; 11808 int interceptor_call_count = 0;
11802 v8::HandleScope scope(CcTest::isolate()); 11809 v8::HandleScope scope(CcTest::isolate());
11803 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11810 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11804 v8::Handle<v8::FunctionTemplate> method_templ = 11811 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
11805 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11812 FastApiCallback_SimpleSignature, v8_str("method_data"),
11806 v8_str("method_data"), 11813 v8::Signature::New(CcTest::isolate(), fun_templ));
11807 v8::Signature::New(fun_templ));
11808 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11814 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11809 proto_templ->Set(v8_str("method"), method_templ); 11815 proto_templ->Set(v8_str("method"), method_templ);
11810 fun_templ->SetHiddenPrototype(true); 11816 fun_templ->SetHiddenPrototype(true);
11811 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 11817 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
11812 templ->SetNamedPropertyHandler( 11818 templ->SetNamedPropertyHandler(
11813 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, 11819 InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
11814 v8::External::New(CcTest::isolate(), &interceptor_call_count)); 11820 v8::External::New(CcTest::isolate(), &interceptor_call_count));
11815 LocalContext context; 11821 LocalContext context;
11816 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11822 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11817 GenerateSomeGarbage(); 11823 GenerateSomeGarbage();
(...skipping 14 matching lines...) Expand all
11832 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 11838 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
11833 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 11839 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
11834 CHECK_GE(interceptor_call_count, 50); 11840 CHECK_GE(interceptor_call_count, 50);
11835 } 11841 }
11836 11842
11837 11843
11838 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) { 11844 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
11839 int interceptor_call_count = 0; 11845 int interceptor_call_count = 0;
11840 v8::HandleScope scope(CcTest::isolate()); 11846 v8::HandleScope scope(CcTest::isolate());
11841 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11847 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11842 v8::Handle<v8::FunctionTemplate> method_templ = 11848 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
11843 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11849 FastApiCallback_SimpleSignature, v8_str("method_data"),
11844 v8_str("method_data"), 11850 v8::Signature::New(CcTest::isolate(), fun_templ));
11845 v8::Signature::New(fun_templ));
11846 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11851 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11847 proto_templ->Set(v8_str("method"), method_templ); 11852 proto_templ->Set(v8_str("method"), method_templ);
11848 fun_templ->SetHiddenPrototype(true); 11853 fun_templ->SetHiddenPrototype(true);
11849 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 11854 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
11850 templ->SetNamedPropertyHandler( 11855 templ->SetNamedPropertyHandler(
11851 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, 11856 InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
11852 v8::External::New(CcTest::isolate(), &interceptor_call_count)); 11857 v8::External::New(CcTest::isolate(), &interceptor_call_count));
11853 LocalContext context; 11858 LocalContext context;
11854 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11859 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11855 GenerateSomeGarbage(); 11860 GenerateSomeGarbage();
(...skipping 17 matching lines...) Expand all
11873 try_catch.Exception()->ToString()); 11878 try_catch.Exception()->ToString());
11874 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 11879 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
11875 CHECK_GE(interceptor_call_count, 50); 11880 CHECK_GE(interceptor_call_count, 50);
11876 } 11881 }
11877 11882
11878 11883
11879 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { 11884 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
11880 int interceptor_call_count = 0; 11885 int interceptor_call_count = 0;
11881 v8::HandleScope scope(CcTest::isolate()); 11886 v8::HandleScope scope(CcTest::isolate());
11882 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11887 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11883 v8::Handle<v8::FunctionTemplate> method_templ = 11888 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
11884 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11889 FastApiCallback_SimpleSignature, v8_str("method_data"),
11885 v8_str("method_data"), 11890 v8::Signature::New(CcTest::isolate(), fun_templ));
11886 v8::Signature::New(fun_templ));
11887 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11891 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11888 proto_templ->Set(v8_str("method"), method_templ); 11892 proto_templ->Set(v8_str("method"), method_templ);
11889 fun_templ->SetHiddenPrototype(true); 11893 fun_templ->SetHiddenPrototype(true);
11890 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate(); 11894 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
11891 templ->SetNamedPropertyHandler( 11895 templ->SetNamedPropertyHandler(
11892 InterceptorCallICFastApi, NULL, NULL, NULL, NULL, 11896 InterceptorCallICFastApi, NULL, NULL, NULL, NULL,
11893 v8::External::New(CcTest::isolate(), &interceptor_call_count)); 11897 v8::External::New(CcTest::isolate(), &interceptor_call_count));
11894 LocalContext context; 11898 LocalContext context;
11895 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11899 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11896 GenerateSomeGarbage(); 11900 GenerateSomeGarbage();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
11938 " result = o.method(41);" 11942 " result = o.method(41);"
11939 "}"); 11943 "}");
11940 11944
11941 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 11945 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
11942 } 11946 }
11943 11947
11944 11948
11945 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) { 11949 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature) {
11946 v8::HandleScope scope(CcTest::isolate()); 11950 v8::HandleScope scope(CcTest::isolate());
11947 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11951 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11948 v8::Handle<v8::FunctionTemplate> method_templ = 11952 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
11949 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11953 FastApiCallback_SimpleSignature, v8_str("method_data"),
11950 v8_str("method_data"), 11954 v8::Signature::New(CcTest::isolate(), fun_templ));
11951 v8::Signature::New(fun_templ));
11952 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11955 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11953 proto_templ->Set(v8_str("method"), method_templ); 11956 proto_templ->Set(v8_str("method"), method_templ);
11954 fun_templ->SetHiddenPrototype(true); 11957 fun_templ->SetHiddenPrototype(true);
11955 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 11958 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
11956 CHECK(!templ.IsEmpty()); 11959 CHECK(!templ.IsEmpty());
11957 LocalContext context; 11960 LocalContext context;
11958 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11961 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11959 GenerateSomeGarbage(); 11962 GenerateSomeGarbage();
11960 context->Global()->Set(v8_str("o"), fun->NewInstance()); 11963 context->Global()->Set(v8_str("o"), fun->NewInstance());
11961 CompileRun( 11964 CompileRun(
11962 "o.foo = 17;" 11965 "o.foo = 17;"
11963 "var receiver = {};" 11966 "var receiver = {};"
11964 "receiver.__proto__ = o;" 11967 "receiver.__proto__ = o;"
11965 "var result = 0;" 11968 "var result = 0;"
11966 "for (var i = 0; i < 100; i++) {" 11969 "for (var i = 0; i < 100; i++) {"
11967 " result = receiver.method(41);" 11970 " result = receiver.method(41);"
11968 "}"); 11971 "}");
11969 11972
11970 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value()); 11973 CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
11971 } 11974 }
11972 11975
11973 11976
11974 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) { 11977 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss1) {
11975 v8::HandleScope scope(CcTest::isolate()); 11978 v8::HandleScope scope(CcTest::isolate());
11976 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 11979 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
11977 v8::Handle<v8::FunctionTemplate> method_templ = 11980 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
11978 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 11981 FastApiCallback_SimpleSignature, v8_str("method_data"),
11979 v8_str("method_data"), 11982 v8::Signature::New(CcTest::isolate(), fun_templ));
11980 v8::Signature::New(fun_templ));
11981 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 11983 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
11982 proto_templ->Set(v8_str("method"), method_templ); 11984 proto_templ->Set(v8_str("method"), method_templ);
11983 fun_templ->SetHiddenPrototype(true); 11985 fun_templ->SetHiddenPrototype(true);
11984 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 11986 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
11985 CHECK(!templ.IsEmpty()); 11987 CHECK(!templ.IsEmpty());
11986 LocalContext context; 11988 LocalContext context;
11987 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 11989 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
11988 GenerateSomeGarbage(); 11990 GenerateSomeGarbage();
11989 context->Global()->Set(v8_str("o"), fun->NewInstance()); 11991 context->Global()->Set(v8_str("o"), fun->NewInstance());
11990 CompileRun( 11992 CompileRun(
(...skipping 10 matching lines...) Expand all
12001 " }" 12003 " }"
12002 "}"); 12004 "}");
12003 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value()); 12005 CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
12004 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 12006 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
12005 } 12007 }
12006 12008
12007 12009
12008 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) { 12010 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_Miss2) {
12009 v8::HandleScope scope(CcTest::isolate()); 12011 v8::HandleScope scope(CcTest::isolate());
12010 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 12012 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
12011 v8::Handle<v8::FunctionTemplate> method_templ = 12013 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12012 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 12014 FastApiCallback_SimpleSignature, v8_str("method_data"),
12013 v8_str("method_data"), 12015 v8::Signature::New(CcTest::isolate(), fun_templ));
12014 v8::Signature::New(fun_templ));
12015 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 12016 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12016 proto_templ->Set(v8_str("method"), method_templ); 12017 proto_templ->Set(v8_str("method"), method_templ);
12017 fun_templ->SetHiddenPrototype(true); 12018 fun_templ->SetHiddenPrototype(true);
12018 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 12019 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
12019 CHECK(!templ.IsEmpty()); 12020 CHECK(!templ.IsEmpty());
12020 LocalContext context; 12021 LocalContext context;
12021 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 12022 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
12022 GenerateSomeGarbage(); 12023 GenerateSomeGarbage();
12023 context->Global()->Set(v8_str("o"), fun->NewInstance()); 12024 context->Global()->Set(v8_str("o"), fun->NewInstance());
12024 v8::TryCatch try_catch; 12025 v8::TryCatch try_catch;
(...skipping 13 matching lines...) Expand all
12038 CHECK(try_catch.HasCaught()); 12039 CHECK(try_catch.HasCaught());
12039 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"), 12040 CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
12040 try_catch.Exception()->ToString()); 12041 try_catch.Exception()->ToString());
12041 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); 12042 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
12042 } 12043 }
12043 12044
12044 12045
12045 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { 12046 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) {
12046 v8::HandleScope scope(CcTest::isolate()); 12047 v8::HandleScope scope(CcTest::isolate());
12047 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); 12048 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
12048 v8::Handle<v8::FunctionTemplate> method_templ = 12049 v8::Handle<v8::FunctionTemplate> method_templ = v8::FunctionTemplate::New(
12049 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature, 12050 FastApiCallback_SimpleSignature, v8_str("method_data"),
12050 v8_str("method_data"), 12051 v8::Signature::New(CcTest::isolate(), fun_templ));
12051 v8::Signature::New(fun_templ));
12052 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate(); 12052 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
12053 proto_templ->Set(v8_str("method"), method_templ); 12053 proto_templ->Set(v8_str("method"), method_templ);
12054 fun_templ->SetHiddenPrototype(true); 12054 fun_templ->SetHiddenPrototype(true);
12055 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate()); 12055 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
12056 CHECK(!templ.IsEmpty()); 12056 CHECK(!templ.IsEmpty());
12057 LocalContext context; 12057 LocalContext context;
12058 v8::Handle<v8::Function> fun = fun_templ->GetFunction(); 12058 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
12059 GenerateSomeGarbage(); 12059 GenerateSomeGarbage();
12060 context->Global()->Set(v8_str("o"), fun->NewInstance()); 12060 context->Global()->Set(v8_str("o"), fun->NewInstance());
12061 v8::TryCatch try_catch; 12061 v8::TryCatch try_catch;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
12360 } 12360 }
12361 12361
12362 12362
12363 // Test that we ignore null interceptors. 12363 // Test that we ignore null interceptors.
12364 THREADED_TEST(NullNamedInterceptor) { 12364 THREADED_TEST(NullNamedInterceptor) {
12365 v8::HandleScope scope(CcTest::isolate()); 12365 v8::HandleScope scope(CcTest::isolate());
12366 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 12366 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
12367 templ->SetNamedPropertyHandler( 12367 templ->SetNamedPropertyHandler(
12368 static_cast<v8::NamedPropertyGetterCallback>(0)); 12368 static_cast<v8::NamedPropertyGetterCallback>(0));
12369 LocalContext context; 12369 LocalContext context;
12370 templ->Set("x", v8_num(42)); 12370 templ->Set(CcTest::isolate(), "x", v8_num(42));
12371 v8::Handle<v8::Object> obj = templ->NewInstance(); 12371 v8::Handle<v8::Object> obj = templ->NewInstance();
12372 context->Global()->Set(v8_str("obj"), obj); 12372 context->Global()->Set(v8_str("obj"), obj);
12373 v8::Handle<Value> value = CompileRun("obj.x"); 12373 v8::Handle<Value> value = CompileRun("obj.x");
12374 CHECK(value->IsInt32()); 12374 CHECK(value->IsInt32());
12375 CHECK_EQ(42, value->Int32Value()); 12375 CHECK_EQ(42, value->Int32Value());
12376 } 12376 }
12377 12377
12378 12378
12379 // Test that we ignore null interceptors. 12379 // Test that we ignore null interceptors.
12380 THREADED_TEST(NullIndexedInterceptor) { 12380 THREADED_TEST(NullIndexedInterceptor) {
12381 v8::HandleScope scope(CcTest::isolate()); 12381 v8::HandleScope scope(CcTest::isolate());
12382 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(); 12382 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
12383 templ->SetIndexedPropertyHandler( 12383 templ->SetIndexedPropertyHandler(
12384 static_cast<v8::IndexedPropertyGetterCallback>(0)); 12384 static_cast<v8::IndexedPropertyGetterCallback>(0));
12385 LocalContext context; 12385 LocalContext context;
12386 templ->Set("42", v8_num(42)); 12386 templ->Set(CcTest::isolate(), "42", v8_num(42));
12387 v8::Handle<v8::Object> obj = templ->NewInstance(); 12387 v8::Handle<v8::Object> obj = templ->NewInstance();
12388 context->Global()->Set(v8_str("obj"), obj); 12388 context->Global()->Set(v8_str("obj"), obj);
12389 v8::Handle<Value> value = CompileRun("obj[42]"); 12389 v8::Handle<Value> value = CompileRun("obj[42]");
12390 CHECK(value->IsInt32()); 12390 CHECK(value->IsInt32());
12391 CHECK_EQ(42, value->Int32Value()); 12391 CHECK_EQ(42, value->Int32Value());
12392 } 12392 }
12393 12393
12394 12394
12395 THREADED_TEST(NamedPropertyHandlerGetterAttributes) { 12395 THREADED_TEST(NamedPropertyHandlerGetterAttributes) {
12396 v8::HandleScope scope(CcTest::isolate()); 12396 v8::HandleScope scope(CcTest::isolate());
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
13974 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); 13974 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name");
13975 CHECK(value->IsString()); 13975 CHECK(value->IsString());
13976 v8::String::Utf8Value name(value); 13976 v8::String::Utf8Value name(value);
13977 CHECK_EQ("asdf", *name); 13977 CHECK_EQ("asdf", *name);
13978 } 13978 }
13979 13979
13980 13980
13981 THREADED_TEST(DateAccess) { 13981 THREADED_TEST(DateAccess) {
13982 LocalContext context; 13982 LocalContext context;
13983 v8::HandleScope scope(context->GetIsolate()); 13983 v8::HandleScope scope(context->GetIsolate());
13984 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0); 13984 v8::Handle<v8::Value> date =
13985 v8::Date::New(context->GetIsolate(), 1224744689038.0);
13985 CHECK(date->IsDate()); 13986 CHECK(date->IsDate());
13986 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf()); 13987 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->ValueOf());
13987 } 13988 }
13988 13989
13989 13990
13990 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[]) {
13991 v8::Handle<v8::Object> obj = val.As<v8::Object>(); 13992 v8::Handle<v8::Object> obj = val.As<v8::Object>();
13992 v8::Handle<v8::Array> props = obj->GetPropertyNames(); 13993 v8::Handle<v8::Array> props = obj->GetPropertyNames();
13993 CHECK_EQ(elmc, props->Length()); 13994 CHECK_EQ(elmc, props->Length());
13994 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
14481 v8::Isolate* isolate = CcTest::isolate(); 14482 v8::Isolate* isolate = CcTest::isolate();
14482 v8::HandleScope scope(isolate); 14483 v8::HandleScope scope(isolate);
14483 14484
14484 const char* cstring = "function foo(a) { return a+1; }"; 14485 const char* cstring = "function foo(a) { return a+1; }";
14485 14486
14486 v8::ScriptData* sd_from_cstring = 14487 v8::ScriptData* sd_from_cstring =
14487 v8::ScriptData::PreCompile(isolate, cstring, i::StrLength(cstring)); 14488 v8::ScriptData::PreCompile(isolate, cstring, i::StrLength(cstring));
14488 14489
14489 TestAsciiResource* resource = new TestAsciiResource(cstring); 14490 TestAsciiResource* resource = new TestAsciiResource(cstring);
14490 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile( 14491 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile(
14491 v8::String::NewExternal(resource)); 14492 v8::String::NewExternal(isolate, resource));
14492 14493
14493 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile( 14494 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile(
14494 v8::String::NewFromUtf8(isolate, cstring)); 14495 v8::String::NewFromUtf8(isolate, cstring));
14495 14496
14496 CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length()); 14497 CHECK_EQ(sd_from_cstring->Length(), sd_from_external_string->Length());
14497 CHECK_EQ(0, memcmp(sd_from_cstring->Data(), 14498 CHECK_EQ(0, memcmp(sd_from_cstring->Data(),
14498 sd_from_external_string->Data(), 14499 sd_from_external_string->Data(),
14499 sd_from_cstring->Length())); 14500 sd_from_cstring->Length()));
14500 14501
14501 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
14729 "--0.5", // This mainly testes PushBack in the Scanner. 14730 "--0.5", // This mainly testes PushBack in the Scanner.
14730 NULL 14731 NULL
14731 }; 14732 };
14732 14733
14733 // Compile the sources as external two byte strings. 14734 // Compile the sources as external two byte strings.
14734 for (int i = 0; ascii_sources[i] != NULL; i++) { 14735 for (int i = 0; ascii_sources[i] != NULL; i++) {
14735 uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]); 14736 uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]);
14736 UC16VectorResource uc16_resource( 14737 UC16VectorResource uc16_resource(
14737 i::Vector<const uint16_t>(two_byte_string, 14738 i::Vector<const uint16_t>(two_byte_string,
14738 i::StrLength(ascii_sources[i]))); 14739 i::StrLength(ascii_sources[i])));
14739 v8::Local<v8::String> source = v8::String::NewExternal(&uc16_resource); 14740 v8::Local<v8::String> source =
14741 v8::String::NewExternal(context->GetIsolate(), &uc16_resource);
14740 v8::Script::Compile(source); 14742 v8::Script::Compile(source);
14741 i::DeleteArray(two_byte_string); 14743 i::DeleteArray(two_byte_string);
14742 } 14744 }
14743 } 14745 }
14744 14746
14745 14747
14746 #ifndef V8_INTERPRETED_REGEXP 14748 #ifndef V8_INTERPRETED_REGEXP
14747 14749
14748 struct RegExpInterruptionData { 14750 struct RegExpInterruptionData {
14749 int loop_count; 14751 int loop_count;
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
16368 void TypedArrayTestHelper(v8::ExternalArrayType array_type, 16370 void TypedArrayTestHelper(v8::ExternalArrayType array_type,
16369 int64_t low, int64_t high) { 16371 int64_t low, int64_t high) {
16370 const int kElementCount = 50; 16372 const int kElementCount = 50;
16371 16373
16372 i::ScopedVector<ElementType> backing_store(kElementCount+2); 16374 i::ScopedVector<ElementType> backing_store(kElementCount+2);
16373 16375
16374 LocalContext env; 16376 LocalContext env;
16375 v8::Isolate* isolate = env->GetIsolate(); 16377 v8::Isolate* isolate = env->GetIsolate();
16376 v8::HandleScope handle_scope(isolate); 16378 v8::HandleScope handle_scope(isolate);
16377 16379
16378 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New( 16380 Local<v8::ArrayBuffer> ab =
16379 backing_store.start(), (kElementCount+2)*sizeof(ElementType)); 16381 v8::ArrayBuffer::New(isolate, backing_store.start(),
16382 (kElementCount + 2) * sizeof(ElementType));
16380 Local<TypedArray> ta = 16383 Local<TypedArray> ta =
16381 TypedArray::New(ab, 2*sizeof(ElementType), kElementCount); 16384 TypedArray::New(ab, 2*sizeof(ElementType), kElementCount);
16382 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta); 16385 CheckInternalFieldsAreZero<v8::ArrayBufferView>(ta);
16383 CHECK_EQ(kElementCount, static_cast<int>(ta->Length())); 16386 CHECK_EQ(kElementCount, static_cast<int>(ta->Length()));
16384 CHECK_EQ(2*sizeof(ElementType), static_cast<int>(ta->ByteOffset())); 16387 CHECK_EQ(2*sizeof(ElementType), static_cast<int>(ta->ByteOffset()));
16385 CHECK_EQ(kElementCount*sizeof(ElementType), 16388 CHECK_EQ(kElementCount*sizeof(ElementType),
16386 static_cast<int>(ta->ByteLength())); 16389 static_cast<int>(ta->ByteLength()));
16387 CHECK_EQ(ab, ta->Buffer()); 16390 CHECK_EQ(ab, ta->Buffer());
16388 16391
16389 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
16454 16457
16455 THREADED_TEST(DataView) { 16458 THREADED_TEST(DataView) {
16456 const int kSize = 50; 16459 const int kSize = 50;
16457 16460
16458 i::ScopedVector<uint8_t> backing_store(kSize+2); 16461 i::ScopedVector<uint8_t> backing_store(kSize+2);
16459 16462
16460 LocalContext env; 16463 LocalContext env;
16461 v8::Isolate* isolate = env->GetIsolate(); 16464 v8::Isolate* isolate = env->GetIsolate();
16462 v8::HandleScope handle_scope(isolate); 16465 v8::HandleScope handle_scope(isolate);
16463 16466
16464 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New( 16467 Local<v8::ArrayBuffer> ab =
16465 backing_store.start(), 2 + kSize); 16468 v8::ArrayBuffer::New(isolate, backing_store.start(), 2 + kSize);
16466 Local<v8::DataView> dv = 16469 Local<v8::DataView> dv =
16467 v8::DataView::New(ab, 2, kSize); 16470 v8::DataView::New(ab, 2, kSize);
16468 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv); 16471 CheckInternalFieldsAreZero<v8::ArrayBufferView>(dv);
16469 CHECK_EQ(2, static_cast<int>(dv->ByteOffset())); 16472 CHECK_EQ(2, static_cast<int>(dv->ByteOffset()));
16470 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength())); 16473 CHECK_EQ(kSize, static_cast<int>(dv->ByteLength()));
16471 CHECK_EQ(ab, dv->Buffer()); 16474 CHECK_EQ(ab, dv->Buffer());
16472 } 16475 }
16473 16476
16474 16477
16475 #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
16562 void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) { 16565 void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
16563 v8::HandleScope scope(args.GetIsolate()); 16566 v8::HandleScope scope(args.GetIsolate());
16564 const char* origin = "capture-stack-trace-test"; 16567 const char* origin = "capture-stack-trace-test";
16565 const int kOverviewTest = 1; 16568 const int kOverviewTest = 1;
16566 const int kDetailedTest = 2; 16569 const int kDetailedTest = 2;
16567 16570
16568 ASSERT(args.Length() == 1); 16571 ASSERT(args.Length() == 1);
16569 16572
16570 int testGroup = args[0]->Int32Value(); 16573 int testGroup = args[0]->Int32Value();
16571 if (testGroup == kOverviewTest) { 16574 if (testGroup == kOverviewTest) {
16572 v8::Handle<v8::StackTrace> stackTrace = 16575 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16573 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kOverview); 16576 args.GetIsolate(), 10, v8::StackTrace::kOverview);
16574 CHECK_EQ(4, stackTrace->GetFrameCount()); 16577 CHECK_EQ(4, stackTrace->GetFrameCount());
16575 checkStackFrame(origin, "bar", 2, 10, false, false, 16578 checkStackFrame(origin, "bar", 2, 10, false, false,
16576 stackTrace->GetFrame(0)); 16579 stackTrace->GetFrame(0));
16577 checkStackFrame(origin, "foo", 6, 3, false, false, 16580 checkStackFrame(origin, "foo", 6, 3, false, false,
16578 stackTrace->GetFrame(1)); 16581 stackTrace->GetFrame(1));
16579 // 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.
16580 checkStackFrame(NULL, "", 1, 5, false, false, 16583 checkStackFrame(NULL, "", 1, 5, false, false,
16581 stackTrace->GetFrame(2)); 16584 stackTrace->GetFrame(2));
16582 // 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.
16583 checkStackFrame(origin, "", 8, 7, false, false, 16586 checkStackFrame(origin, "", 8, 7, false, false,
16584 stackTrace->GetFrame(3)); 16587 stackTrace->GetFrame(3));
16585 16588
16586 CHECK(stackTrace->AsArray()->IsArray()); 16589 CHECK(stackTrace->AsArray()->IsArray());
16587 } else if (testGroup == kDetailedTest) { 16590 } else if (testGroup == kDetailedTest) {
16588 v8::Handle<v8::StackTrace> stackTrace = 16591 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16589 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); 16592 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
16590 CHECK_EQ(4, stackTrace->GetFrameCount()); 16593 CHECK_EQ(4, stackTrace->GetFrameCount());
16591 checkStackFrame(origin, "bat", 4, 22, false, false, 16594 checkStackFrame(origin, "bat", 4, 22, false, false,
16592 stackTrace->GetFrame(0)); 16595 stackTrace->GetFrame(0));
16593 checkStackFrame(origin, "baz", 8, 3, false, true, 16596 checkStackFrame(origin, "baz", 8, 3, false, true,
16594 stackTrace->GetFrame(1)); 16597 stackTrace->GetFrame(1));
16595 #ifdef ENABLE_DEBUGGER_SUPPORT 16598 #ifdef ENABLE_DEBUGGER_SUPPORT
16596 bool is_eval = true; 16599 bool is_eval = true;
16597 #else // ENABLE_DEBUGGER_SUPPORT 16600 #else // ENABLE_DEBUGGER_SUPPORT
16598 bool is_eval = false; 16601 bool is_eval = false;
16599 #endif // ENABLE_DEBUGGER_SUPPORT 16602 #endif // ENABLE_DEBUGGER_SUPPORT
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
16845 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); 16848 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
16846 CompileRun(source); 16849 CompileRun(source);
16847 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); 16850 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
16848 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler); 16851 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler);
16849 } 16852 }
16850 16853
16851 16854
16852 void AnalyzeStackOfEvalWithSourceURL( 16855 void AnalyzeStackOfEvalWithSourceURL(
16853 const v8::FunctionCallbackInfo<v8::Value>& args) { 16856 const v8::FunctionCallbackInfo<v8::Value>& args) {
16854 v8::HandleScope scope(args.GetIsolate()); 16857 v8::HandleScope scope(args.GetIsolate());
16855 v8::Handle<v8::StackTrace> stackTrace = 16858 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16856 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); 16859 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
16857 CHECK_EQ(5, stackTrace->GetFrameCount()); 16860 CHECK_EQ(5, stackTrace->GetFrameCount());
16858 v8::Handle<v8::String> url = v8_str("eval_url"); 16861 v8::Handle<v8::String> url = v8_str("eval_url");
16859 for (int i = 0; i < 3; i++) { 16862 for (int i = 0; i < 3; i++) {
16860 v8::Handle<v8::String> name = 16863 v8::Handle<v8::String> name =
16861 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); 16864 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
16862 CHECK(!name.IsEmpty()); 16865 CHECK(!name.IsEmpty());
16863 CHECK_EQ(url, name); 16866 CHECK_EQ(url, name);
16864 } 16867 }
16865 } 16868 }
16866 16869
(...skipping 24 matching lines...) Expand all
16891 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); 16894 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url");
16892 CHECK(CompileRun(code.start())->IsUndefined()); 16895 CHECK(CompileRun(code.start())->IsUndefined());
16893 } 16896 }
16894 16897
16895 16898
16896 static int scriptIdInStack[2]; 16899 static int scriptIdInStack[2];
16897 16900
16898 void AnalyzeScriptIdInStack( 16901 void AnalyzeScriptIdInStack(
16899 const v8::FunctionCallbackInfo<v8::Value>& args) { 16902 const v8::FunctionCallbackInfo<v8::Value>& args) {
16900 v8::HandleScope scope(args.GetIsolate()); 16903 v8::HandleScope scope(args.GetIsolate());
16901 v8::Handle<v8::StackTrace> stackTrace = 16904 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16902 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kScriptId); 16905 args.GetIsolate(), 10, v8::StackTrace::kScriptId);
16903 CHECK_EQ(2, stackTrace->GetFrameCount()); 16906 CHECK_EQ(2, stackTrace->GetFrameCount());
16904 for (int i = 0; i < 2; i++) { 16907 for (int i = 0; i < 2; i++) {
16905 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); 16908 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId();
16906 } 16909 }
16907 } 16910 }
16908 16911
16909 16912
16910 TEST(ScriptIdInStackTrace) { 16913 TEST(ScriptIdInStackTrace) {
16911 v8::HandleScope scope(CcTest::isolate()); 16914 v8::HandleScope scope(CcTest::isolate());
16912 Local<ObjectTemplate> templ = ObjectTemplate::New(); 16915 Local<ObjectTemplate> templ = ObjectTemplate::New();
(...skipping 14 matching lines...) Expand all
16927 for (int i = 0; i < 2; i++) { 16930 for (int i = 0; i < 2; i++) {
16928 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); 16931 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo);
16929 CHECK_EQ(scriptIdInStack[i], script->GetId()); 16932 CHECK_EQ(scriptIdInStack[i], script->GetId());
16930 } 16933 }
16931 } 16934 }
16932 16935
16933 16936
16934 void AnalyzeStackOfInlineScriptWithSourceURL( 16937 void AnalyzeStackOfInlineScriptWithSourceURL(
16935 const v8::FunctionCallbackInfo<v8::Value>& args) { 16938 const v8::FunctionCallbackInfo<v8::Value>& args) {
16936 v8::HandleScope scope(args.GetIsolate()); 16939 v8::HandleScope scope(args.GetIsolate());
16937 v8::Handle<v8::StackTrace> stackTrace = 16940 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16938 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); 16941 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
16939 CHECK_EQ(4, stackTrace->GetFrameCount()); 16942 CHECK_EQ(4, stackTrace->GetFrameCount());
16940 v8::Handle<v8::String> url = v8_str("url"); 16943 v8::Handle<v8::String> url = v8_str("url");
16941 for (int i = 0; i < 3; i++) { 16944 for (int i = 0; i < 3; i++) {
16942 v8::Handle<v8::String> name = 16945 v8::Handle<v8::String> name =
16943 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); 16946 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
16944 CHECK(!name.IsEmpty()); 16947 CHECK(!name.IsEmpty());
16945 CHECK_EQ(url, name); 16948 CHECK_EQ(url, name);
16946 } 16949 }
16947 } 16950 }
16948 16951
(...skipping 23 matching lines...) Expand all
16972 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); 16975 i::OS::SNPrintF(code, source, "//# sourceURL=source_url");
16973 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); 16976 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
16974 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); 16977 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url");
16975 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); 16978 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
16976 } 16979 }
16977 16980
16978 16981
16979 void AnalyzeStackOfDynamicScriptWithSourceURL( 16982 void AnalyzeStackOfDynamicScriptWithSourceURL(
16980 const v8::FunctionCallbackInfo<v8::Value>& args) { 16983 const v8::FunctionCallbackInfo<v8::Value>& args) {
16981 v8::HandleScope scope(args.GetIsolate()); 16984 v8::HandleScope scope(args.GetIsolate());
16982 v8::Handle<v8::StackTrace> stackTrace = 16985 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
16983 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); 16986 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
16984 CHECK_EQ(4, stackTrace->GetFrameCount()); 16987 CHECK_EQ(4, stackTrace->GetFrameCount());
16985 v8::Handle<v8::String> url = v8_str("source_url"); 16988 v8::Handle<v8::String> url = v8_str("source_url");
16986 for (int i = 0; i < 3; i++) { 16989 for (int i = 0; i < 3; i++) {
16987 v8::Handle<v8::String> name = 16990 v8::Handle<v8::String> name =
16988 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); 16991 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL();
16989 CHECK(!name.IsEmpty()); 16992 CHECK(!name.IsEmpty());
16990 CHECK_EQ(url, name); 16993 CHECK_EQ(url, name);
16991 } 16994 }
16992 } 16995 }
16993 16996
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
17257 }; 17260 };
17258 17261
17259 17262
17260 TEST(VisitExternalStrings) { 17263 TEST(VisitExternalStrings) {
17261 LocalContext env; 17264 LocalContext env;
17262 v8::HandleScope scope(env->GetIsolate()); 17265 v8::HandleScope scope(env->GetIsolate());
17263 const char* string = "Some string"; 17266 const char* string = "Some string";
17264 uint16_t* two_byte_string = AsciiToTwoByteString(string); 17267 uint16_t* two_byte_string = AsciiToTwoByteString(string);
17265 TestResource* resource[4]; 17268 TestResource* resource[4];
17266 resource[0] = new TestResource(two_byte_string); 17269 resource[0] = new TestResource(two_byte_string);
17267 v8::Local<v8::String> string0 = v8::String::NewExternal(resource[0]); 17270 v8::Local<v8::String> string0 =
17271 v8::String::NewExternal(env->GetIsolate(), resource[0]);
17268 resource[1] = new TestResource(two_byte_string); 17272 resource[1] = new TestResource(two_byte_string);
17269 v8::Local<v8::String> string1 = v8::String::NewExternal(resource[1]); 17273 v8::Local<v8::String> string1 =
17274 v8::String::NewExternal(env->GetIsolate(), resource[1]);
17270 17275
17271 // Externalized symbol. 17276 // Externalized symbol.
17272 resource[2] = new TestResource(two_byte_string); 17277 resource[2] = new TestResource(two_byte_string);
17273 v8::Local<v8::String> string2 = v8::String::NewFromUtf8( 17278 v8::Local<v8::String> string2 = v8::String::NewFromUtf8(
17274 env->GetIsolate(), string, v8::String::kInternalizedString); 17279 env->GetIsolate(), string, v8::String::kInternalizedString);
17275 CHECK(string2->MakeExternal(resource[2])); 17280 CHECK(string2->MakeExternal(resource[2]));
17276 17281
17277 // Symbolized External. 17282 // Symbolized External.
17278 resource[3] = new TestResource(AsciiToTwoByteString("Some other string")); 17283 resource[3] = new TestResource(AsciiToTwoByteString("Some other string"));
17279 v8::Local<v8::String> string3 = v8::String::NewExternal(resource[3]); 17284 v8::Local<v8::String> string3 =
17285 v8::String::NewExternal(env->GetIsolate(), resource[3]);
17280 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string. 17286 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string.
17281 // Turn into a symbol. 17287 // Turn into a symbol.
17282 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3); 17288 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3);
17283 CHECK(!CcTest::heap()->InternalizeString(*string3_i)->IsFailure()); 17289 CHECK(!CcTest::heap()->InternalizeString(*string3_i)->IsFailure());
17284 CHECK(string3_i->IsInternalizedString()); 17290 CHECK(string3_i->IsInternalizedString());
17285 17291
17286 // 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
17287 CHECK(string0->IsExternal()); 17293 CHECK(string0->IsExternal());
17288 CHECK(string1->IsExternal()); 17294 CHECK(string1->IsExternal());
17289 CHECK(string2->IsExternal()); 17295 CHECK(string2->IsExternal());
17290 CHECK(string3->IsExternal()); 17296 CHECK(string3->IsExternal());
17291 17297
17292 VisitorImpl visitor(resource); 17298 VisitorImpl visitor(resource);
17293 v8::V8::VisitExternalResources(&visitor); 17299 v8::V8::VisitExternalResources(&visitor);
17294 visitor.CheckVisitedResources(); 17300 visitor.CheckVisitedResources();
17295 } 17301 }
17296 17302
17297 17303
17298 TEST(ExternalStringCollectedAtTearDown) { 17304 TEST(ExternalStringCollectedAtTearDown) {
17299 int destroyed = 0; 17305 int destroyed = 0;
17300 v8::Isolate* isolate = v8::Isolate::New(); 17306 v8::Isolate* isolate = v8::Isolate::New();
17301 { v8::Isolate::Scope isolate_scope(isolate); 17307 { v8::Isolate::Scope isolate_scope(isolate);
17302 v8::HandleScope handle_scope(isolate); 17308 v8::HandleScope handle_scope(isolate);
17303 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.";
17304 TestAsciiResource* inscription = 17310 TestAsciiResource* inscription =
17305 new TestAsciiResource(i::StrDup(s), &destroyed); 17311 new TestAsciiResource(i::StrDup(s), &destroyed);
17306 v8::Local<v8::String> ring = v8::String::NewExternal(inscription); 17312 v8::Local<v8::String> ring = v8::String::NewExternal(isolate, inscription);
17307 // Ring is still alive. Orcs are roaming freely across our lands. 17313 // Ring is still alive. Orcs are roaming freely across our lands.
17308 CHECK_EQ(0, destroyed); 17314 CHECK_EQ(0, destroyed);
17309 USE(ring); 17315 USE(ring);
17310 } 17316 }
17311 17317
17312 isolate->Dispose(); 17318 isolate->Dispose();
17313 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice. 17319 // Ring has been destroyed. Free Peoples of Middle-earth Rejoice.
17314 CHECK_EQ(1, destroyed); 17320 CHECK_EQ(1, destroyed);
17315 } 17321 }
17316 17322
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
17402 // Most significant fraction bit for quiet nan is set to 0 17408 // Most significant fraction bit for quiet nan is set to 0
17403 // on MIPS architecture. Allowed by IEEE-754. 17409 // on MIPS architecture. Allowed by IEEE-754.
17404 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); 17410 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff));
17405 #else 17411 #else
17406 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); 17412 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff));
17407 #endif 17413 #endif
17408 } 17414 }
17409 17415
17410 // 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
17411 // quiets SNaNs. 17417 // quiets SNaNs.
17412 v8::Handle<v8::Value> date = v8::Date::New(test_value); 17418 v8::Handle<v8::Value> date =
17419 v8::Date::New(context->GetIsolate(), test_value);
17413 double expected_stored_date = DoubleToDateTime(test_value); 17420 double expected_stored_date = DoubleToDateTime(test_value);
17414 double stored_date = date->NumberValue(); 17421 double stored_date = date->NumberValue();
17415 if (!std::isnan(expected_stored_date)) { 17422 if (!std::isnan(expected_stored_date)) {
17416 CHECK_EQ(expected_stored_date, stored_date); 17423 CHECK_EQ(expected_stored_date, stored_date);
17417 } else { 17424 } else {
17418 uint64_t stored_bits = DoubleToBits(stored_date); 17425 uint64_t stored_bits = DoubleToBits(stored_date);
17419 // Check if quiet nan (bits 51..62 all set). 17426 // Check if quiet nan (bits 51..62 all set).
17420 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) 17427 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR)
17421 // Most significant fraction bit for quiet nan is set to 0 17428 // Most significant fraction bit for quiet nan is set to 0
17422 // 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
18252 i::SmartArrayPointer<uintptr_t> 18259 i::SmartArrayPointer<uintptr_t>
18253 aligned_contents(new uintptr_t[aligned_length]); 18260 aligned_contents(new uintptr_t[aligned_length]);
18254 uint16_t* string_contents = reinterpret_cast<uint16_t*>(*aligned_contents); 18261 uint16_t* string_contents = reinterpret_cast<uint16_t*>(*aligned_contents);
18255 // Set to contain only one byte. 18262 // Set to contain only one byte.
18256 for (int i = 0; i < length-1; i++) { 18263 for (int i = 0; i < length-1; i++) {
18257 string_contents[i] = 0x41; 18264 string_contents[i] = 0x41;
18258 } 18265 }
18259 string_contents[length-1] = 0; 18266 string_contents[length-1] = 0;
18260 // Simple case. 18267 // Simple case.
18261 Handle<String> string; 18268 Handle<String> string;
18262 string = String::NewExternal(new TestResource(string_contents)); 18269 string = String::NewExternal(isolate, new TestResource(string_contents));
18263 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); 18270 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte());
18264 // Counter example. 18271 // Counter example.
18265 string = String::NewFromTwoByte(isolate, string_contents); 18272 string = String::NewFromTwoByte(isolate, string_contents);
18266 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); 18273 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte());
18267 // Test left right and balanced cons strings. 18274 // Test left right and balanced cons strings.
18268 Handle<String> base = String::NewFromUtf8(isolate, "a"); 18275 Handle<String> base = String::NewFromUtf8(isolate, "a");
18269 Handle<String> left = base; 18276 Handle<String> left = base;
18270 Handle<String> right = base; 18277 Handle<String> right = base;
18271 for (int i = 0; i < 1000; i++) { 18278 for (int i = 0; i < 1000; i++) {
18272 left = String::Concat(base, left); 18279 left = String::Concat(base, left);
18273 right = String::Concat(right, base); 18280 right = String::Concat(right, base);
18274 } 18281 }
18275 Handle<String> balanced = String::Concat(left, base); 18282 Handle<String> balanced = String::Concat(left, base);
18276 balanced = String::Concat(balanced, right); 18283 balanced = String::Concat(balanced, right);
18277 Handle<String> cons_strings[] = {left, balanced, right}; 18284 Handle<String> cons_strings[] = {left, balanced, right};
18278 Handle<String> two_byte = 18285 Handle<String> two_byte =
18279 String::NewExternal(new TestResource(string_contents)); 18286 String::NewExternal(isolate, new TestResource(string_contents));
18280 for (size_t i = 0; i < ARRAY_SIZE(cons_strings); i++) { 18287 for (size_t i = 0; i < ARRAY_SIZE(cons_strings); i++) {
18281 // Base assumptions. 18288 // Base assumptions.
18282 string = cons_strings[i]; 18289 string = cons_strings[i];
18283 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); 18290 CHECK(string->IsOneByte() && string->ContainsOnlyOneByte());
18284 // Test left and right concatentation. 18291 // Test left and right concatentation.
18285 string = String::Concat(two_byte, cons_strings[i]); 18292 string = String::Concat(two_byte, cons_strings[i]);
18286 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); 18293 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte());
18287 string = String::Concat(cons_strings[i], two_byte); 18294 string = String::Concat(cons_strings[i], two_byte);
18288 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); 18295 CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte());
18289 } 18296 }
18290 // Set bits in different positions 18297 // Set bits in different positions
18291 // for strings of different lengths and alignments. 18298 // for strings of different lengths and alignments.
18292 for (int alignment = 0; alignment < 7; alignment++) { 18299 for (int alignment = 0; alignment < 7; alignment++) {
18293 for (int size = 2; alignment + size < length; size *= 2) { 18300 for (int size = 2; alignment + size < length; size *= 2) {
18294 int zero_offset = size + alignment; 18301 int zero_offset = size + alignment;
18295 string_contents[zero_offset] = 0; 18302 string_contents[zero_offset] = 0;
18296 for (int i = 0; i < size; i++) { 18303 for (int i = 0; i < size; i++) {
18297 int shift = 8 + (i % 7); 18304 int shift = 8 + (i % 7);
18298 string_contents[alignment + i] = 1 << shift; 18305 string_contents[alignment + i] = 1 << shift;
18299 string = 18306 string = String::NewExternal(
18300 String::NewExternal(new TestResource(string_contents + alignment)); 18307 isolate, new TestResource(string_contents + alignment));
18301 CHECK_EQ(size, string->Length()); 18308 CHECK_EQ(size, string->Length());
18302 CHECK(!string->ContainsOnlyOneByte()); 18309 CHECK(!string->ContainsOnlyOneByte());
18303 string_contents[alignment + i] = 0x41; 18310 string_contents[alignment + i] = 0x41;
18304 } 18311 }
18305 string_contents[zero_offset] = 0x41; 18312 string_contents[zero_offset] = 0x41;
18306 } 18313 }
18307 } 18314 }
18308 } 18315 }
18309 18316
18310 18317
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
19072 } 19079 }
19073 19080
19074 19081
19075 static void Getter(v8::Local<v8::String> property, 19082 static void Getter(v8::Local<v8::String> property,
19076 const v8::PropertyCallbackInfo<v8::Value>& info ) { 19083 const v8::PropertyCallbackInfo<v8::Value>& info ) {
19077 info.GetReturnValue().Set(v8_str("42!")); 19084 info.GetReturnValue().Set(v8_str("42!"));
19078 } 19085 }
19079 19086
19080 19087
19081 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) { 19088 static void Enumerator(const v8::PropertyCallbackInfo<v8::Array>& info) {
19082 v8::Handle<v8::Array> result = v8::Array::New(); 19089 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate());
19083 result->Set(0, v8_str("universalAnswer")); 19090 result->Set(0, v8_str("universalAnswer"));
19084 info.GetReturnValue().Set(result); 19091 info.GetReturnValue().Set(result);
19085 } 19092 }
19086 19093
19087 19094
19088 TEST(NamedEnumeratorAndForIn) { 19095 TEST(NamedEnumeratorAndForIn) {
19089 LocalContext context; 19096 LocalContext context;
19090 v8::HandleScope handle_scope(context->GetIsolate()); 19097 v8::HandleScope handle_scope(context->GetIsolate());
19091 v8::Context::Scope context_scope(context.local()); 19098 v8::Context::Scope context_scope(context.local());
19092 19099
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
20083 LocalContext context; 20090 LocalContext context;
20084 v8::HandleScope scope(context->GetIsolate()); 20091 v8::HandleScope scope(context->GetIsolate());
20085 20092
20086 Local<FunctionTemplate> templ = FunctionTemplate::New(); 20093 Local<FunctionTemplate> templ = FunctionTemplate::New();
20087 Local<ObjectTemplate> inst = templ->InstanceTemplate(); 20094 Local<ObjectTemplate> inst = templ->InstanceTemplate();
20088 inst->SetAccessor(v8_str("foo"), 20095 inst->SetAccessor(v8_str("foo"),
20089 InstanceCheckedGetter, InstanceCheckedSetter, 20096 InstanceCheckedGetter, InstanceCheckedSetter,
20090 Handle<Value>(), 20097 Handle<Value>(),
20091 v8::DEFAULT, 20098 v8::DEFAULT,
20092 v8::None, 20099 v8::None,
20093 v8::AccessorSignature::New(templ)); 20100 v8::AccessorSignature::New(context->GetIsolate(), templ));
20094 context->Global()->Set(v8_str("f"), templ->GetFunction()); 20101 context->Global()->Set(v8_str("f"), templ->GetFunction());
20095 20102
20096 printf("Testing positive ...\n"); 20103 printf("Testing positive ...\n");
20097 CompileRun("var obj = new f();"); 20104 CompileRun("var obj = new f();");
20098 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); 20105 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj"))));
20099 CheckInstanceCheckedAccessors(true); 20106 CheckInstanceCheckedAccessors(true);
20100 20107
20101 printf("Testing negative ...\n"); 20108 printf("Testing negative ...\n");
20102 CompileRun("var obj = {};" 20109 CompileRun("var obj = {};"
20103 "obj.__proto__ = new f();"); 20110 "obj.__proto__ = new f();");
20104 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); 20111 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj"))));
20105 CheckInstanceCheckedAccessors(false); 20112 CheckInstanceCheckedAccessors(false);
20106 } 20113 }
20107 20114
20108 20115
20109 THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) { 20116 THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) {
20110 v8::internal::FLAG_allow_natives_syntax = true; 20117 v8::internal::FLAG_allow_natives_syntax = true;
20111 LocalContext context; 20118 LocalContext context;
20112 v8::HandleScope scope(context->GetIsolate()); 20119 v8::HandleScope scope(context->GetIsolate());
20113 20120
20114 Local<FunctionTemplate> templ = FunctionTemplate::New(); 20121 Local<FunctionTemplate> templ = FunctionTemplate::New();
20115 Local<ObjectTemplate> inst = templ->InstanceTemplate(); 20122 Local<ObjectTemplate> inst = templ->InstanceTemplate();
20116 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); 20123 AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
20117 inst->SetAccessor(v8_str("foo"), 20124 inst->SetAccessor(v8_str("foo"),
20118 InstanceCheckedGetter, InstanceCheckedSetter, 20125 InstanceCheckedGetter, InstanceCheckedSetter,
20119 Handle<Value>(), 20126 Handle<Value>(),
20120 v8::DEFAULT, 20127 v8::DEFAULT,
20121 v8::None, 20128 v8::None,
20122 v8::AccessorSignature::New(templ)); 20129 v8::AccessorSignature::New(context->GetIsolate(), templ));
20123 context->Global()->Set(v8_str("f"), templ->GetFunction()); 20130 context->Global()->Set(v8_str("f"), templ->GetFunction());
20124 20131
20125 printf("Testing positive ...\n"); 20132 printf("Testing positive ...\n");
20126 CompileRun("var obj = new f();"); 20133 CompileRun("var obj = new f();");
20127 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); 20134 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj"))));
20128 CheckInstanceCheckedAccessors(true); 20135 CheckInstanceCheckedAccessors(true);
20129 20136
20130 printf("Testing negative ...\n"); 20137 printf("Testing negative ...\n");
20131 CompileRun("var obj = {};" 20138 CompileRun("var obj = {};"
20132 "obj.__proto__ = new f();"); 20139 "obj.__proto__ = new f();");
20133 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj")))); 20140 CHECK(!templ->HasInstance(context->Global()->Get(v8_str("obj"))));
20134 CheckInstanceCheckedAccessors(false); 20141 CheckInstanceCheckedAccessors(false);
20135 } 20142 }
20136 20143
20137 20144
20138 THREADED_TEST(InstanceCheckOnPrototypeAccessor) { 20145 THREADED_TEST(InstanceCheckOnPrototypeAccessor) {
20139 v8::internal::FLAG_allow_natives_syntax = true; 20146 v8::internal::FLAG_allow_natives_syntax = true;
20140 LocalContext context; 20147 LocalContext context;
20141 v8::HandleScope scope(context->GetIsolate()); 20148 v8::HandleScope scope(context->GetIsolate());
20142 20149
20143 Local<FunctionTemplate> templ = FunctionTemplate::New(); 20150 Local<FunctionTemplate> templ = FunctionTemplate::New();
20144 Local<ObjectTemplate> proto = templ->PrototypeTemplate(); 20151 Local<ObjectTemplate> proto = templ->PrototypeTemplate();
20145 proto->SetAccessor(v8_str("foo"), 20152 proto->SetAccessor(v8_str("foo"),
20146 InstanceCheckedGetter, InstanceCheckedSetter, 20153 InstanceCheckedGetter, InstanceCheckedSetter,
20147 Handle<Value>(), 20154 Handle<Value>(),
20148 v8::DEFAULT, 20155 v8::DEFAULT,
20149 v8::None, 20156 v8::None,
20150 v8::AccessorSignature::New(templ)); 20157 v8::AccessorSignature::New(context->GetIsolate(), templ));
20151 context->Global()->Set(v8_str("f"), templ->GetFunction()); 20158 context->Global()->Set(v8_str("f"), templ->GetFunction());
20152 20159
20153 printf("Testing positive ...\n"); 20160 printf("Testing positive ...\n");
20154 CompileRun("var obj = new f();"); 20161 CompileRun("var obj = new f();");
20155 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj")))); 20162 CHECK(templ->HasInstance(context->Global()->Get(v8_str("obj"))));
20156 CheckInstanceCheckedAccessors(true); 20163 CheckInstanceCheckedAccessors(true);
20157 20164
20158 printf("Testing negative ...\n"); 20165 printf("Testing negative ...\n");
20159 CompileRun("var obj = {};" 20166 CompileRun("var obj = {};"
20160 "obj.__proto__ = new f();"); 20167 "obj.__proto__ = new f();");
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
20559 // failed access check callback will be called on each access. 20566 // failed access check callback will be called on each access.
20560 LocalContext context1(NULL, global_template); 20567 LocalContext context1(NULL, global_template);
20561 context1->Global()->Set(v8_str("other"), global0); 20568 context1->Global()->Set(v8_str("other"), global0);
20562 20569
20563 ExpectString("JSON.stringify(other)", "{}"); 20570 ExpectString("JSON.stringify(other)", "{}");
20564 ExpectString("JSON.stringify({ 'a' : other, 'b' : ['c'] })", 20571 ExpectString("JSON.stringify({ 'a' : other, 'b' : ['c'] })",
20565 "{\"a\":{},\"b\":[\"c\"]}"); 20572 "{\"a\":{},\"b\":[\"c\"]}");
20566 ExpectString("JSON.stringify([other, 'b', 'c'])", 20573 ExpectString("JSON.stringify([other, 'b', 'c'])",
20567 "[{},\"b\",\"c\"]"); 20574 "[{},\"b\",\"c\"]");
20568 20575
20569 v8::Handle<v8::Array> array = v8::Array::New(2); 20576 v8::Handle<v8::Array> array = v8::Array::New(CcTest::isolate(), 2);
20570 array->Set(0, v8_str("a")); 20577 array->Set(0, v8_str("a"));
20571 array->Set(1, v8_str("b")); 20578 array->Set(1, v8_str("b"));
20572 context1->Global()->Set(v8_str("array"), array); 20579 context1->Global()->Set(v8_str("array"), array);
20573 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]"); 20580 ExpectString("JSON.stringify(array)", "[\"a\",\"b\"]");
20574 array->TurnOnAccessCheck(); 20581 array->TurnOnAccessCheck();
20575 ExpectString("JSON.stringify(array)", "[]"); 20582 ExpectString("JSON.stringify(array)", "[]");
20576 ExpectString("JSON.stringify([array])", "[[]]"); 20583 ExpectString("JSON.stringify([array])", "[[]]");
20577 ExpectString("JSON.stringify({'a' : array})", "{\"a\":[]}"); 20584 ExpectString("JSON.stringify({'a' : array})", "{\"a\":[]}");
20578 } 20585 }
20579 } 20586 }
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
20847 } 20854 }
20848 for (int i = 0; i < runs; i++) { 20855 for (int i = 0; i < runs; i++) {
20849 Local<String> expected; 20856 Local<String> expected;
20850 if (i != 0) { 20857 if (i != 0) {
20851 CHECK_EQ(v8_str("escape value"), values[i]); 20858 CHECK_EQ(v8_str("escape value"), values[i]);
20852 } else { 20859 } else {
20853 CHECK(values[i].IsEmpty()); 20860 CHECK(values[i].IsEmpty());
20854 } 20861 }
20855 } 20862 }
20856 } 20863 }
OLDNEW
« no previous file with comments | « test/cctest/test-accessors.cc ('k') | test/cctest/test-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698