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

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

Issue 863443005: Support old and new weak handle API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Undo cast that was not needed. Created 5 years, 11 months 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
« no previous file with comments | « src/global-handles.cc ('k') | no next file » | 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 7697 matching lines...) Expand 10 before | Expand all | Expand 10 after
7708 7708
7709 int y() { return y_; } 7709 int y() { return y_; }
7710 void set_y(int y) { y_ = y; } 7710 void set_y(int y) { y_ = y; }
7711 7711
7712 private: 7712 private:
7713 int y_; 7713 int y_;
7714 int x_; 7714 int x_;
7715 }; 7715 };
7716 7716
7717 7717
7718 void CheckInternalFields(const v8::PhantomCallbackData< 7718 void CheckInternalFields(
7719 v8::Persistent<v8::Object>, Trivial, Trivial2>& data) { 7719 const v8::PhantomCallbackData<v8::Persistent<v8::Object>>& data) {
7720 v8::Persistent<v8::Object>* handle = data.GetParameter(); 7720 v8::Persistent<v8::Object>* handle = data.GetParameter();
7721 handle->Reset(); 7721 handle->Reset();
7722 Trivial* t1 = data.GetInternalField1(); 7722 Trivial* t1 = reinterpret_cast<Trivial*>(data.GetInternalField1());
7723 Trivial2* t2 = data.GetInternalField2(); 7723 Trivial2* t2 = reinterpret_cast<Trivial2*>(data.GetInternalField2());
7724 CHECK_EQ(42, t1->x()); 7724 CHECK_EQ(42, t1->x());
7725 CHECK_EQ(103, t2->x()); 7725 CHECK_EQ(103, t2->x());
7726 t1->set_x(1729); 7726 t1->set_x(1729);
7727 t2->set_x(33550336); 7727 t2->set_x(33550336);
7728 } 7728 }
7729 7729
7730 7730
7731 void InternalFieldCallback(bool global_gc) { 7731 void InternalFieldCallback(bool global_gc) {
7732 LocalContext env; 7732 LocalContext env;
7733 v8::Isolate* isolate = env->GetIsolate(); 7733 v8::Isolate* isolate = env->GetIsolate();
(...skipping 15 matching lines...) Expand all
7749 7749
7750 obj->SetAlignedPointerInInternalField(0, t1); 7750 obj->SetAlignedPointerInInternalField(0, t1);
7751 t1 = reinterpret_cast<Trivial*>(obj->GetAlignedPointerFromInternalField(0)); 7751 t1 = reinterpret_cast<Trivial*>(obj->GetAlignedPointerFromInternalField(0));
7752 CHECK_EQ(42, t1->x()); 7752 CHECK_EQ(42, t1->x());
7753 7753
7754 obj->SetAlignedPointerInInternalField(1, t2); 7754 obj->SetAlignedPointerInInternalField(1, t2);
7755 t2 = 7755 t2 =
7756 reinterpret_cast<Trivial2*>(obj->GetAlignedPointerFromInternalField(1)); 7756 reinterpret_cast<Trivial2*>(obj->GetAlignedPointerFromInternalField(1));
7757 CHECK_EQ(103, t2->x()); 7757 CHECK_EQ(103, t2->x());
7758 7758
7759 handle.SetPhantom<v8::Persistent<v8::Object>, Trivial, Trivial2>( 7759 handle.SetPhantom<v8::Persistent<v8::Object>>(&handle, CheckInternalFields,
7760 &handle, 0, 1, CheckInternalFields); 7760 0, 1);
7761 if (!global_gc) { 7761 if (!global_gc) {
7762 handle.MarkIndependent(); 7762 handle.MarkIndependent();
7763 } 7763 }
7764 } 7764 }
7765 if (global_gc) { 7765 if (global_gc) {
7766 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags); 7766 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags);
7767 } else { 7767 } else {
7768 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 7768 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
7769 } 7769 }
7770 7770
(...skipping 16945 matching lines...) Expand 10 before | Expand all | Expand 10 after
24716 "bar2.js"); 24716 "bar2.js");
24717 } 24717 }
24718 24718
24719 24719
24720 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { 24720 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
24721 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", 24721 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#",
24722 " sourceMappingURL=bar2.js\n", "foo();", NULL}; 24722 " sourceMappingURL=bar2.js\n", "foo();", NULL};
24723 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, 24723 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
24724 "bar2.js"); 24724 "bar2.js");
24725 } 24725 }
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698