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

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

Issue 842153004: Unify phantom and internal fields weak handle callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« src/global-handles.cc ('K') | « 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 7779 matching lines...) Expand 10 before | Expand all | Expand 10 after
7790 int y() { return y_; } 7790 int y() { return y_; }
7791 void set_y(int y) { y_ = y; } 7791 void set_y(int y) { y_ = y; }
7792 7792
7793 private: 7793 private:
7794 int y_; 7794 int y_;
7795 int x_; 7795 int x_;
7796 }; 7796 };
7797 7797
7798 7798
7799 void CheckInternalFields( 7799 void CheckInternalFields(
7800 const v8::InternalFieldsCallbackData<Trivial, Trivial2>& data) { 7800 const v8::PhantomCallbackData<void, Trivial, Trivial2>& data) {
7801 Trivial* t1 = data.GetInternalField1(); 7801 Trivial* t1 = data.GetInternalField1();
7802 Trivial2* t2 = data.GetInternalField2(); 7802 Trivial2* t2 = data.GetInternalField2();
7803 CHECK_EQ(42, t1->x()); 7803 CHECK_EQ(42, t1->x());
7804 CHECK_EQ(103, t2->x()); 7804 CHECK_EQ(103, t2->x());
7805 t1->set_x(1729); 7805 t1->set_x(1729);
7806 t2->set_x(33550336); 7806 t2->set_x(33550336);
7807 } 7807 }
7808 7808
7809 7809
7810 void InternalFieldCallback(bool global_gc) { 7810 void InternalFieldCallback(bool global_gc) {
(...skipping 17 matching lines...) Expand all
7828 7828
7829 obj->SetAlignedPointerInInternalField(0, t1); 7829 obj->SetAlignedPointerInInternalField(0, t1);
7830 t1 = reinterpret_cast<Trivial*>(obj->GetAlignedPointerFromInternalField(0)); 7830 t1 = reinterpret_cast<Trivial*>(obj->GetAlignedPointerFromInternalField(0));
7831 CHECK_EQ(42, t1->x()); 7831 CHECK_EQ(42, t1->x());
7832 7832
7833 obj->SetAlignedPointerInInternalField(1, t2); 7833 obj->SetAlignedPointerInInternalField(1, t2);
7834 t2 = 7834 t2 =
7835 reinterpret_cast<Trivial2*>(obj->GetAlignedPointerFromInternalField(1)); 7835 reinterpret_cast<Trivial2*>(obj->GetAlignedPointerFromInternalField(1));
7836 CHECK_EQ(103, t2->x()); 7836 CHECK_EQ(103, t2->x());
7837 7837
7838 handle.SetPhantom(CheckInternalFields, 0, 1); 7838 handle.SetPhantom<void, Trivial, Trivial2>(0, 0, 1, CheckInternalFields);
7839 if (!global_gc) { 7839 if (!global_gc) {
7840 handle.MarkIndependent(); 7840 handle.MarkIndependent();
7841 } 7841 }
7842 } 7842 }
7843 if (global_gc) { 7843 if (global_gc) {
7844 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags); 7844 CcTest::heap()->CollectAllGarbage(TestHeap::Heap::kNoGCFlags);
7845 } else { 7845 } else {
7846 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 7846 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
7847 } 7847 }
7848 7848
(...skipping 16903 matching lines...) Expand 10 before | Expand all | Expand 10 after
24752 "bar2.js"); 24752 "bar2.js");
24753 } 24753 }
24754 24754
24755 24755
24756 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { 24756 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
24757 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", 24757 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#",
24758 " sourceMappingURL=bar2.js\n", "foo();", NULL}; 24758 " sourceMappingURL=bar2.js\n", "foo();", NULL};
24759 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, 24759 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
24760 "bar2.js"); 24760 "bar2.js");
24761 } 24761 }
OLDNEW
« src/global-handles.cc ('K') | « src/global-handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698