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

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

Issue 12716010: Added a version of the v8::HandleScope constructor with an Isolate and use that consistently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback. Rebased Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-disasm-arm.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 22 matching lines...) Expand all
33 #include "factory.h" 33 #include "factory.h"
34 #include "macro-assembler.h" 34 #include "macro-assembler.h"
35 #include "objects.h" 35 #include "objects.h"
36 #include "global-handles.h" 36 #include "global-handles.h"
37 #include "cctest.h" 37 #include "cctest.h"
38 38
39 using namespace v8::internal; 39 using namespace v8::internal;
40 40
41 41
42 TEST(ObjectHashTable) { 42 TEST(ObjectHashTable) {
43 v8::HandleScope scope;
44 LocalContext context; 43 LocalContext context;
44 v8::HandleScope scope(context->GetIsolate());
45 Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(23); 45 Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(23);
46 Handle<JSObject> a = FACTORY->NewJSArray(7); 46 Handle<JSObject> a = FACTORY->NewJSArray(7);
47 Handle<JSObject> b = FACTORY->NewJSArray(11); 47 Handle<JSObject> b = FACTORY->NewJSArray(11);
48 table = PutIntoObjectHashTable(table, a, b); 48 table = PutIntoObjectHashTable(table, a, b);
49 CHECK_EQ(table->NumberOfElements(), 1); 49 CHECK_EQ(table->NumberOfElements(), 1);
50 CHECK_EQ(table->Lookup(*a), *b); 50 CHECK_EQ(table->Lookup(*a), *b);
51 CHECK_EQ(table->Lookup(*b), HEAP->the_hole_value()); 51 CHECK_EQ(table->Lookup(*b), HEAP->the_hole_value());
52 52
53 // Keys still have to be valid after objects were moved. 53 // Keys still have to be valid after objects were moved.
54 HEAP->CollectGarbage(NEW_SPACE); 54 HEAP->CollectGarbage(NEW_SPACE);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 for (int i = 0; i < 100; i++) { 94 for (int i = 0; i < 100; i++) {
95 Handle<JSObject> key = FACTORY->NewJSArray(7); 95 Handle<JSObject> key = FACTORY->NewJSArray(7);
96 CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value()); 96 CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value());
97 CHECK_EQ(key->GetIdentityHash(OMIT_CREATION), HEAP->undefined_value()); 97 CHECK_EQ(key->GetIdentityHash(OMIT_CREATION), HEAP->undefined_value());
98 } 98 }
99 } 99 }
100 100
101 101
102 #ifdef DEBUG 102 #ifdef DEBUG
103 TEST(ObjectHashSetCausesGC) { 103 TEST(ObjectHashSetCausesGC) {
104 v8::HandleScope scope;
105 LocalContext context; 104 LocalContext context;
105 v8::HandleScope scope(context->GetIsolate());
106 Handle<ObjectHashSet> table = FACTORY->NewObjectHashSet(1); 106 Handle<ObjectHashSet> table = FACTORY->NewObjectHashSet(1);
107 Handle<JSObject> key = FACTORY->NewJSArray(0); 107 Handle<JSObject> key = FACTORY->NewJSArray(0);
108 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); 108 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
109 109
110 // Force allocation of hash table backing store for hidden properties. 110 // Force allocation of hash table backing store for hidden properties.
111 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); 111 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1"));
112 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); 112 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2"));
113 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); 113 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3"));
114 114
115 // Simulate a full heap so that generating an identity hash code 115 // Simulate a full heap so that generating an identity hash code
116 // in subsequent calls will request GC. 116 // in subsequent calls will request GC.
117 SimulateFullSpace(HEAP->new_space()); 117 SimulateFullSpace(HEAP->new_space());
118 SimulateFullSpace(HEAP->old_pointer_space()); 118 SimulateFullSpace(HEAP->old_pointer_space());
119 119
120 // Calling Contains() should not cause GC ever. 120 // Calling Contains() should not cause GC ever.
121 CHECK(!table->Contains(*key)); 121 CHECK(!table->Contains(*key));
122 122
123 // Calling Remove() should not cause GC ever. 123 // Calling Remove() should not cause GC ever.
124 CHECK(!table->Remove(*key)->IsFailure()); 124 CHECK(!table->Remove(*key)->IsFailure());
125 125
126 // Calling Add() should request GC by returning a failure. 126 // Calling Add() should request GC by returning a failure.
127 CHECK(table->Add(*key)->IsRetryAfterGC()); 127 CHECK(table->Add(*key)->IsRetryAfterGC());
128 } 128 }
129 #endif 129 #endif
130 130
131 131
132 #ifdef DEBUG 132 #ifdef DEBUG
133 TEST(ObjectHashTableCausesGC) { 133 TEST(ObjectHashTableCausesGC) {
134 v8::HandleScope scope;
135 LocalContext context; 134 LocalContext context;
135 v8::HandleScope scope(context->GetIsolate());
136 Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(1); 136 Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(1);
137 Handle<JSObject> key = FACTORY->NewJSArray(0); 137 Handle<JSObject> key = FACTORY->NewJSArray(0);
138 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key); 138 v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
139 139
140 // Force allocation of hash table backing store for hidden properties. 140 // Force allocation of hash table backing store for hidden properties.
141 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1")); 141 key_obj->SetHiddenValue(v8_str("key 1"), v8_str("val 1"));
142 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2")); 142 key_obj->SetHiddenValue(v8_str("key 2"), v8_str("val 2"));
143 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3")); 143 key_obj->SetHiddenValue(v8_str("key 3"), v8_str("val 3"));
144 144
145 // Simulate a full heap so that generating an identity hash code 145 // Simulate a full heap so that generating an identity hash code
146 // in subsequent calls will request GC. 146 // in subsequent calls will request GC.
147 SimulateFullSpace(HEAP->new_space()); 147 SimulateFullSpace(HEAP->new_space());
148 SimulateFullSpace(HEAP->old_pointer_space()); 148 SimulateFullSpace(HEAP->old_pointer_space());
149 149
150 // Calling Lookup() should not cause GC ever. 150 // Calling Lookup() should not cause GC ever.
151 CHECK(table->Lookup(*key)->IsTheHole()); 151 CHECK(table->Lookup(*key)->IsTheHole());
152 152
153 // Calling Put() should request GC by returning a failure. 153 // Calling Put() should request GC by returning a failure.
154 CHECK(table->Put(*key, *key)->IsRetryAfterGC()); 154 CHECK(table->Put(*key, *key)->IsRetryAfterGC());
155 } 155 }
156 #endif 156 #endif
OLDNEW
« no previous file with comments | « test/cctest/test-deoptimization.cc ('k') | test/cctest/test-disasm-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698