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

Side by Side Diff: src/handles.cc

Issue 6713070: Clean up Isolate usages in handles.cc. (Closed)
Patch Set: Created 9 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
« no previous file with comments | « no previous file | 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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 126
127 Address HandleScope::current_limit_address() { 127 Address HandleScope::current_limit_address() {
128 return reinterpret_cast<Address>( 128 return reinterpret_cast<Address>(
129 &Isolate::Current()->handle_scope_data()->limit); 129 &Isolate::Current()->handle_scope_data()->limit);
130 } 130 }
131 131
132 132
133 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content, 133 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content,
134 Handle<JSArray> array) { 134 Handle<JSArray> array) {
135 CALL_HEAP_FUNCTION(content->GetHeap()->isolate(), 135 CALL_HEAP_FUNCTION(content->GetIsolate(),
136 content->AddKeysFromJSArray(*array), FixedArray); 136 content->AddKeysFromJSArray(*array), FixedArray);
137 } 137 }
138 138
139 139
140 Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first, 140 Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first,
141 Handle<FixedArray> second) { 141 Handle<FixedArray> second) {
142 CALL_HEAP_FUNCTION(first->GetHeap()->isolate(), 142 CALL_HEAP_FUNCTION(first->GetIsolate(),
143 first->UnionOfKeys(*second), FixedArray); 143 first->UnionOfKeys(*second), FixedArray);
144 } 144 }
145 145
146 146
147 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( 147 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
148 Handle<JSFunction> constructor, 148 Handle<JSFunction> constructor,
149 Handle<JSGlobalProxy> global) { 149 Handle<JSGlobalProxy> global) {
150 CALL_HEAP_FUNCTION( 150 CALL_HEAP_FUNCTION(
151 constructor->GetHeap()->isolate(), 151 constructor->GetIsolate(),
152 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global), 152 constructor->GetHeap()->ReinitializeJSGlobalProxy(*constructor, *global),
153 JSGlobalProxy); 153 JSGlobalProxy);
154 } 154 }
155 155
156 156
157 void SetExpectedNofProperties(Handle<JSFunction> func, int nof) { 157 void SetExpectedNofProperties(Handle<JSFunction> func, int nof) {
158 // If objects constructed from this function exist then changing 158 // If objects constructed from this function exist then changing
159 // 'estimated_nof_properties' is dangerous since the previous value might 159 // 'estimated_nof_properties' is dangerous since the previous value might
160 // have been compiled into the fast construct stub. More over, the inobject 160 // have been compiled into the fast construct stub. More over, the inobject
161 // slack tracking logic might have adjusted the previous value, so even 161 // slack tracking logic might have adjusted the previous value, so even
162 // passing the same value is risky. 162 // passing the same value is risky.
163 if (func->shared()->live_objects_may_exist()) return; 163 if (func->shared()->live_objects_may_exist()) return;
164 164
165 func->shared()->set_expected_nof_properties(nof); 165 func->shared()->set_expected_nof_properties(nof);
166 if (func->has_initial_map()) { 166 if (func->has_initial_map()) {
167 Handle<Map> new_initial_map = 167 Handle<Map> new_initial_map =
168 func->GetIsolate()->factory()->CopyMapDropTransitions( 168 func->GetIsolate()->factory()->CopyMapDropTransitions(
169 Handle<Map>(func->initial_map())); 169 Handle<Map>(func->initial_map()));
170 new_initial_map->set_unused_property_fields(nof); 170 new_initial_map->set_unused_property_fields(nof);
171 func->set_initial_map(*new_initial_map); 171 func->set_initial_map(*new_initial_map);
172 } 172 }
173 } 173 }
174 174
175 175
176 void SetPrototypeProperty(Handle<JSFunction> func, Handle<JSObject> value) { 176 void SetPrototypeProperty(Handle<JSFunction> func, Handle<JSObject> value) {
177 CALL_HEAP_FUNCTION_VOID(func->GetHeap()->isolate(), 177 CALL_HEAP_FUNCTION_VOID(func->GetIsolate(),
178 func->SetPrototype(*value)); 178 func->SetPrototype(*value));
179 } 179 }
180 180
181 181
182 static int ExpectedNofPropertiesFromEstimate(int estimate) { 182 static int ExpectedNofPropertiesFromEstimate(int estimate) {
183 // If no properties are added in the constructor, they are more likely 183 // If no properties are added in the constructor, they are more likely
184 // to be added later. 184 // to be added later.
185 if (estimate == 0) estimate = 2; 185 if (estimate == 0) estimate = 2;
186 186
187 // We do not shrink objects that go into a snapshot (yet), so we adjust 187 // We do not shrink objects that go into a snapshot (yet), so we adjust
(...skipping 12 matching lines...) Expand all
200 if (shared->live_objects_may_exist()) return; 200 if (shared->live_objects_may_exist()) return;
201 201
202 shared->set_expected_nof_properties( 202 shared->set_expected_nof_properties(
203 ExpectedNofPropertiesFromEstimate(estimate)); 203 ExpectedNofPropertiesFromEstimate(estimate));
204 } 204 }
205 205
206 206
207 void NormalizeProperties(Handle<JSObject> object, 207 void NormalizeProperties(Handle<JSObject> object,
208 PropertyNormalizationMode mode, 208 PropertyNormalizationMode mode,
209 int expected_additional_properties) { 209 int expected_additional_properties) {
210 CALL_HEAP_FUNCTION_VOID(object->GetHeap()->isolate(), 210 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
211 object->NormalizeProperties( 211 object->NormalizeProperties(
212 mode, 212 mode,
213 expected_additional_properties)); 213 expected_additional_properties));
214 } 214 }
215 215
216 216
217 void NormalizeElements(Handle<JSObject> object) { 217 void NormalizeElements(Handle<JSObject> object) {
218 CALL_HEAP_FUNCTION_VOID(object->GetHeap()->isolate(), 218 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
219 object->NormalizeElements()); 219 object->NormalizeElements());
220 } 220 }
221 221
222 222
223 void TransformToFastProperties(Handle<JSObject> object, 223 void TransformToFastProperties(Handle<JSObject> object,
224 int unused_property_fields) { 224 int unused_property_fields) {
225 CALL_HEAP_FUNCTION_VOID( 225 CALL_HEAP_FUNCTION_VOID(
226 object->GetHeap()->isolate(), 226 object->GetIsolate(),
227 object->TransformToFastProperties(unused_property_fields)); 227 object->TransformToFastProperties(unused_property_fields));
228 } 228 }
229 229
230 230
231 void NumberDictionarySet(Handle<NumberDictionary> dictionary, 231 void NumberDictionarySet(Handle<NumberDictionary> dictionary,
232 uint32_t index, 232 uint32_t index,
233 Handle<Object> value, 233 Handle<Object> value,
234 PropertyDetails details) { 234 PropertyDetails details) {
235 CALL_HEAP_FUNCTION_VOID(dictionary->GetIsolate(), 235 CALL_HEAP_FUNCTION_VOID(dictionary->GetIsolate(),
236 dictionary->Set(index, *value, details)); 236 dictionary->Set(index, *value, details));
237 } 237 }
238 238
239 239
240 void FlattenString(Handle<String> string) { 240 void FlattenString(Handle<String> string) {
241 CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten()); 241 CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten());
242 } 242 }
243 243
244 244
245 Handle<String> FlattenGetString(Handle<String> string) { 245 Handle<String> FlattenGetString(Handle<String> string) {
246 CALL_HEAP_FUNCTION(string->GetIsolate(), string->TryFlatten(), String); 246 CALL_HEAP_FUNCTION(string->GetIsolate(), string->TryFlatten(), String);
247 } 247 }
248 248
249 249
250 Handle<Object> SetPrototype(Handle<JSFunction> function, 250 Handle<Object> SetPrototype(Handle<JSFunction> function,
251 Handle<Object> prototype) { 251 Handle<Object> prototype) {
252 ASSERT(function->should_have_prototype()); 252 ASSERT(function->should_have_prototype());
253 CALL_HEAP_FUNCTION(function->GetHeap()->isolate(), 253 CALL_HEAP_FUNCTION(function->GetIsolate(),
254 Accessors::FunctionSetPrototype(*function, 254 Accessors::FunctionSetPrototype(*function,
255 *prototype, 255 *prototype,
256 NULL), 256 NULL),
257 Object); 257 Object);
258 } 258 }
259 259
260 260
261 Handle<Object> SetProperty(Handle<JSObject> object, 261 Handle<Object> SetProperty(Handle<JSObject> object,
262 Handle<String> key, 262 Handle<String> key,
263 Handle<Object> value, 263 Handle<Object> value,
264 PropertyAttributes attributes, 264 PropertyAttributes attributes,
265 StrictModeFlag strict_mode) { 265 StrictModeFlag strict_mode) {
266 CALL_HEAP_FUNCTION(object->GetHeap()->isolate(), 266 CALL_HEAP_FUNCTION(object->GetIsolate(),
267 object->SetProperty(*key, *value, attributes, strict_mode), 267 object->SetProperty(*key, *value, attributes, strict_mode),
268 Object); 268 Object);
269 } 269 }
270 270
271 271
272 Handle<Object> SetProperty(Handle<Object> object, 272 Handle<Object> SetProperty(Handle<Object> object,
273 Handle<Object> key, 273 Handle<Object> key,
274 Handle<Object> value, 274 Handle<Object> value,
275 PropertyAttributes attributes, 275 PropertyAttributes attributes,
276 StrictModeFlag strict_mode) { 276 StrictModeFlag strict_mode) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 object->GetIsolate(), 324 object->GetIsolate(),
325 object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes), 325 object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes),
326 Object); 326 Object);
327 } 327 }
328 328
329 329
330 void SetLocalPropertyNoThrow(Handle<JSObject> object, 330 void SetLocalPropertyNoThrow(Handle<JSObject> object,
331 Handle<String> key, 331 Handle<String> key,
332 Handle<Object> value, 332 Handle<Object> value,
333 PropertyAttributes attributes) { 333 PropertyAttributes attributes) {
334 ASSERT(!object->GetIsolate()->has_pending_exception()); 334 Isolate* isolate = object->GetIsolate();
335 ASSERT(!isolate->has_pending_exception());
335 CHECK(!SetLocalPropertyIgnoreAttributes( 336 CHECK(!SetLocalPropertyIgnoreAttributes(
336 object, key, value, attributes).is_null()); 337 object, key, value, attributes).is_null());
337 CHECK(!object->GetIsolate()->has_pending_exception()); 338 CHECK(!isolate->has_pending_exception());
338 } 339 }
339 340
340 341
341 Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, 342 Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object,
342 Handle<String> key, 343 Handle<String> key,
343 Handle<Object> value, 344 Handle<Object> value,
344 PropertyAttributes attributes, 345 PropertyAttributes attributes,
345 StrictModeFlag strict_mode) { 346 StrictModeFlag strict_mode) {
346 CALL_HEAP_FUNCTION(object->GetIsolate(), 347 CALL_HEAP_FUNCTION(object->GetIsolate(),
347 object->SetPropertyWithInterceptor(*key, 348 object->SetPropertyWithInterceptor(*key,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 Handle<Object> PreventExtensions(Handle<JSObject> object) { 405 Handle<Object> PreventExtensions(Handle<JSObject> object) {
405 CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object); 406 CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object);
406 } 407 }
407 408
408 409
409 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, 410 Handle<Object> GetHiddenProperties(Handle<JSObject> obj,
410 bool create_if_needed) { 411 bool create_if_needed) {
411 Isolate* isolate = obj->GetIsolate(); 412 Isolate* isolate = obj->GetIsolate();
412 Object* holder = obj->BypassGlobalProxy(); 413 Object* holder = obj->BypassGlobalProxy();
413 if (holder->IsUndefined()) return isolate->factory()->undefined_value(); 414 if (holder->IsUndefined()) return isolate->factory()->undefined_value();
414 obj = Handle<JSObject>(JSObject::cast(holder)); 415 obj = Handle<JSObject>(JSObject::cast(holder), isolate);
415 416
416 if (obj->HasFastProperties()) { 417 if (obj->HasFastProperties()) {
417 // If the object has fast properties, check whether the first slot 418 // If the object has fast properties, check whether the first slot
418 // in the descriptor array matches the hidden symbol. Since the 419 // in the descriptor array matches the hidden symbol. Since the
419 // hidden symbols hash code is zero (and no other string has hash 420 // hidden symbols hash code is zero (and no other string has hash
420 // code zero) it will always occupy the first entry if present. 421 // code zero) it will always occupy the first entry if present.
421 DescriptorArray* descriptors = obj->map()->instance_descriptors(); 422 DescriptorArray* descriptors = obj->map()->instance_descriptors();
422 if ((descriptors->number_of_descriptors() > 0) && 423 if ((descriptors->number_of_descriptors() > 0) &&
423 (descriptors->GetKey(0) == isolate->heap()->hidden_symbol()) && 424 (descriptors->GetKey(0) == isolate->heap()->hidden_symbol()) &&
424 descriptors->IsProperty(0)) { 425 descriptors->IsProperty(0)) {
425 ASSERT(descriptors->GetType(0) == FIELD); 426 ASSERT(descriptors->GetType(0) == FIELD);
426 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0))); 427 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0)),
428 isolate);
427 } 429 }
428 } 430 }
429 431
430 // Only attempt to find the hidden properties in the local object and not 432 // Only attempt to find the hidden properties in the local object and not
431 // in the prototype chain. Note that HasLocalProperty() can cause a GC in 433 // in the prototype chain. Note that HasLocalProperty() can cause a GC in
432 // the general case in the presence of interceptors. 434 // the general case in the presence of interceptors.
433 if (!obj->HasHiddenPropertiesObject()) { 435 if (!obj->HasHiddenPropertiesObject()) {
434 // Hidden properties object not found. Allocate a new hidden properties 436 // Hidden properties object not found. Allocate a new hidden properties
435 // object if requested. Otherwise return the undefined value. 437 // object if requested. Otherwise return the undefined value.
436 if (create_if_needed) { 438 if (create_if_needed) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 #ifdef ENABLE_HEAP_PROTECTION 531 #ifdef ENABLE_HEAP_PROTECTION
530 // Weak reference callbacks are called as if from outside V8. We 532 // Weak reference callbacks are called as if from outside V8. We
531 // need to reeenter to unprotect the heap. 533 // need to reeenter to unprotect the heap.
532 VMState state(OTHER); 534 VMState state(OTHER);
533 #endif 535 #endif
534 Handle<Object> cache = Utils::OpenHandle(*handle); 536 Handle<Object> cache = Utils::OpenHandle(*handle);
535 JSValue* wrapper = JSValue::cast(*cache); 537 JSValue* wrapper = JSValue::cast(*cache);
536 Proxy* proxy = Script::cast(wrapper->value())->wrapper(); 538 Proxy* proxy = Script::cast(wrapper->value())->wrapper();
537 ASSERT(proxy->proxy() == reinterpret_cast<Address>(cache.location())); 539 ASSERT(proxy->proxy() == reinterpret_cast<Address>(cache.location()));
538 proxy->set_proxy(0); 540 proxy->set_proxy(0);
539 Isolate::Current()->global_handles()->Destroy(cache.location()); 541 Isolate* isolate = Isolate::Current();
540 COUNTERS->script_wrappers()->Decrement(); 542 isolate->global_handles()->Destroy(cache.location());
543 isolate->counters()->script_wrappers()->Decrement();
541 } 544 }
542 545
543 546
544 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { 547 Handle<JSValue> GetScriptWrapper(Handle<Script> script) {
545 Isolate* isolate = Isolate::Current();
546 if (script->wrapper()->proxy() != NULL) { 548 if (script->wrapper()->proxy() != NULL) {
547 // Return the script wrapper directly from the cache. 549 // Return the script wrapper directly from the cache.
548 return Handle<JSValue>( 550 return Handle<JSValue>(
549 reinterpret_cast<JSValue**>(script->wrapper()->proxy())); 551 reinterpret_cast<JSValue**>(script->wrapper()->proxy()));
550 } 552 }
551 553 Isolate* isolate = Isolate::Current();
552 // Construct a new script wrapper. 554 // Construct a new script wrapper.
553 isolate->counters()->script_wrappers()->Increment(); 555 isolate->counters()->script_wrappers()->Increment();
554 Handle<JSFunction> constructor = isolate->script_function(); 556 Handle<JSFunction> constructor = isolate->script_function();
555 Handle<JSValue> result = 557 Handle<JSValue> result =
556 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); 558 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor));
557 result->set_value(*script); 559 result->set_value(*script);
558 560
559 // Create a new weak global handle and use it to cache the wrapper 561 // Create a new weak global handle and use it to cache the wrapper
560 // for future use. The cache will automatically be cleared by the 562 // for future use. The cache will automatically be cleared by the
561 // garbage collector when it is not used anymore. 563 // garbage collector when it is not used anymore.
562 Handle<Object> handle = isolate->global_handles()->Create(*result); 564 Handle<Object> handle = isolate->global_handles()->Create(*result);
563 isolate->global_handles()->MakeWeak(handle.location(), NULL, 565 isolate->global_handles()->MakeWeak(handle.location(), NULL,
564 &ClearWrapperCache); 566 &ClearWrapperCache);
565 script->wrapper()->set_proxy(reinterpret_cast<Address>(handle.location())); 567 script->wrapper()->set_proxy(reinterpret_cast<Address>(handle.location()));
566 return result; 568 return result;
567 } 569 }
568 570
569 571
570 // Init line_ends array with code positions of line ends inside script 572 // Init line_ends array with code positions of line ends inside script
571 // source. 573 // source.
572 void InitScriptLineEnds(Handle<Script> script) { 574 void InitScriptLineEnds(Handle<Script> script) {
573 if (!script->line_ends()->IsUndefined()) return; 575 if (!script->line_ends()->IsUndefined()) return;
574 576
577 Isolate* isolate = script->GetIsolate();
578
575 if (!script->source()->IsString()) { 579 if (!script->source()->IsString()) {
576 ASSERT(script->source()->IsUndefined()); 580 ASSERT(script->source()->IsUndefined());
577 Handle<FixedArray> empty = 581 Handle<FixedArray> empty = isolate->factory()->NewFixedArray(0);
578 script->GetIsolate()->factory()->NewFixedArray(0);
579 script->set_line_ends(*empty); 582 script->set_line_ends(*empty);
580 ASSERT(script->line_ends()->IsFixedArray()); 583 ASSERT(script->line_ends()->IsFixedArray());
581 return; 584 return;
582 } 585 }
583 586
584 Handle<String> src(String::cast(script->source())); 587 Handle<String> src(String::cast(script->source()), isolate);
585 588
586 Handle<FixedArray> array = CalculateLineEnds(src, true); 589 Handle<FixedArray> array = CalculateLineEnds(src, true);
587 590
588 if (*array != HEAP->empty_fixed_array()) { 591 if (*array != isolate->heap()->empty_fixed_array()) {
589 array->set_map(HEAP->fixed_cow_array_map()); 592 array->set_map(isolate->heap()->fixed_cow_array_map());
590 } 593 }
591 594
592 script->set_line_ends(*array); 595 script->set_line_ends(*array);
593 ASSERT(script->line_ends()->IsFixedArray()); 596 ASSERT(script->line_ends()->IsFixedArray());
594 } 597 }
595 598
596 599
597 template <typename SourceChar> 600 template <typename SourceChar>
598 static void CalculateLineEnds(Isolate* isolate, 601 static void CalculateLineEnds(Isolate* isolate,
599 List<int>* line_ends, 602 List<int>* line_ends,
(...skipping 18 matching lines...) Expand all
618 } 621 }
619 622
620 623
621 Handle<FixedArray> CalculateLineEnds(Handle<String> src, 624 Handle<FixedArray> CalculateLineEnds(Handle<String> src,
622 bool with_last_line) { 625 bool with_last_line) {
623 src = FlattenGetString(src); 626 src = FlattenGetString(src);
624 // Rough estimate of line count based on a roughly estimated average 627 // Rough estimate of line count based on a roughly estimated average
625 // length of (unpacked) code. 628 // length of (unpacked) code.
626 int line_count_estimate = src->length() >> 4; 629 int line_count_estimate = src->length() >> 4;
627 List<int> line_ends(line_count_estimate); 630 List<int> line_ends(line_count_estimate);
631 Isolate* isolate = src->GetIsolate();
628 { 632 {
629 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid. 633 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid.
630 Isolate* isolate = src->GetIsolate();
631 // Dispatch on type of strings. 634 // Dispatch on type of strings.
632 if (src->IsAsciiRepresentation()) { 635 if (src->IsAsciiRepresentation()) {
633 CalculateLineEnds(isolate, 636 CalculateLineEnds(isolate,
634 &line_ends, 637 &line_ends,
635 src->ToAsciiVector(), 638 src->ToAsciiVector(),
636 with_last_line); 639 with_last_line);
637 } else { 640 } else {
638 CalculateLineEnds(isolate, 641 CalculateLineEnds(isolate,
639 &line_ends, 642 &line_ends,
640 src->ToUC16Vector(), 643 src->ToUC16Vector(),
641 with_last_line); 644 with_last_line);
642 } 645 }
643 } 646 }
644 int line_count = line_ends.length(); 647 int line_count = line_ends.length();
645 Handle<FixedArray> array = FACTORY->NewFixedArray(line_count); 648 Handle<FixedArray> array = isolate->factory()->NewFixedArray(line_count);
646 for (int i = 0; i < line_count; i++) { 649 for (int i = 0; i < line_count; i++) {
647 array->set(i, Smi::FromInt(line_ends[i])); 650 array->set(i, Smi::FromInt(line_ends[i]));
648 } 651 }
649 return array; 652 return array;
650 } 653 }
651 654
652 655
653 // Convert code position into line number. 656 // Convert code position into line number.
654 int GetScriptLineNumber(Handle<Script> script, int code_pos) { 657 int GetScriptLineNumber(Handle<Script> script, int code_pos) {
655 InitScriptLineEnds(script); 658 InitScriptLineEnds(script);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 760 }
758 return true; 761 return true;
759 } 762 }
760 763
761 764
762 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object, 765 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object,
763 KeyCollectionType type) { 766 KeyCollectionType type) {
764 USE(ContainsOnlyValidKeys); 767 USE(ContainsOnlyValidKeys);
765 Isolate* isolate = object->GetIsolate(); 768 Isolate* isolate = object->GetIsolate();
766 Handle<FixedArray> content = isolate->factory()->empty_fixed_array(); 769 Handle<FixedArray> content = isolate->factory()->empty_fixed_array();
767 Handle<JSObject> arguments_boilerplate = 770 Handle<JSObject> arguments_boilerplate = Handle<JSObject>(
768 Handle<JSObject>( 771 isolate->context()->global_context()->arguments_boilerplate(),
769 isolate->context()->global_context()->arguments_boilerplate()); 772 isolate);
770 Handle<JSFunction> arguments_function = 773 Handle<JSFunction> arguments_function = Handle<JSFunction>(
771 Handle<JSFunction>( 774 JSFunction::cast(arguments_boilerplate->map()->constructor()),
772 JSFunction::cast(arguments_boilerplate->map()->constructor())); 775 isolate);
773 776
774 // Only collect keys if access is permitted. 777 // Only collect keys if access is permitted.
775 for (Handle<Object> p = object; 778 for (Handle<Object> p = object;
776 *p != isolate->heap()->null_value(); 779 *p != isolate->heap()->null_value();
777 p = Handle<Object>(p->GetPrototype())) { 780 p = Handle<Object>(p->GetPrototype(), isolate)) {
778 Handle<JSObject> current(JSObject::cast(*p)); 781 Handle<JSObject> current(JSObject::cast(*p), isolate);
779 782
780 // Check access rights if required. 783 // Check access rights if required.
781 if (current->IsAccessCheckNeeded() && 784 if (current->IsAccessCheckNeeded() &&
782 !isolate->MayNamedAccess(*current, 785 !isolate->MayNamedAccess(*current,
783 isolate->heap()->undefined_value(), 786 isolate->heap()->undefined_value(),
784 v8::ACCESS_KEYS)) { 787 v8::ACCESS_KEYS)) {
785 isolate->ReportFailedAccessCheck(*current, v8::ACCESS_KEYS); 788 isolate->ReportFailedAccessCheck(*current, v8::ACCESS_KEYS);
786 break; 789 break;
787 } 790 }
788 791
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 854
852 855
853 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, 856 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object,
854 bool cache_result) { 857 bool cache_result) {
855 int index = 0; 858 int index = 0;
856 Isolate* isolate = object->GetIsolate(); 859 Isolate* isolate = object->GetIsolate();
857 if (object->HasFastProperties()) { 860 if (object->HasFastProperties()) {
858 if (object->map()->instance_descriptors()->HasEnumCache()) { 861 if (object->map()->instance_descriptors()->HasEnumCache()) {
859 isolate->counters()->enum_cache_hits()->Increment(); 862 isolate->counters()->enum_cache_hits()->Increment();
860 DescriptorArray* desc = object->map()->instance_descriptors(); 863 DescriptorArray* desc = object->map()->instance_descriptors();
861 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache())); 864 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache()),
865 isolate);
862 } 866 }
863 isolate->counters()->enum_cache_misses()->Increment(); 867 isolate->counters()->enum_cache_misses()->Increment();
864 int num_enum = object->NumberOfEnumProperties(); 868 int num_enum = object->NumberOfEnumProperties();
865 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); 869 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
866 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); 870 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
867 Handle<DescriptorArray> descs = 871 Handle<DescriptorArray> descs =
868 Handle<DescriptorArray>(object->map()->instance_descriptors()); 872 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate);
869 for (int i = 0; i < descs->number_of_descriptors(); i++) { 873 for (int i = 0; i < descs->number_of_descriptors(); i++) {
870 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) { 874 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) {
871 (*storage)->set(index, descs->GetKey(i)); 875 (*storage)->set(index, descs->GetKey(i));
872 PropertyDetails details(descs->GetDetails(i)); 876 PropertyDetails details(descs->GetDetails(i));
873 (*sort_array)->set(index, Smi::FromInt(details.index())); 877 (*sort_array)->set(index, Smi::FromInt(details.index()));
874 index++; 878 index++;
875 } 879 }
876 } 880 }
877 (*storage)->SortPairs(*sort_array, sort_array->length()); 881 (*storage)->SortPairs(*sort_array, sort_array->length());
878 if (cache_result) { 882 if (cache_result) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 956
953 bool CompileOptimized(Handle<JSFunction> function, 957 bool CompileOptimized(Handle<JSFunction> function,
954 int osr_ast_id, 958 int osr_ast_id,
955 ClearExceptionFlag flag) { 959 ClearExceptionFlag flag) {
956 CompilationInfo info(function); 960 CompilationInfo info(function);
957 info.SetOptimizing(osr_ast_id); 961 info.SetOptimizing(osr_ast_id);
958 return CompileLazyHelper(&info, flag); 962 return CompileLazyHelper(&info, flag);
959 } 963 }
960 964
961 } } // namespace v8::internal 965 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698