OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 Object* key = constant_properties->get(p); | 164 Object* key = constant_properties->get(p); |
165 uint32_t element_index = 0; | 165 uint32_t element_index = 0; |
166 if (key->IsInternalizedString()) { | 166 if (key->IsInternalizedString()) { |
167 number_of_string_keys++; | 167 number_of_string_keys++; |
168 } else if (key->ToArrayIndex(&element_index)) { | 168 } else if (key->ToArrayIndex(&element_index)) { |
169 // An index key does not require space in the property backing store. | 169 // An index key does not require space in the property backing store. |
170 number_of_properties--; | 170 number_of_properties--; |
171 } else { | 171 } else { |
172 // Bail out as a non-internalized-string non-index key makes caching | 172 // Bail out as a non-internalized-string non-index key makes caching |
173 // impossible. | 173 // impossible. |
174 // ASSERT to make sure that the if condition after the loop is false. | 174 // DCHECK to make sure that the if condition after the loop is false. |
175 ASSERT(number_of_string_keys != number_of_properties); | 175 DCHECK(number_of_string_keys != number_of_properties); |
176 break; | 176 break; |
177 } | 177 } |
178 } | 178 } |
179 // If we only have internalized strings and array indices among keys then we | 179 // If we only have internalized strings and array indices among keys then we |
180 // can use the map cache in the native context. | 180 // can use the map cache in the native context. |
181 const int kMaxKeys = 10; | 181 const int kMaxKeys = 10; |
182 if ((number_of_string_keys == number_of_properties) && | 182 if ((number_of_string_keys == number_of_properties) && |
183 (number_of_string_keys < kMaxKeys)) { | 183 (number_of_string_keys < kMaxKeys)) { |
184 // Create the fixed array with the key. | 184 // Create the fixed array with the key. |
185 Handle<FixedArray> keys = | 185 Handle<FixedArray> keys = |
186 isolate->factory()->NewFixedArray(number_of_string_keys); | 186 isolate->factory()->NewFixedArray(number_of_string_keys); |
187 if (number_of_string_keys > 0) { | 187 if (number_of_string_keys > 0) { |
188 int index = 0; | 188 int index = 0; |
189 for (int p = 0; p < properties_length; p += 2) { | 189 for (int p = 0; p < properties_length; p += 2) { |
190 Object* key = constant_properties->get(p); | 190 Object* key = constant_properties->get(p); |
191 if (key->IsInternalizedString()) { | 191 if (key->IsInternalizedString()) { |
192 keys->set(index++, key); | 192 keys->set(index++, key); |
193 } | 193 } |
194 } | 194 } |
195 ASSERT(index == number_of_string_keys); | 195 DCHECK(index == number_of_string_keys); |
196 } | 196 } |
197 *is_result_from_cache = true; | 197 *is_result_from_cache = true; |
198 return isolate->factory()->ObjectLiteralMapFromCache(context, keys); | 198 return isolate->factory()->ObjectLiteralMapFromCache(context, keys); |
199 } | 199 } |
200 *is_result_from_cache = false; | 200 *is_result_from_cache = false; |
201 return Map::Create(handle(context->object_function()), number_of_properties); | 201 return Map::Create(handle(context->object_function()), number_of_properties); |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( | 205 MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 MaybeHandle<Object> maybe_result; | 269 MaybeHandle<Object> maybe_result; |
270 uint32_t element_index = 0; | 270 uint32_t element_index = 0; |
271 if (key->IsInternalizedString()) { | 271 if (key->IsInternalizedString()) { |
272 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { | 272 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
273 // Array index as string (uint32). | 273 // Array index as string (uint32). |
274 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); | 274 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); |
275 maybe_result = | 275 maybe_result = |
276 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); | 276 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); |
277 } else { | 277 } else { |
278 Handle<String> name(String::cast(*key)); | 278 Handle<String> name(String::cast(*key)); |
279 ASSERT(!name->AsArrayIndex(&element_index)); | 279 DCHECK(!name->AsArrayIndex(&element_index)); |
280 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( | 280 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( |
281 boilerplate, name, value, NONE); | 281 boilerplate, name, value, NONE); |
282 } | 282 } |
283 } else if (key->ToArrayIndex(&element_index)) { | 283 } else if (key->ToArrayIndex(&element_index)) { |
284 // Array index (uint32). | 284 // Array index (uint32). |
285 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); | 285 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); |
286 maybe_result = | 286 maybe_result = |
287 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); | 287 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); |
288 } else { | 288 } else { |
289 // Non-uint32 number. | 289 // Non-uint32 number. |
290 ASSERT(key->IsNumber()); | 290 DCHECK(key->IsNumber()); |
291 double num = key->Number(); | 291 double num = key->Number(); |
292 char arr[100]; | 292 char arr[100]; |
293 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 293 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
294 const char* str = DoubleToCString(num, buffer); | 294 const char* str = DoubleToCString(num, buffer); |
295 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); | 295 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); |
296 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name, | 296 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name, |
297 value, NONE); | 297 value, NONE); |
298 } | 298 } |
299 // If setting the property on the boilerplate throws an | 299 // If setting the property on the boilerplate throws an |
300 // exception, the exception is converted to an empty handle in | 300 // exception, the exception is converted to an empty handle in |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 Handle<JSArray> object = Handle<JSArray>::cast( | 350 Handle<JSArray> object = Handle<JSArray>::cast( |
351 isolate->factory()->NewJSObject(constructor, pretenure_flag)); | 351 isolate->factory()->NewJSObject(constructor, pretenure_flag)); |
352 | 352 |
353 ElementsKind constant_elements_kind = | 353 ElementsKind constant_elements_kind = |
354 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); | 354 static_cast<ElementsKind>(Smi::cast(elements->get(0))->value()); |
355 Handle<FixedArrayBase> constant_elements_values( | 355 Handle<FixedArrayBase> constant_elements_values( |
356 FixedArrayBase::cast(elements->get(1))); | 356 FixedArrayBase::cast(elements->get(1))); |
357 | 357 |
358 { DisallowHeapAllocation no_gc; | 358 { DisallowHeapAllocation no_gc; |
359 ASSERT(IsFastElementsKind(constant_elements_kind)); | 359 DCHECK(IsFastElementsKind(constant_elements_kind)); |
360 Context* native_context = isolate->context()->native_context(); | 360 Context* native_context = isolate->context()->native_context(); |
361 Object* maps_array = native_context->js_array_maps(); | 361 Object* maps_array = native_context->js_array_maps(); |
362 ASSERT(!maps_array->IsUndefined()); | 362 DCHECK(!maps_array->IsUndefined()); |
363 Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind); | 363 Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind); |
364 object->set_map(Map::cast(map)); | 364 object->set_map(Map::cast(map)); |
365 } | 365 } |
366 | 366 |
367 Handle<FixedArrayBase> copied_elements_values; | 367 Handle<FixedArrayBase> copied_elements_values; |
368 if (IsFastDoubleElementsKind(constant_elements_kind)) { | 368 if (IsFastDoubleElementsKind(constant_elements_kind)) { |
369 copied_elements_values = isolate->factory()->CopyFixedDoubleArray( | 369 copied_elements_values = isolate->factory()->CopyFixedDoubleArray( |
370 Handle<FixedDoubleArray>::cast(constant_elements_values)); | 370 Handle<FixedDoubleArray>::cast(constant_elements_values)); |
371 } else { | 371 } else { |
372 ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind)); | 372 DCHECK(IsFastSmiOrObjectElementsKind(constant_elements_kind)); |
373 const bool is_cow = | 373 const bool is_cow = |
374 (constant_elements_values->map() == | 374 (constant_elements_values->map() == |
375 isolate->heap()->fixed_cow_array_map()); | 375 isolate->heap()->fixed_cow_array_map()); |
376 if (is_cow) { | 376 if (is_cow) { |
377 copied_elements_values = constant_elements_values; | 377 copied_elements_values = constant_elements_values; |
378 #if DEBUG | 378 #if DEBUG |
379 Handle<FixedArray> fixed_array_values = | 379 Handle<FixedArray> fixed_array_values = |
380 Handle<FixedArray>::cast(copied_elements_values); | 380 Handle<FixedArray>::cast(copied_elements_values); |
381 for (int i = 0; i < fixed_array_values->length(); i++) { | 381 for (int i = 0; i < fixed_array_values->length(); i++) { |
382 ASSERT(!fixed_array_values->get(i)->IsFixedArray()); | 382 DCHECK(!fixed_array_values->get(i)->IsFixedArray()); |
383 } | 383 } |
384 #endif | 384 #endif |
385 } else { | 385 } else { |
386 Handle<FixedArray> fixed_array_values = | 386 Handle<FixedArray> fixed_array_values = |
387 Handle<FixedArray>::cast(constant_elements_values); | 387 Handle<FixedArray>::cast(constant_elements_values); |
388 Handle<FixedArray> fixed_array_values_copy = | 388 Handle<FixedArray> fixed_array_values_copy = |
389 isolate->factory()->CopyFixedArray(fixed_array_values); | 389 isolate->factory()->CopyFixedArray(fixed_array_values); |
390 copied_elements_values = fixed_array_values_copy; | 390 copied_elements_values = fixed_array_values_copy; |
391 for (int i = 0; i < fixed_array_values->length(); i++) { | 391 for (int i = 0; i < fixed_array_values->length(); i++) { |
392 if (fixed_array_values->get(i)->IsFixedArray()) { | 392 if (fixed_array_values->get(i)->IsFixedArray()) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 isolate, literals, elements); | 435 isolate, literals, elements); |
436 default: | 436 default: |
437 UNREACHABLE(); | 437 UNREACHABLE(); |
438 return MaybeHandle<Object>(); | 438 return MaybeHandle<Object>(); |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 | 442 |
443 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { | 443 RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { |
444 HandleScope scope(isolate); | 444 HandleScope scope(isolate); |
445 ASSERT(args.length() == 4); | 445 DCHECK(args.length() == 4); |
446 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 446 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
447 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 447 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
448 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 448 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
449 CONVERT_SMI_ARG_CHECKED(flags, 3); | 449 CONVERT_SMI_ARG_CHECKED(flags, 3); |
450 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 450 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
451 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 451 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
452 | 452 |
453 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); | 453 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); |
454 | 454 |
455 // Check if boilerplate exists. If not, create it first. | 455 // Check if boilerplate exists. If not, create it first. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 496 |
497 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( | 497 MUST_USE_RESULT static MaybeHandle<AllocationSite> GetLiteralAllocationSite( |
498 Isolate* isolate, | 498 Isolate* isolate, |
499 Handle<FixedArray> literals, | 499 Handle<FixedArray> literals, |
500 int literals_index, | 500 int literals_index, |
501 Handle<FixedArray> elements) { | 501 Handle<FixedArray> elements) { |
502 // Check if boilerplate exists. If not, create it first. | 502 // Check if boilerplate exists. If not, create it first. |
503 Handle<Object> literal_site(literals->get(literals_index), isolate); | 503 Handle<Object> literal_site(literals->get(literals_index), isolate); |
504 Handle<AllocationSite> site; | 504 Handle<AllocationSite> site; |
505 if (*literal_site == isolate->heap()->undefined_value()) { | 505 if (*literal_site == isolate->heap()->undefined_value()) { |
506 ASSERT(*elements != isolate->heap()->empty_fixed_array()); | 506 DCHECK(*elements != isolate->heap()->empty_fixed_array()); |
507 Handle<Object> boilerplate; | 507 Handle<Object> boilerplate; |
508 ASSIGN_RETURN_ON_EXCEPTION( | 508 ASSIGN_RETURN_ON_EXCEPTION( |
509 isolate, boilerplate, | 509 isolate, boilerplate, |
510 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements), | 510 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements), |
511 AllocationSite); | 511 AllocationSite); |
512 | 512 |
513 AllocationSiteCreationContext creation_context(isolate); | 513 AllocationSiteCreationContext creation_context(isolate); |
514 site = creation_context.EnterNewScope(); | 514 site = creation_context.EnterNewScope(); |
515 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate), | 515 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate), |
516 &creation_context).is_null()) { | 516 &creation_context).is_null()) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 : JSObject::kObjectIsShallow; | 549 : JSObject::kObjectIsShallow; |
550 MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, | 550 MaybeHandle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, |
551 hints); | 551 hints); |
552 usage_context.ExitScope(site, boilerplate); | 552 usage_context.ExitScope(site, boilerplate); |
553 return copy; | 553 return copy; |
554 } | 554 } |
555 | 555 |
556 | 556 |
557 RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) { | 557 RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) { |
558 HandleScope scope(isolate); | 558 HandleScope scope(isolate); |
559 ASSERT(args.length() == 4); | 559 DCHECK(args.length() == 4); |
560 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 560 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
561 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 561 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
563 CONVERT_SMI_ARG_CHECKED(flags, 3); | 563 CONVERT_SMI_ARG_CHECKED(flags, 3); |
564 | 564 |
565 Handle<JSObject> result; | 565 Handle<JSObject> result; |
566 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 566 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
567 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 567 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
568 flags)); | 568 flags)); |
569 return *result; | 569 return *result; |
570 } | 570 } |
571 | 571 |
572 | 572 |
573 RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) { | 573 RUNTIME_FUNCTION(Runtime_CreateArrayLiteralStubBailout) { |
574 HandleScope scope(isolate); | 574 HandleScope scope(isolate); |
575 ASSERT(args.length() == 3); | 575 DCHECK(args.length() == 3); |
576 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 576 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
577 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 577 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
578 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 578 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
579 | 579 |
580 Handle<JSObject> result; | 580 Handle<JSObject> result; |
581 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 581 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
582 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 582 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
583 ArrayLiteral::kShallowElements)); | 583 ArrayLiteral::kShallowElements)); |
584 return *result; | 584 return *result; |
585 } | 585 } |
586 | 586 |
587 | 587 |
588 RUNTIME_FUNCTION(Runtime_CreateSymbol) { | 588 RUNTIME_FUNCTION(Runtime_CreateSymbol) { |
589 HandleScope scope(isolate); | 589 HandleScope scope(isolate); |
590 ASSERT(args.length() == 1); | 590 DCHECK(args.length() == 1); |
591 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 591 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
592 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 592 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
593 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); | 593 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); |
594 if (name->IsString()) symbol->set_name(*name); | 594 if (name->IsString()) symbol->set_name(*name); |
595 return *symbol; | 595 return *symbol; |
596 } | 596 } |
597 | 597 |
598 | 598 |
599 RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) { | 599 RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) { |
600 HandleScope scope(isolate); | 600 HandleScope scope(isolate); |
601 ASSERT(args.length() == 1); | 601 DCHECK(args.length() == 1); |
602 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 602 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
603 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 603 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
604 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); | 604 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); |
605 if (name->IsString()) symbol->set_name(*name); | 605 if (name->IsString()) symbol->set_name(*name); |
606 return *symbol; | 606 return *symbol; |
607 } | 607 } |
608 | 608 |
609 | 609 |
610 RUNTIME_FUNCTION(Runtime_CreateGlobalPrivateSymbol) { | 610 RUNTIME_FUNCTION(Runtime_CreateGlobalPrivateSymbol) { |
611 HandleScope scope(isolate); | 611 HandleScope scope(isolate); |
612 ASSERT(args.length() == 1); | 612 DCHECK(args.length() == 1); |
613 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 613 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
614 Handle<JSObject> registry = isolate->GetSymbolRegistry(); | 614 Handle<JSObject> registry = isolate->GetSymbolRegistry(); |
615 Handle<String> part = isolate->factory()->private_intern_string(); | 615 Handle<String> part = isolate->factory()->private_intern_string(); |
616 Handle<Object> privates; | 616 Handle<Object> privates; |
617 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 617 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
618 isolate, privates, Object::GetPropertyOrElement(registry, part)); | 618 isolate, privates, Object::GetPropertyOrElement(registry, part)); |
619 Handle<Object> symbol; | 619 Handle<Object> symbol; |
620 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 620 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
621 isolate, symbol, Object::GetPropertyOrElement(privates, name)); | 621 isolate, symbol, Object::GetPropertyOrElement(privates, name)); |
622 if (!symbol->IsSymbol()) { | 622 if (!symbol->IsSymbol()) { |
623 ASSERT(symbol->IsUndefined()); | 623 DCHECK(symbol->IsUndefined()); |
624 symbol = isolate->factory()->NewPrivateSymbol(); | 624 symbol = isolate->factory()->NewPrivateSymbol(); |
625 Handle<Symbol>::cast(symbol)->set_name(*name); | 625 Handle<Symbol>::cast(symbol)->set_name(*name); |
626 JSObject::SetProperty(Handle<JSObject>::cast(privates), name, symbol, | 626 JSObject::SetProperty(Handle<JSObject>::cast(privates), name, symbol, |
627 STRICT).Assert(); | 627 STRICT).Assert(); |
628 } | 628 } |
629 return *symbol; | 629 return *symbol; |
630 } | 630 } |
631 | 631 |
632 | 632 |
633 RUNTIME_FUNCTION(Runtime_NewSymbolWrapper) { | 633 RUNTIME_FUNCTION(Runtime_NewSymbolWrapper) { |
634 HandleScope scope(isolate); | 634 HandleScope scope(isolate); |
635 ASSERT(args.length() == 1); | 635 DCHECK(args.length() == 1); |
636 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); | 636 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); |
637 return *Object::ToObject(isolate, symbol).ToHandleChecked(); | 637 return *Object::ToObject(isolate, symbol).ToHandleChecked(); |
638 } | 638 } |
639 | 639 |
640 | 640 |
641 RUNTIME_FUNCTION(Runtime_SymbolDescription) { | 641 RUNTIME_FUNCTION(Runtime_SymbolDescription) { |
642 SealHandleScope shs(isolate); | 642 SealHandleScope shs(isolate); |
643 ASSERT(args.length() == 1); | 643 DCHECK(args.length() == 1); |
644 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 644 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
645 return symbol->name(); | 645 return symbol->name(); |
646 } | 646 } |
647 | 647 |
648 | 648 |
649 RUNTIME_FUNCTION(Runtime_SymbolRegistry) { | 649 RUNTIME_FUNCTION(Runtime_SymbolRegistry) { |
650 HandleScope scope(isolate); | 650 HandleScope scope(isolate); |
651 ASSERT(args.length() == 0); | 651 DCHECK(args.length() == 0); |
652 return *isolate->GetSymbolRegistry(); | 652 return *isolate->GetSymbolRegistry(); |
653 } | 653 } |
654 | 654 |
655 | 655 |
656 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { | 656 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { |
657 SealHandleScope shs(isolate); | 657 SealHandleScope shs(isolate); |
658 ASSERT(args.length() == 1); | 658 DCHECK(args.length() == 1); |
659 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 659 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
660 return isolate->heap()->ToBoolean(symbol->is_private()); | 660 return isolate->heap()->ToBoolean(symbol->is_private()); |
661 } | 661 } |
662 | 662 |
663 | 663 |
664 RUNTIME_FUNCTION(Runtime_CreateJSProxy) { | 664 RUNTIME_FUNCTION(Runtime_CreateJSProxy) { |
665 HandleScope scope(isolate); | 665 HandleScope scope(isolate); |
666 ASSERT(args.length() == 2); | 666 DCHECK(args.length() == 2); |
667 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); | 667 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
668 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 668 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
669 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); | 669 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
670 return *isolate->factory()->NewJSProxy(handler, prototype); | 670 return *isolate->factory()->NewJSProxy(handler, prototype); |
671 } | 671 } |
672 | 672 |
673 | 673 |
674 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { | 674 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { |
675 HandleScope scope(isolate); | 675 HandleScope scope(isolate); |
676 ASSERT(args.length() == 4); | 676 DCHECK(args.length() == 4); |
677 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); | 677 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
678 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1); | 678 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1); |
679 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); | 679 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); |
680 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); | 680 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); |
681 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3); | 681 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3); |
682 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); | 682 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
683 return *isolate->factory()->NewJSFunctionProxy( | 683 return *isolate->factory()->NewJSFunctionProxy( |
684 handler, call_trap, construct_trap, prototype); | 684 handler, call_trap, construct_trap, prototype); |
685 } | 685 } |
686 | 686 |
687 | 687 |
688 RUNTIME_FUNCTION(Runtime_IsJSProxy) { | 688 RUNTIME_FUNCTION(Runtime_IsJSProxy) { |
689 SealHandleScope shs(isolate); | 689 SealHandleScope shs(isolate); |
690 ASSERT(args.length() == 1); | 690 DCHECK(args.length() == 1); |
691 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 691 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
692 return isolate->heap()->ToBoolean(obj->IsJSProxy()); | 692 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
693 } | 693 } |
694 | 694 |
695 | 695 |
696 RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) { | 696 RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) { |
697 SealHandleScope shs(isolate); | 697 SealHandleScope shs(isolate); |
698 ASSERT(args.length() == 1); | 698 DCHECK(args.length() == 1); |
699 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 699 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
700 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); | 700 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); |
701 } | 701 } |
702 | 702 |
703 | 703 |
704 RUNTIME_FUNCTION(Runtime_GetHandler) { | 704 RUNTIME_FUNCTION(Runtime_GetHandler) { |
705 SealHandleScope shs(isolate); | 705 SealHandleScope shs(isolate); |
706 ASSERT(args.length() == 1); | 706 DCHECK(args.length() == 1); |
707 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); | 707 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); |
708 return proxy->handler(); | 708 return proxy->handler(); |
709 } | 709 } |
710 | 710 |
711 | 711 |
712 RUNTIME_FUNCTION(Runtime_GetCallTrap) { | 712 RUNTIME_FUNCTION(Runtime_GetCallTrap) { |
713 SealHandleScope shs(isolate); | 713 SealHandleScope shs(isolate); |
714 ASSERT(args.length() == 1); | 714 DCHECK(args.length() == 1); |
715 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 715 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
716 return proxy->call_trap(); | 716 return proxy->call_trap(); |
717 } | 717 } |
718 | 718 |
719 | 719 |
720 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { | 720 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { |
721 SealHandleScope shs(isolate); | 721 SealHandleScope shs(isolate); |
722 ASSERT(args.length() == 1); | 722 DCHECK(args.length() == 1); |
723 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 723 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
724 return proxy->construct_trap(); | 724 return proxy->construct_trap(); |
725 } | 725 } |
726 | 726 |
727 | 727 |
728 RUNTIME_FUNCTION(Runtime_Fix) { | 728 RUNTIME_FUNCTION(Runtime_Fix) { |
729 HandleScope scope(isolate); | 729 HandleScope scope(isolate); |
730 ASSERT(args.length() == 1); | 730 DCHECK(args.length() == 1); |
731 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); | 731 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); |
732 JSProxy::Fix(proxy); | 732 JSProxy::Fix(proxy); |
733 return isolate->heap()->undefined_value(); | 733 return isolate->heap()->undefined_value(); |
734 } | 734 } |
735 | 735 |
736 | 736 |
737 void Runtime::FreeArrayBuffer(Isolate* isolate, | 737 void Runtime::FreeArrayBuffer(Isolate* isolate, |
738 JSArrayBuffer* phantom_array_buffer) { | 738 JSArrayBuffer* phantom_array_buffer) { |
739 if (phantom_array_buffer->should_be_freed()) { | 739 if (phantom_array_buffer->should_be_freed()) { |
740 ASSERT(phantom_array_buffer->is_external()); | 740 DCHECK(phantom_array_buffer->is_external()); |
741 free(phantom_array_buffer->backing_store()); | 741 free(phantom_array_buffer->backing_store()); |
742 } | 742 } |
743 if (phantom_array_buffer->is_external()) return; | 743 if (phantom_array_buffer->is_external()) return; |
744 | 744 |
745 size_t allocated_length = NumberToSize( | 745 size_t allocated_length = NumberToSize( |
746 isolate, phantom_array_buffer->byte_length()); | 746 isolate, phantom_array_buffer->byte_length()); |
747 | 747 |
748 reinterpret_cast<v8::Isolate*>(isolate) | 748 reinterpret_cast<v8::Isolate*>(isolate) |
749 ->AdjustAmountOfExternalAllocatedMemory( | 749 ->AdjustAmountOfExternalAllocatedMemory( |
750 -static_cast<int64_t>(allocated_length)); | 750 -static_cast<int64_t>(allocated_length)); |
751 CHECK(V8::ArrayBufferAllocator() != NULL); | 751 CHECK(V8::ArrayBufferAllocator() != NULL); |
752 V8::ArrayBufferAllocator()->Free( | 752 V8::ArrayBufferAllocator()->Free( |
753 phantom_array_buffer->backing_store(), | 753 phantom_array_buffer->backing_store(), |
754 allocated_length); | 754 allocated_length); |
755 } | 755 } |
756 | 756 |
757 | 757 |
758 void Runtime::SetupArrayBuffer(Isolate* isolate, | 758 void Runtime::SetupArrayBuffer(Isolate* isolate, |
759 Handle<JSArrayBuffer> array_buffer, | 759 Handle<JSArrayBuffer> array_buffer, |
760 bool is_external, | 760 bool is_external, |
761 void* data, | 761 void* data, |
762 size_t allocated_length) { | 762 size_t allocated_length) { |
763 ASSERT(array_buffer->GetInternalFieldCount() == | 763 DCHECK(array_buffer->GetInternalFieldCount() == |
764 v8::ArrayBuffer::kInternalFieldCount); | 764 v8::ArrayBuffer::kInternalFieldCount); |
765 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { | 765 for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { |
766 array_buffer->SetInternalField(i, Smi::FromInt(0)); | 766 array_buffer->SetInternalField(i, Smi::FromInt(0)); |
767 } | 767 } |
768 array_buffer->set_backing_store(data); | 768 array_buffer->set_backing_store(data); |
769 array_buffer->set_flag(Smi::FromInt(0)); | 769 array_buffer->set_flag(Smi::FromInt(0)); |
770 array_buffer->set_is_external(is_external); | 770 array_buffer->set_is_external(is_external); |
771 | 771 |
772 Handle<Object> byte_length = | 772 Handle<Object> byte_length = |
773 isolate->factory()->NewNumberFromSize(allocated_length); | 773 isolate->factory()->NewNumberFromSize(allocated_length); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 UNREACHABLE(); | 821 UNREACHABLE(); |
822 } | 822 } |
823 view_obj = handle(view->weak_next(), isolate); | 823 view_obj = handle(view->weak_next(), isolate); |
824 } | 824 } |
825 array_buffer->Neuter(); | 825 array_buffer->Neuter(); |
826 } | 826 } |
827 | 827 |
828 | 828 |
829 RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) { | 829 RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) { |
830 HandleScope scope(isolate); | 830 HandleScope scope(isolate); |
831 ASSERT(args.length() == 2); | 831 DCHECK(args.length() == 2); |
832 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); | 832 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); |
833 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); | 833 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); |
834 if (!holder->byte_length()->IsUndefined()) { | 834 if (!holder->byte_length()->IsUndefined()) { |
835 // ArrayBuffer is already initialized; probably a fuzz test. | 835 // ArrayBuffer is already initialized; probably a fuzz test. |
836 return *holder; | 836 return *holder; |
837 } | 837 } |
838 size_t allocated_length = 0; | 838 size_t allocated_length = 0; |
839 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { | 839 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { |
840 return isolate->Throw( | 840 return isolate->Throw( |
841 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 841 *isolate->factory()->NewRangeError("invalid_array_buffer_length", |
842 HandleVector<Object>(NULL, 0))); | 842 HandleVector<Object>(NULL, 0))); |
843 } | 843 } |
844 if (!Runtime::SetupArrayBufferAllocatingData(isolate, | 844 if (!Runtime::SetupArrayBufferAllocatingData(isolate, |
845 holder, allocated_length)) { | 845 holder, allocated_length)) { |
846 return isolate->Throw( | 846 return isolate->Throw( |
847 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 847 *isolate->factory()->NewRangeError("invalid_array_buffer_length", |
848 HandleVector<Object>(NULL, 0))); | 848 HandleVector<Object>(NULL, 0))); |
849 } | 849 } |
850 return *holder; | 850 return *holder; |
851 } | 851 } |
852 | 852 |
853 | 853 |
854 RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { | 854 RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { |
855 SealHandleScope shs(isolate); | 855 SealHandleScope shs(isolate); |
856 ASSERT(args.length() == 1); | 856 DCHECK(args.length() == 1); |
857 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); | 857 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); |
858 return holder->byte_length(); | 858 return holder->byte_length(); |
859 } | 859 } |
860 | 860 |
861 | 861 |
862 RUNTIME_FUNCTION(Runtime_ArrayBufferSliceImpl) { | 862 RUNTIME_FUNCTION(Runtime_ArrayBufferSliceImpl) { |
863 HandleScope scope(isolate); | 863 HandleScope scope(isolate); |
864 ASSERT(args.length() == 3); | 864 DCHECK(args.length() == 3); |
865 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); | 865 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); |
866 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); | 866 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); |
867 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); | 867 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); |
868 RUNTIME_ASSERT(!source.is_identical_to(target)); | 868 RUNTIME_ASSERT(!source.is_identical_to(target)); |
869 size_t start = 0; | 869 size_t start = 0; |
870 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); | 870 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); |
871 size_t target_length = NumberToSize(isolate, target->byte_length()); | 871 size_t target_length = NumberToSize(isolate, target->byte_length()); |
872 | 872 |
873 if (target_length == 0) return isolate->heap()->undefined_value(); | 873 if (target_length == 0) return isolate->heap()->undefined_value(); |
874 | 874 |
875 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); | 875 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); |
876 RUNTIME_ASSERT(start <= source_byte_length); | 876 RUNTIME_ASSERT(start <= source_byte_length); |
877 RUNTIME_ASSERT(source_byte_length - start >= target_length); | 877 RUNTIME_ASSERT(source_byte_length - start >= target_length); |
878 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); | 878 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); |
879 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); | 879 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); |
880 CopyBytes(target_data, source_data + start, target_length); | 880 CopyBytes(target_data, source_data + start, target_length); |
881 return isolate->heap()->undefined_value(); | 881 return isolate->heap()->undefined_value(); |
882 } | 882 } |
883 | 883 |
884 | 884 |
885 RUNTIME_FUNCTION(Runtime_ArrayBufferIsView) { | 885 RUNTIME_FUNCTION(Runtime_ArrayBufferIsView) { |
886 HandleScope scope(isolate); | 886 HandleScope scope(isolate); |
887 ASSERT(args.length() == 1); | 887 DCHECK(args.length() == 1); |
888 CONVERT_ARG_CHECKED(Object, object, 0); | 888 CONVERT_ARG_CHECKED(Object, object, 0); |
889 return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); | 889 return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); |
890 } | 890 } |
891 | 891 |
892 | 892 |
893 RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) { | 893 RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) { |
894 HandleScope scope(isolate); | 894 HandleScope scope(isolate); |
895 ASSERT(args.length() == 1); | 895 DCHECK(args.length() == 1); |
896 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); | 896 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); |
897 if (array_buffer->backing_store() == NULL) { | 897 if (array_buffer->backing_store() == NULL) { |
898 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); | 898 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); |
899 return isolate->heap()->undefined_value(); | 899 return isolate->heap()->undefined_value(); |
900 } | 900 } |
901 ASSERT(!array_buffer->is_external()); | 901 DCHECK(!array_buffer->is_external()); |
902 void* backing_store = array_buffer->backing_store(); | 902 void* backing_store = array_buffer->backing_store(); |
903 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); | 903 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); |
904 array_buffer->set_is_external(true); | 904 array_buffer->set_is_external(true); |
905 Runtime::NeuterArrayBuffer(array_buffer); | 905 Runtime::NeuterArrayBuffer(array_buffer); |
906 V8::ArrayBufferAllocator()->Free(backing_store, byte_length); | 906 V8::ArrayBufferAllocator()->Free(backing_store, byte_length); |
907 return isolate->heap()->undefined_value(); | 907 return isolate->heap()->undefined_value(); |
908 } | 908 } |
909 | 909 |
910 | 910 |
911 void Runtime::ArrayIdToTypeAndSize( | 911 void Runtime::ArrayIdToTypeAndSize( |
(...skipping 15 matching lines...) Expand all Loading... |
927 #undef ARRAY_ID_CASE | 927 #undef ARRAY_ID_CASE |
928 | 928 |
929 default: | 929 default: |
930 UNREACHABLE(); | 930 UNREACHABLE(); |
931 } | 931 } |
932 } | 932 } |
933 | 933 |
934 | 934 |
935 RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) { | 935 RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) { |
936 HandleScope scope(isolate); | 936 HandleScope scope(isolate); |
937 ASSERT(args.length() == 5); | 937 DCHECK(args.length() == 5); |
938 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 938 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
939 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 939 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
940 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); | 940 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); |
941 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3); | 941 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3); |
942 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4); | 942 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4); |
943 | 943 |
944 RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST && | 944 RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST && |
945 arrayId <= Runtime::ARRAY_ID_LAST); | 945 arrayId <= Runtime::ARRAY_ID_LAST); |
946 | 946 |
947 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 947 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
(...skipping 27 matching lines...) Expand all Loading... |
975 size_t length = byte_length / element_size; | 975 size_t length = byte_length / element_size; |
976 | 976 |
977 if (length > static_cast<unsigned>(Smi::kMaxValue)) { | 977 if (length > static_cast<unsigned>(Smi::kMaxValue)) { |
978 return isolate->Throw( | 978 return isolate->Throw( |
979 *isolate->factory()->NewRangeError("invalid_typed_array_length", | 979 *isolate->factory()->NewRangeError("invalid_typed_array_length", |
980 HandleVector<Object>(NULL, 0))); | 980 HandleVector<Object>(NULL, 0))); |
981 } | 981 } |
982 | 982 |
983 // All checks are done, now we can modify objects. | 983 // All checks are done, now we can modify objects. |
984 | 984 |
985 ASSERT(holder->GetInternalFieldCount() == | 985 DCHECK(holder->GetInternalFieldCount() == |
986 v8::ArrayBufferView::kInternalFieldCount); | 986 v8::ArrayBufferView::kInternalFieldCount); |
987 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 987 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
988 holder->SetInternalField(i, Smi::FromInt(0)); | 988 holder->SetInternalField(i, Smi::FromInt(0)); |
989 } | 989 } |
990 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); | 990 Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); |
991 holder->set_length(*length_obj); | 991 holder->set_length(*length_obj); |
992 holder->set_byte_offset(*byte_offset_object); | 992 holder->set_byte_offset(*byte_offset_object); |
993 holder->set_byte_length(*byte_length_object); | 993 holder->set_byte_length(*byte_length_object); |
994 | 994 |
995 if (!maybe_buffer->IsNull()) { | 995 if (!maybe_buffer->IsNull()) { |
996 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); | 996 Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); |
997 holder->set_buffer(*buffer); | 997 holder->set_buffer(*buffer); |
998 holder->set_weak_next(buffer->weak_first_view()); | 998 holder->set_weak_next(buffer->weak_first_view()); |
999 buffer->set_weak_first_view(*holder); | 999 buffer->set_weak_first_view(*holder); |
1000 | 1000 |
1001 Handle<ExternalArray> elements = | 1001 Handle<ExternalArray> elements = |
1002 isolate->factory()->NewExternalArray( | 1002 isolate->factory()->NewExternalArray( |
1003 static_cast<int>(length), array_type, | 1003 static_cast<int>(length), array_type, |
1004 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); | 1004 static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); |
1005 Handle<Map> map = | 1005 Handle<Map> map = |
1006 JSObject::GetElementsTransitionMap(holder, external_elements_kind); | 1006 JSObject::GetElementsTransitionMap(holder, external_elements_kind); |
1007 JSObject::SetMapAndElements(holder, map, elements); | 1007 JSObject::SetMapAndElements(holder, map, elements); |
1008 ASSERT(IsExternalArrayElementsKind(holder->map()->elements_kind())); | 1008 DCHECK(IsExternalArrayElementsKind(holder->map()->elements_kind())); |
1009 } else { | 1009 } else { |
1010 holder->set_buffer(Smi::FromInt(0)); | 1010 holder->set_buffer(Smi::FromInt(0)); |
1011 holder->set_weak_next(isolate->heap()->undefined_value()); | 1011 holder->set_weak_next(isolate->heap()->undefined_value()); |
1012 Handle<FixedTypedArrayBase> elements = | 1012 Handle<FixedTypedArrayBase> elements = |
1013 isolate->factory()->NewFixedTypedArray( | 1013 isolate->factory()->NewFixedTypedArray( |
1014 static_cast<int>(length), array_type); | 1014 static_cast<int>(length), array_type); |
1015 holder->set_elements(*elements); | 1015 holder->set_elements(*elements); |
1016 } | 1016 } |
1017 return isolate->heap()->undefined_value(); | 1017 return isolate->heap()->undefined_value(); |
1018 } | 1018 } |
1019 | 1019 |
1020 | 1020 |
1021 // Initializes a typed array from an array-like object. | 1021 // Initializes a typed array from an array-like object. |
1022 // If an array-like object happens to be a typed array of the same type, | 1022 // If an array-like object happens to be a typed array of the same type, |
1023 // initializes backing store using memove. | 1023 // initializes backing store using memove. |
1024 // | 1024 // |
1025 // Returns true if backing store was initialized or false otherwise. | 1025 // Returns true if backing store was initialized or false otherwise. |
1026 RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) { | 1026 RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) { |
1027 HandleScope scope(isolate); | 1027 HandleScope scope(isolate); |
1028 ASSERT(args.length() == 4); | 1028 DCHECK(args.length() == 4); |
1029 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 1029 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
1030 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 1030 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
1031 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); | 1031 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); |
1032 CONVERT_NUMBER_ARG_HANDLE_CHECKED(length_obj, 3); | 1032 CONVERT_NUMBER_ARG_HANDLE_CHECKED(length_obj, 3); |
1033 | 1033 |
1034 RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST && | 1034 RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST && |
1035 arrayId <= Runtime::ARRAY_ID_LAST); | 1035 arrayId <= Runtime::ARRAY_ID_LAST); |
1036 | 1036 |
1037 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. | 1037 ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. |
1038 size_t element_size = 1; // Bogus initialization. | 1038 size_t element_size = 1; // Bogus initialization. |
(...skipping 17 matching lines...) Expand all Loading... |
1056 RUNTIME_ASSERT(TryNumberToSize(isolate, *length_obj, &length)); | 1056 RUNTIME_ASSERT(TryNumberToSize(isolate, *length_obj, &length)); |
1057 | 1057 |
1058 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || | 1058 if ((length > static_cast<unsigned>(Smi::kMaxValue)) || |
1059 (length > (kMaxInt / element_size))) { | 1059 (length > (kMaxInt / element_size))) { |
1060 return isolate->Throw(*isolate->factory()-> | 1060 return isolate->Throw(*isolate->factory()-> |
1061 NewRangeError("invalid_typed_array_length", | 1061 NewRangeError("invalid_typed_array_length", |
1062 HandleVector<Object>(NULL, 0))); | 1062 HandleVector<Object>(NULL, 0))); |
1063 } | 1063 } |
1064 size_t byte_length = length * element_size; | 1064 size_t byte_length = length * element_size; |
1065 | 1065 |
1066 ASSERT(holder->GetInternalFieldCount() == | 1066 DCHECK(holder->GetInternalFieldCount() == |
1067 v8::ArrayBufferView::kInternalFieldCount); | 1067 v8::ArrayBufferView::kInternalFieldCount); |
1068 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1068 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
1069 holder->SetInternalField(i, Smi::FromInt(0)); | 1069 holder->SetInternalField(i, Smi::FromInt(0)); |
1070 } | 1070 } |
1071 | 1071 |
1072 // NOTE: not initializing backing store. | 1072 // NOTE: not initializing backing store. |
1073 // We assume that the caller of this function will initialize holder | 1073 // We assume that the caller of this function will initialize holder |
1074 // with the loop | 1074 // with the loop |
1075 // for(i = 0; i < length; i++) { holder[i] = source[i]; } | 1075 // for(i = 0; i < length; i++) { holder[i] = source[i]; } |
1076 // We assume that the caller of this function is always a typed array | 1076 // We assume that the caller of this function is always a typed array |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 } | 1126 } |
1127 } | 1127 } |
1128 | 1128 |
1129 return isolate->heap()->false_value(); | 1129 return isolate->heap()->false_value(); |
1130 } | 1130 } |
1131 | 1131 |
1132 | 1132 |
1133 #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ | 1133 #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ |
1134 RUNTIME_FUNCTION(Runtime_##Type##Get##getter) { \ | 1134 RUNTIME_FUNCTION(Runtime_##Type##Get##getter) { \ |
1135 HandleScope scope(isolate); \ | 1135 HandleScope scope(isolate); \ |
1136 ASSERT(args.length() == 1); \ | 1136 DCHECK(args.length() == 1); \ |
1137 CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ | 1137 CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ |
1138 return holder->accessor(); \ | 1138 return holder->accessor(); \ |
1139 } | 1139 } |
1140 | 1140 |
1141 BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) | 1141 BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) |
1142 BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) | 1142 BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) |
1143 BUFFER_VIEW_GETTER(TypedArray, Length, length) | 1143 BUFFER_VIEW_GETTER(TypedArray, Length, length) |
1144 BUFFER_VIEW_GETTER(DataView, Buffer, buffer) | 1144 BUFFER_VIEW_GETTER(DataView, Buffer, buffer) |
1145 | 1145 |
1146 #undef BUFFER_VIEW_GETTER | 1146 #undef BUFFER_VIEW_GETTER |
1147 | 1147 |
1148 RUNTIME_FUNCTION(Runtime_TypedArrayGetBuffer) { | 1148 RUNTIME_FUNCTION(Runtime_TypedArrayGetBuffer) { |
1149 HandleScope scope(isolate); | 1149 HandleScope scope(isolate); |
1150 ASSERT(args.length() == 1); | 1150 DCHECK(args.length() == 1); |
1151 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 1151 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
1152 return *holder->GetBuffer(); | 1152 return *holder->GetBuffer(); |
1153 } | 1153 } |
1154 | 1154 |
1155 | 1155 |
1156 // Return codes for Runtime_TypedArraySetFastCases. | 1156 // Return codes for Runtime_TypedArraySetFastCases. |
1157 // Should be synchronized with typedarray.js natives. | 1157 // Should be synchronized with typedarray.js natives. |
1158 enum TypedArraySetResultCodes { | 1158 enum TypedArraySetResultCodes { |
1159 // Set from typed array of the same type. | 1159 // Set from typed array of the same type. |
1160 // This is processed by TypedArraySetFastCases | 1160 // This is processed by TypedArraySetFastCases |
1161 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 1161 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, |
1162 // Set from typed array of the different type, overlapping in memory. | 1162 // Set from typed array of the different type, overlapping in memory. |
1163 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, | 1163 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, |
1164 // Set from typed array of the different type, non-overlapping. | 1164 // Set from typed array of the different type, non-overlapping. |
1165 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 1165 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, |
1166 // Set from non-typed array. | 1166 // Set from non-typed array. |
1167 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 | 1167 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 |
1168 }; | 1168 }; |
1169 | 1169 |
1170 | 1170 |
1171 RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) { | 1171 RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) { |
1172 HandleScope scope(isolate); | 1172 HandleScope scope(isolate); |
1173 ASSERT(args.length() == 3); | 1173 DCHECK(args.length() == 3); |
1174 if (!args[0]->IsJSTypedArray()) | 1174 if (!args[0]->IsJSTypedArray()) |
1175 return isolate->Throw(*isolate->factory()->NewTypeError( | 1175 return isolate->Throw(*isolate->factory()->NewTypeError( |
1176 "not_typed_array", HandleVector<Object>(NULL, 0))); | 1176 "not_typed_array", HandleVector<Object>(NULL, 0))); |
1177 | 1177 |
1178 if (!args[1]->IsJSTypedArray()) | 1178 if (!args[1]->IsJSTypedArray()) |
1179 return Smi::FromInt(TYPED_ARRAY_SET_NON_TYPED_ARRAY); | 1179 return Smi::FromInt(TYPED_ARRAY_SET_NON_TYPED_ARRAY); |
1180 | 1180 |
1181 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, target_obj, 0); | 1181 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, target_obj, 0); |
1182 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, source_obj, 1); | 1182 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, source_obj, 1); |
1183 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset_obj, 2); | 1183 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset_obj, 2); |
(...skipping 27 matching lines...) Expand all Loading... |
1211 source_base, source_byte_length); | 1211 source_base, source_byte_length); |
1212 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); | 1212 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); |
1213 } | 1213 } |
1214 | 1214 |
1215 // Typed arrays of different types over the same backing store | 1215 // Typed arrays of different types over the same backing store |
1216 if ((source_base <= target_base && | 1216 if ((source_base <= target_base && |
1217 source_base + source_byte_length > target_base) || | 1217 source_base + source_byte_length > target_base) || |
1218 (target_base <= source_base && | 1218 (target_base <= source_base && |
1219 target_base + target_byte_length > source_base)) { | 1219 target_base + target_byte_length > source_base)) { |
1220 // We do not support overlapping ArrayBuffers | 1220 // We do not support overlapping ArrayBuffers |
1221 ASSERT( | 1221 DCHECK( |
1222 target->GetBuffer()->backing_store() == | 1222 target->GetBuffer()->backing_store() == |
1223 source->GetBuffer()->backing_store()); | 1223 source->GetBuffer()->backing_store()); |
1224 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); | 1224 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); |
1225 } else { // Non-overlapping typed arrays | 1225 } else { // Non-overlapping typed arrays |
1226 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); | 1226 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); |
1227 } | 1227 } |
1228 } | 1228 } |
1229 | 1229 |
1230 | 1230 |
1231 RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) { | 1231 RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) { |
1232 ASSERT(args.length() == 0); | 1232 DCHECK(args.length() == 0); |
1233 ASSERT_OBJECT_SIZE( | 1233 DCHECK_OBJECT_SIZE( |
1234 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); | 1234 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); |
1235 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); | 1235 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); |
1236 } | 1236 } |
1237 | 1237 |
1238 | 1238 |
1239 RUNTIME_FUNCTION(Runtime_DataViewInitialize) { | 1239 RUNTIME_FUNCTION(Runtime_DataViewInitialize) { |
1240 HandleScope scope(isolate); | 1240 HandleScope scope(isolate); |
1241 ASSERT(args.length() == 4); | 1241 DCHECK(args.length() == 4); |
1242 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 1242 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); |
1243 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 1243 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); |
1244 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset, 2); | 1244 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset, 2); |
1245 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length, 3); | 1245 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length, 3); |
1246 | 1246 |
1247 ASSERT(holder->GetInternalFieldCount() == | 1247 DCHECK(holder->GetInternalFieldCount() == |
1248 v8::ArrayBufferView::kInternalFieldCount); | 1248 v8::ArrayBufferView::kInternalFieldCount); |
1249 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1249 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
1250 holder->SetInternalField(i, Smi::FromInt(0)); | 1250 holder->SetInternalField(i, Smi::FromInt(0)); |
1251 } | 1251 } |
1252 size_t buffer_length = 0; | 1252 size_t buffer_length = 0; |
1253 size_t offset = 0; | 1253 size_t offset = 0; |
1254 size_t length = 0; | 1254 size_t length = 0; |
1255 RUNTIME_ASSERT( | 1255 RUNTIME_ASSERT( |
1256 TryNumberToSize(isolate, buffer->byte_length(), &buffer_length)); | 1256 TryNumberToSize(isolate, buffer->byte_length(), &buffer_length)); |
1257 RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_offset, &offset)); | 1257 RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_offset, &offset)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 return false; | 1323 return false; |
1324 } | 1324 } |
1325 | 1325 |
1326 union Value { | 1326 union Value { |
1327 T data; | 1327 T data; |
1328 uint8_t bytes[sizeof(T)]; | 1328 uint8_t bytes[sizeof(T)]; |
1329 }; | 1329 }; |
1330 | 1330 |
1331 Value value; | 1331 Value value; |
1332 size_t buffer_offset = data_view_byte_offset + byte_offset; | 1332 size_t buffer_offset = data_view_byte_offset + byte_offset; |
1333 ASSERT( | 1333 DCHECK( |
1334 NumberToSize(isolate, buffer->byte_length()) | 1334 NumberToSize(isolate, buffer->byte_length()) |
1335 >= buffer_offset + sizeof(T)); | 1335 >= buffer_offset + sizeof(T)); |
1336 uint8_t* source = | 1336 uint8_t* source = |
1337 static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; | 1337 static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; |
1338 if (NeedToFlipBytes(is_little_endian)) { | 1338 if (NeedToFlipBytes(is_little_endian)) { |
1339 FlipBytes<sizeof(T)>(value.bytes, source); | 1339 FlipBytes<sizeof(T)>(value.bytes, source); |
1340 } else { | 1340 } else { |
1341 CopyBytes<sizeof(T)>(value.bytes, source); | 1341 CopyBytes<sizeof(T)>(value.bytes, source); |
1342 } | 1342 } |
1343 *result = value.data; | 1343 *result = value.data; |
(...skipping 24 matching lines...) Expand all Loading... |
1368 } | 1368 } |
1369 | 1369 |
1370 union Value { | 1370 union Value { |
1371 T data; | 1371 T data; |
1372 uint8_t bytes[sizeof(T)]; | 1372 uint8_t bytes[sizeof(T)]; |
1373 }; | 1373 }; |
1374 | 1374 |
1375 Value value; | 1375 Value value; |
1376 value.data = data; | 1376 value.data = data; |
1377 size_t buffer_offset = data_view_byte_offset + byte_offset; | 1377 size_t buffer_offset = data_view_byte_offset + byte_offset; |
1378 ASSERT( | 1378 DCHECK( |
1379 NumberToSize(isolate, buffer->byte_length()) | 1379 NumberToSize(isolate, buffer->byte_length()) |
1380 >= buffer_offset + sizeof(T)); | 1380 >= buffer_offset + sizeof(T)); |
1381 uint8_t* target = | 1381 uint8_t* target = |
1382 static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; | 1382 static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; |
1383 if (NeedToFlipBytes(is_little_endian)) { | 1383 if (NeedToFlipBytes(is_little_endian)) { |
1384 FlipBytes<sizeof(T)>(target, value.bytes); | 1384 FlipBytes<sizeof(T)>(target, value.bytes); |
1385 } else { | 1385 } else { |
1386 CopyBytes<sizeof(T)>(target, value.bytes); | 1386 CopyBytes<sizeof(T)>(target, value.bytes); |
1387 } | 1387 } |
1388 return true; | 1388 return true; |
1389 } | 1389 } |
1390 | 1390 |
1391 | 1391 |
1392 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ | 1392 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ |
1393 RUNTIME_FUNCTION(Runtime_DataViewGet##TypeName) { \ | 1393 RUNTIME_FUNCTION(Runtime_DataViewGet##TypeName) { \ |
1394 HandleScope scope(isolate); \ | 1394 HandleScope scope(isolate); \ |
1395 ASSERT(args.length() == 3); \ | 1395 DCHECK(args.length() == 3); \ |
1396 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1396 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
1397 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ | 1397 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ |
1398 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ | 1398 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ |
1399 Type result; \ | 1399 Type result; \ |
1400 if (DataViewGetValue( \ | 1400 if (DataViewGetValue( \ |
1401 isolate, holder, offset, is_little_endian, &result)) { \ | 1401 isolate, holder, offset, is_little_endian, &result)) { \ |
1402 return *isolate->factory()->Converter(result); \ | 1402 return *isolate->factory()->Converter(result); \ |
1403 } else { \ | 1403 } else { \ |
1404 return isolate->Throw(*isolate->factory()->NewRangeError( \ | 1404 return isolate->Throw(*isolate->factory()->NewRangeError( \ |
1405 "invalid_data_view_accessor_offset", \ | 1405 "invalid_data_view_accessor_offset", \ |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 | 1467 |
1468 template <> | 1468 template <> |
1469 double DataViewConvertValue<double>(double value) { | 1469 double DataViewConvertValue<double>(double value) { |
1470 return value; | 1470 return value; |
1471 } | 1471 } |
1472 | 1472 |
1473 | 1473 |
1474 #define DATA_VIEW_SETTER(TypeName, Type) \ | 1474 #define DATA_VIEW_SETTER(TypeName, Type) \ |
1475 RUNTIME_FUNCTION(Runtime_DataViewSet##TypeName) { \ | 1475 RUNTIME_FUNCTION(Runtime_DataViewSet##TypeName) { \ |
1476 HandleScope scope(isolate); \ | 1476 HandleScope scope(isolate); \ |
1477 ASSERT(args.length() == 4); \ | 1477 DCHECK(args.length() == 4); \ |
1478 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1478 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
1479 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ | 1479 CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ |
1480 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); \ | 1480 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); \ |
1481 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ | 1481 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ |
1482 Type v = DataViewConvertValue<Type>(value->Number()); \ | 1482 Type v = DataViewConvertValue<Type>(value->Number()); \ |
1483 if (DataViewSetValue( \ | 1483 if (DataViewSetValue( \ |
1484 isolate, holder, offset, is_little_endian, v)) { \ | 1484 isolate, holder, offset, is_little_endian, v)) { \ |
1485 return isolate->heap()->undefined_value(); \ | 1485 return isolate->heap()->undefined_value(); \ |
1486 } else { \ | 1486 } else { \ |
1487 return isolate->Throw(*isolate->factory()->NewRangeError( \ | 1487 return isolate->Throw(*isolate->factory()->NewRangeError( \ |
1488 "invalid_data_view_accessor_offset", \ | 1488 "invalid_data_view_accessor_offset", \ |
1489 HandleVector<Object>(NULL, 0))); \ | 1489 HandleVector<Object>(NULL, 0))); \ |
1490 } \ | 1490 } \ |
1491 } | 1491 } |
1492 | 1492 |
1493 DATA_VIEW_SETTER(Uint8, uint8_t) | 1493 DATA_VIEW_SETTER(Uint8, uint8_t) |
1494 DATA_VIEW_SETTER(Int8, int8_t) | 1494 DATA_VIEW_SETTER(Int8, int8_t) |
1495 DATA_VIEW_SETTER(Uint16, uint16_t) | 1495 DATA_VIEW_SETTER(Uint16, uint16_t) |
1496 DATA_VIEW_SETTER(Int16, int16_t) | 1496 DATA_VIEW_SETTER(Int16, int16_t) |
1497 DATA_VIEW_SETTER(Uint32, uint32_t) | 1497 DATA_VIEW_SETTER(Uint32, uint32_t) |
1498 DATA_VIEW_SETTER(Int32, int32_t) | 1498 DATA_VIEW_SETTER(Int32, int32_t) |
1499 DATA_VIEW_SETTER(Float32, float) | 1499 DATA_VIEW_SETTER(Float32, float) |
1500 DATA_VIEW_SETTER(Float64, double) | 1500 DATA_VIEW_SETTER(Float64, double) |
1501 | 1501 |
1502 #undef DATA_VIEW_SETTER | 1502 #undef DATA_VIEW_SETTER |
1503 | 1503 |
1504 | 1504 |
1505 RUNTIME_FUNCTION(Runtime_SetInitialize) { | 1505 RUNTIME_FUNCTION(Runtime_SetInitialize) { |
1506 HandleScope scope(isolate); | 1506 HandleScope scope(isolate); |
1507 ASSERT(args.length() == 1); | 1507 DCHECK(args.length() == 1); |
1508 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1508 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1509 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); | 1509 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); |
1510 holder->set_table(*table); | 1510 holder->set_table(*table); |
1511 return *holder; | 1511 return *holder; |
1512 } | 1512 } |
1513 | 1513 |
1514 | 1514 |
1515 RUNTIME_FUNCTION(Runtime_SetAdd) { | 1515 RUNTIME_FUNCTION(Runtime_SetAdd) { |
1516 HandleScope scope(isolate); | 1516 HandleScope scope(isolate); |
1517 ASSERT(args.length() == 2); | 1517 DCHECK(args.length() == 2); |
1518 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1518 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1519 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1519 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1520 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1520 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1521 table = OrderedHashSet::Add(table, key); | 1521 table = OrderedHashSet::Add(table, key); |
1522 holder->set_table(*table); | 1522 holder->set_table(*table); |
1523 return *holder; | 1523 return *holder; |
1524 } | 1524 } |
1525 | 1525 |
1526 | 1526 |
1527 RUNTIME_FUNCTION(Runtime_SetHas) { | 1527 RUNTIME_FUNCTION(Runtime_SetHas) { |
1528 HandleScope scope(isolate); | 1528 HandleScope scope(isolate); |
1529 ASSERT(args.length() == 2); | 1529 DCHECK(args.length() == 2); |
1530 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1530 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1531 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1531 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1532 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1532 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1533 return isolate->heap()->ToBoolean(table->Contains(key)); | 1533 return isolate->heap()->ToBoolean(table->Contains(key)); |
1534 } | 1534 } |
1535 | 1535 |
1536 | 1536 |
1537 RUNTIME_FUNCTION(Runtime_SetDelete) { | 1537 RUNTIME_FUNCTION(Runtime_SetDelete) { |
1538 HandleScope scope(isolate); | 1538 HandleScope scope(isolate); |
1539 ASSERT(args.length() == 2); | 1539 DCHECK(args.length() == 2); |
1540 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1540 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1541 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1541 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1542 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1542 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1543 bool was_present = false; | 1543 bool was_present = false; |
1544 table = OrderedHashSet::Remove(table, key, &was_present); | 1544 table = OrderedHashSet::Remove(table, key, &was_present); |
1545 holder->set_table(*table); | 1545 holder->set_table(*table); |
1546 return isolate->heap()->ToBoolean(was_present); | 1546 return isolate->heap()->ToBoolean(was_present); |
1547 } | 1547 } |
1548 | 1548 |
1549 | 1549 |
1550 RUNTIME_FUNCTION(Runtime_SetClear) { | 1550 RUNTIME_FUNCTION(Runtime_SetClear) { |
1551 HandleScope scope(isolate); | 1551 HandleScope scope(isolate); |
1552 ASSERT(args.length() == 1); | 1552 DCHECK(args.length() == 1); |
1553 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1553 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1554 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1554 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1555 table = OrderedHashSet::Clear(table); | 1555 table = OrderedHashSet::Clear(table); |
1556 holder->set_table(*table); | 1556 holder->set_table(*table); |
1557 return isolate->heap()->undefined_value(); | 1557 return isolate->heap()->undefined_value(); |
1558 } | 1558 } |
1559 | 1559 |
1560 | 1560 |
1561 RUNTIME_FUNCTION(Runtime_SetGetSize) { | 1561 RUNTIME_FUNCTION(Runtime_SetGetSize) { |
1562 HandleScope scope(isolate); | 1562 HandleScope scope(isolate); |
1563 ASSERT(args.length() == 1); | 1563 DCHECK(args.length() == 1); |
1564 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1564 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1565 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1565 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1566 return Smi::FromInt(table->NumberOfElements()); | 1566 return Smi::FromInt(table->NumberOfElements()); |
1567 } | 1567 } |
1568 | 1568 |
1569 | 1569 |
1570 RUNTIME_FUNCTION(Runtime_SetIteratorInitialize) { | 1570 RUNTIME_FUNCTION(Runtime_SetIteratorInitialize) { |
1571 HandleScope scope(isolate); | 1571 HandleScope scope(isolate); |
1572 ASSERT(args.length() == 3); | 1572 DCHECK(args.length() == 3); |
1573 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); | 1573 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0); |
1574 CONVERT_ARG_HANDLE_CHECKED(JSSet, set, 1); | 1574 CONVERT_ARG_HANDLE_CHECKED(JSSet, set, 1); |
1575 CONVERT_SMI_ARG_CHECKED(kind, 2) | 1575 CONVERT_SMI_ARG_CHECKED(kind, 2) |
1576 RUNTIME_ASSERT(kind == JSSetIterator::kKindValues || | 1576 RUNTIME_ASSERT(kind == JSSetIterator::kKindValues || |
1577 kind == JSSetIterator::kKindEntries); | 1577 kind == JSSetIterator::kKindEntries); |
1578 Handle<OrderedHashSet> table(OrderedHashSet::cast(set->table())); | 1578 Handle<OrderedHashSet> table(OrderedHashSet::cast(set->table())); |
1579 holder->set_table(*table); | 1579 holder->set_table(*table); |
1580 holder->set_index(Smi::FromInt(0)); | 1580 holder->set_index(Smi::FromInt(0)); |
1581 holder->set_kind(Smi::FromInt(kind)); | 1581 holder->set_kind(Smi::FromInt(kind)); |
1582 return isolate->heap()->undefined_value(); | 1582 return isolate->heap()->undefined_value(); |
1583 } | 1583 } |
1584 | 1584 |
1585 | 1585 |
1586 RUNTIME_FUNCTION(Runtime_SetIteratorNext) { | 1586 RUNTIME_FUNCTION(Runtime_SetIteratorNext) { |
1587 SealHandleScope shs(isolate); | 1587 SealHandleScope shs(isolate); |
1588 ASSERT(args.length() == 2); | 1588 DCHECK(args.length() == 2); |
1589 CONVERT_ARG_CHECKED(JSSetIterator, holder, 0); | 1589 CONVERT_ARG_CHECKED(JSSetIterator, holder, 0); |
1590 CONVERT_ARG_CHECKED(JSArray, value_array, 1); | 1590 CONVERT_ARG_CHECKED(JSArray, value_array, 1); |
1591 return holder->Next(value_array); | 1591 return holder->Next(value_array); |
1592 } | 1592 } |
1593 | 1593 |
1594 | 1594 |
1595 RUNTIME_FUNCTION(Runtime_MapInitialize) { | 1595 RUNTIME_FUNCTION(Runtime_MapInitialize) { |
1596 HandleScope scope(isolate); | 1596 HandleScope scope(isolate); |
1597 ASSERT(args.length() == 1); | 1597 DCHECK(args.length() == 1); |
1598 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1598 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1599 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); | 1599 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); |
1600 holder->set_table(*table); | 1600 holder->set_table(*table); |
1601 return *holder; | 1601 return *holder; |
1602 } | 1602 } |
1603 | 1603 |
1604 | 1604 |
1605 RUNTIME_FUNCTION(Runtime_MapGet) { | 1605 RUNTIME_FUNCTION(Runtime_MapGet) { |
1606 HandleScope scope(isolate); | 1606 HandleScope scope(isolate); |
1607 ASSERT(args.length() == 2); | 1607 DCHECK(args.length() == 2); |
1608 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1608 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1609 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1609 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1610 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1610 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1611 Handle<Object> lookup(table->Lookup(key), isolate); | 1611 Handle<Object> lookup(table->Lookup(key), isolate); |
1612 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 1612 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
1613 } | 1613 } |
1614 | 1614 |
1615 | 1615 |
1616 RUNTIME_FUNCTION(Runtime_MapHas) { | 1616 RUNTIME_FUNCTION(Runtime_MapHas) { |
1617 HandleScope scope(isolate); | 1617 HandleScope scope(isolate); |
1618 ASSERT(args.length() == 2); | 1618 DCHECK(args.length() == 2); |
1619 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1619 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1620 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1620 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1621 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1621 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1622 Handle<Object> lookup(table->Lookup(key), isolate); | 1622 Handle<Object> lookup(table->Lookup(key), isolate); |
1623 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1623 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
1624 } | 1624 } |
1625 | 1625 |
1626 | 1626 |
1627 RUNTIME_FUNCTION(Runtime_MapDelete) { | 1627 RUNTIME_FUNCTION(Runtime_MapDelete) { |
1628 HandleScope scope(isolate); | 1628 HandleScope scope(isolate); |
1629 ASSERT(args.length() == 2); | 1629 DCHECK(args.length() == 2); |
1630 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1630 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1631 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1631 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1632 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1632 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1633 bool was_present = false; | 1633 bool was_present = false; |
1634 Handle<OrderedHashMap> new_table = | 1634 Handle<OrderedHashMap> new_table = |
1635 OrderedHashMap::Remove(table, key, &was_present); | 1635 OrderedHashMap::Remove(table, key, &was_present); |
1636 holder->set_table(*new_table); | 1636 holder->set_table(*new_table); |
1637 return isolate->heap()->ToBoolean(was_present); | 1637 return isolate->heap()->ToBoolean(was_present); |
1638 } | 1638 } |
1639 | 1639 |
1640 | 1640 |
1641 RUNTIME_FUNCTION(Runtime_MapClear) { | 1641 RUNTIME_FUNCTION(Runtime_MapClear) { |
1642 HandleScope scope(isolate); | 1642 HandleScope scope(isolate); |
1643 ASSERT(args.length() == 1); | 1643 DCHECK(args.length() == 1); |
1644 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1644 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1645 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1645 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1646 table = OrderedHashMap::Clear(table); | 1646 table = OrderedHashMap::Clear(table); |
1647 holder->set_table(*table); | 1647 holder->set_table(*table); |
1648 return isolate->heap()->undefined_value(); | 1648 return isolate->heap()->undefined_value(); |
1649 } | 1649 } |
1650 | 1650 |
1651 | 1651 |
1652 RUNTIME_FUNCTION(Runtime_MapSet) { | 1652 RUNTIME_FUNCTION(Runtime_MapSet) { |
1653 HandleScope scope(isolate); | 1653 HandleScope scope(isolate); |
1654 ASSERT(args.length() == 3); | 1654 DCHECK(args.length() == 3); |
1655 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1655 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1656 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1656 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1657 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 1657 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
1658 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1658 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1659 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); | 1659 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); |
1660 holder->set_table(*new_table); | 1660 holder->set_table(*new_table); |
1661 return *holder; | 1661 return *holder; |
1662 } | 1662 } |
1663 | 1663 |
1664 | 1664 |
1665 RUNTIME_FUNCTION(Runtime_MapGetSize) { | 1665 RUNTIME_FUNCTION(Runtime_MapGetSize) { |
1666 HandleScope scope(isolate); | 1666 HandleScope scope(isolate); |
1667 ASSERT(args.length() == 1); | 1667 DCHECK(args.length() == 1); |
1668 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1668 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1669 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1669 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1670 return Smi::FromInt(table->NumberOfElements()); | 1670 return Smi::FromInt(table->NumberOfElements()); |
1671 } | 1671 } |
1672 | 1672 |
1673 | 1673 |
1674 RUNTIME_FUNCTION(Runtime_MapIteratorInitialize) { | 1674 RUNTIME_FUNCTION(Runtime_MapIteratorInitialize) { |
1675 HandleScope scope(isolate); | 1675 HandleScope scope(isolate); |
1676 ASSERT(args.length() == 3); | 1676 DCHECK(args.length() == 3); |
1677 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0); | 1677 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0); |
1678 CONVERT_ARG_HANDLE_CHECKED(JSMap, map, 1); | 1678 CONVERT_ARG_HANDLE_CHECKED(JSMap, map, 1); |
1679 CONVERT_SMI_ARG_CHECKED(kind, 2) | 1679 CONVERT_SMI_ARG_CHECKED(kind, 2) |
1680 RUNTIME_ASSERT(kind == JSMapIterator::kKindKeys | 1680 RUNTIME_ASSERT(kind == JSMapIterator::kKindKeys |
1681 || kind == JSMapIterator::kKindValues | 1681 || kind == JSMapIterator::kKindValues |
1682 || kind == JSMapIterator::kKindEntries); | 1682 || kind == JSMapIterator::kKindEntries); |
1683 Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table())); | 1683 Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table())); |
1684 holder->set_table(*table); | 1684 holder->set_table(*table); |
1685 holder->set_index(Smi::FromInt(0)); | 1685 holder->set_index(Smi::FromInt(0)); |
1686 holder->set_kind(Smi::FromInt(kind)); | 1686 holder->set_kind(Smi::FromInt(kind)); |
1687 return isolate->heap()->undefined_value(); | 1687 return isolate->heap()->undefined_value(); |
1688 } | 1688 } |
1689 | 1689 |
1690 | 1690 |
1691 RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) { | 1691 RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) { |
1692 HandleScope scope(isolate); | 1692 HandleScope scope(isolate); |
1693 ASSERT(args.length() == 1); | 1693 DCHECK(args.length() == 1); |
1694 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0); | 1694 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0); |
1695 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 1695 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
1696 Handle<FixedArray> entries = | 1696 Handle<FixedArray> entries = |
1697 isolate->factory()->NewFixedArray(table->NumberOfElements() * 2); | 1697 isolate->factory()->NewFixedArray(table->NumberOfElements() * 2); |
1698 { | 1698 { |
1699 DisallowHeapAllocation no_gc; | 1699 DisallowHeapAllocation no_gc; |
1700 int number_of_non_hole_elements = 0; | 1700 int number_of_non_hole_elements = 0; |
1701 for (int i = 0; i < table->Capacity(); i++) { | 1701 for (int i = 0; i < table->Capacity(); i++) { |
1702 Handle<Object> key(table->KeyAt(i), isolate); | 1702 Handle<Object> key(table->KeyAt(i), isolate); |
1703 if (table->IsKey(*key)) { | 1703 if (table->IsKey(*key)) { |
1704 entries->set(number_of_non_hole_elements++, *key); | 1704 entries->set(number_of_non_hole_elements++, *key); |
1705 entries->set(number_of_non_hole_elements++, table->Lookup(key)); | 1705 entries->set(number_of_non_hole_elements++, table->Lookup(key)); |
1706 } | 1706 } |
1707 } | 1707 } |
1708 ASSERT_EQ(table->NumberOfElements() * 2, number_of_non_hole_elements); | 1708 DCHECK_EQ(table->NumberOfElements() * 2, number_of_non_hole_elements); |
1709 } | 1709 } |
1710 return *isolate->factory()->NewJSArrayWithElements(entries); | 1710 return *isolate->factory()->NewJSArrayWithElements(entries); |
1711 } | 1711 } |
1712 | 1712 |
1713 | 1713 |
1714 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { | 1714 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { |
1715 SealHandleScope shs(isolate); | 1715 SealHandleScope shs(isolate); |
1716 ASSERT(args.length() == 2); | 1716 DCHECK(args.length() == 2); |
1717 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0); | 1717 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0); |
1718 CONVERT_ARG_CHECKED(JSArray, value_array, 1); | 1718 CONVERT_ARG_CHECKED(JSArray, value_array, 1); |
1719 return holder->Next(value_array); | 1719 return holder->Next(value_array); |
1720 } | 1720 } |
1721 | 1721 |
1722 | 1722 |
1723 static Handle<JSWeakCollection> WeakCollectionInitialize( | 1723 static Handle<JSWeakCollection> WeakCollectionInitialize( |
1724 Isolate* isolate, | 1724 Isolate* isolate, |
1725 Handle<JSWeakCollection> weak_collection) { | 1725 Handle<JSWeakCollection> weak_collection) { |
1726 ASSERT(weak_collection->map()->inobject_properties() == 0); | 1726 DCHECK(weak_collection->map()->inobject_properties() == 0); |
1727 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 0); | 1727 Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 0); |
1728 weak_collection->set_table(*table); | 1728 weak_collection->set_table(*table); |
1729 return weak_collection; | 1729 return weak_collection; |
1730 } | 1730 } |
1731 | 1731 |
1732 | 1732 |
1733 RUNTIME_FUNCTION(Runtime_WeakCollectionInitialize) { | 1733 RUNTIME_FUNCTION(Runtime_WeakCollectionInitialize) { |
1734 HandleScope scope(isolate); | 1734 HandleScope scope(isolate); |
1735 ASSERT(args.length() == 1); | 1735 DCHECK(args.length() == 1); |
1736 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1736 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1737 return *WeakCollectionInitialize(isolate, weak_collection); | 1737 return *WeakCollectionInitialize(isolate, weak_collection); |
1738 } | 1738 } |
1739 | 1739 |
1740 | 1740 |
1741 RUNTIME_FUNCTION(Runtime_WeakCollectionGet) { | 1741 RUNTIME_FUNCTION(Runtime_WeakCollectionGet) { |
1742 HandleScope scope(isolate); | 1742 HandleScope scope(isolate); |
1743 ASSERT(args.length() == 2); | 1743 DCHECK(args.length() == 2); |
1744 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1744 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1745 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1745 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1746 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); | 1746 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); |
1747 Handle<ObjectHashTable> table( | 1747 Handle<ObjectHashTable> table( |
1748 ObjectHashTable::cast(weak_collection->table())); | 1748 ObjectHashTable::cast(weak_collection->table())); |
1749 RUNTIME_ASSERT(table->IsKey(*key)); | 1749 RUNTIME_ASSERT(table->IsKey(*key)); |
1750 Handle<Object> lookup(table->Lookup(key), isolate); | 1750 Handle<Object> lookup(table->Lookup(key), isolate); |
1751 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 1751 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
1752 } | 1752 } |
1753 | 1753 |
1754 | 1754 |
1755 RUNTIME_FUNCTION(Runtime_WeakCollectionHas) { | 1755 RUNTIME_FUNCTION(Runtime_WeakCollectionHas) { |
1756 HandleScope scope(isolate); | 1756 HandleScope scope(isolate); |
1757 ASSERT(args.length() == 2); | 1757 DCHECK(args.length() == 2); |
1758 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1758 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1759 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1759 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1760 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); | 1760 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); |
1761 Handle<ObjectHashTable> table( | 1761 Handle<ObjectHashTable> table( |
1762 ObjectHashTable::cast(weak_collection->table())); | 1762 ObjectHashTable::cast(weak_collection->table())); |
1763 RUNTIME_ASSERT(table->IsKey(*key)); | 1763 RUNTIME_ASSERT(table->IsKey(*key)); |
1764 Handle<Object> lookup(table->Lookup(key), isolate); | 1764 Handle<Object> lookup(table->Lookup(key), isolate); |
1765 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1765 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
1766 } | 1766 } |
1767 | 1767 |
1768 | 1768 |
1769 RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) { | 1769 RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) { |
1770 HandleScope scope(isolate); | 1770 HandleScope scope(isolate); |
1771 ASSERT(args.length() == 2); | 1771 DCHECK(args.length() == 2); |
1772 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1772 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1773 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1773 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1774 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); | 1774 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); |
1775 Handle<ObjectHashTable> table(ObjectHashTable::cast( | 1775 Handle<ObjectHashTable> table(ObjectHashTable::cast( |
1776 weak_collection->table())); | 1776 weak_collection->table())); |
1777 RUNTIME_ASSERT(table->IsKey(*key)); | 1777 RUNTIME_ASSERT(table->IsKey(*key)); |
1778 bool was_present = false; | 1778 bool was_present = false; |
1779 Handle<ObjectHashTable> new_table = | 1779 Handle<ObjectHashTable> new_table = |
1780 ObjectHashTable::Remove(table, key, &was_present); | 1780 ObjectHashTable::Remove(table, key, &was_present); |
1781 weak_collection->set_table(*new_table); | 1781 weak_collection->set_table(*new_table); |
1782 return isolate->heap()->ToBoolean(was_present); | 1782 return isolate->heap()->ToBoolean(was_present); |
1783 } | 1783 } |
1784 | 1784 |
1785 | 1785 |
1786 RUNTIME_FUNCTION(Runtime_WeakCollectionSet) { | 1786 RUNTIME_FUNCTION(Runtime_WeakCollectionSet) { |
1787 HandleScope scope(isolate); | 1787 HandleScope scope(isolate); |
1788 ASSERT(args.length() == 3); | 1788 DCHECK(args.length() == 3); |
1789 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1789 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1790 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1790 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1791 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); | 1791 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); |
1792 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 1792 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
1793 Handle<ObjectHashTable> table( | 1793 Handle<ObjectHashTable> table( |
1794 ObjectHashTable::cast(weak_collection->table())); | 1794 ObjectHashTable::cast(weak_collection->table())); |
1795 RUNTIME_ASSERT(table->IsKey(*key)); | 1795 RUNTIME_ASSERT(table->IsKey(*key)); |
1796 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); | 1796 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); |
1797 weak_collection->set_table(*new_table); | 1797 weak_collection->set_table(*new_table); |
1798 return *weak_collection; | 1798 return *weak_collection; |
1799 } | 1799 } |
1800 | 1800 |
1801 | 1801 |
1802 RUNTIME_FUNCTION(Runtime_GetWeakSetValues) { | 1802 RUNTIME_FUNCTION(Runtime_GetWeakSetValues) { |
1803 HandleScope scope(isolate); | 1803 HandleScope scope(isolate); |
1804 ASSERT(args.length() == 1); | 1804 DCHECK(args.length() == 1); |
1805 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0); | 1805 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0); |
1806 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 1806 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
1807 Handle<FixedArray> values = | 1807 Handle<FixedArray> values = |
1808 isolate->factory()->NewFixedArray(table->NumberOfElements()); | 1808 isolate->factory()->NewFixedArray(table->NumberOfElements()); |
1809 { | 1809 { |
1810 DisallowHeapAllocation no_gc; | 1810 DisallowHeapAllocation no_gc; |
1811 int number_of_non_hole_elements = 0; | 1811 int number_of_non_hole_elements = 0; |
1812 for (int i = 0; i < table->Capacity(); i++) { | 1812 for (int i = 0; i < table->Capacity(); i++) { |
1813 Handle<Object> key(table->KeyAt(i), isolate); | 1813 Handle<Object> key(table->KeyAt(i), isolate); |
1814 if (table->IsKey(*key)) { | 1814 if (table->IsKey(*key)) { |
1815 values->set(number_of_non_hole_elements++, *key); | 1815 values->set(number_of_non_hole_elements++, *key); |
1816 } | 1816 } |
1817 } | 1817 } |
1818 ASSERT_EQ(table->NumberOfElements(), number_of_non_hole_elements); | 1818 DCHECK_EQ(table->NumberOfElements(), number_of_non_hole_elements); |
1819 } | 1819 } |
1820 return *isolate->factory()->NewJSArrayWithElements(values); | 1820 return *isolate->factory()->NewJSArrayWithElements(values); |
1821 } | 1821 } |
1822 | 1822 |
1823 | 1823 |
1824 RUNTIME_FUNCTION(Runtime_GetPrototype) { | 1824 RUNTIME_FUNCTION(Runtime_GetPrototype) { |
1825 HandleScope scope(isolate); | 1825 HandleScope scope(isolate); |
1826 ASSERT(args.length() == 1); | 1826 DCHECK(args.length() == 1); |
1827 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 1827 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
1828 // We don't expect access checks to be needed on JSProxy objects. | 1828 // We don't expect access checks to be needed on JSProxy objects. |
1829 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 1829 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
1830 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 1830 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
1831 do { | 1831 do { |
1832 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && | 1832 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && |
1833 !isolate->MayNamedAccess( | 1833 !isolate->MayNamedAccess( |
1834 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), | 1834 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), |
1835 isolate->factory()->proto_string(), v8::ACCESS_GET)) { | 1835 isolate->factory()->proto_string(), v8::ACCESS_GET)) { |
1836 isolate->ReportFailedAccessCheck( | 1836 isolate->ReportFailedAccessCheck( |
1837 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), | 1837 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), |
1838 v8::ACCESS_GET); | 1838 v8::ACCESS_GET); |
1839 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 1839 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
1856 return PrototypeIterator::GetCurrent(iter); | 1856 return PrototypeIterator::GetCurrent(iter); |
1857 } | 1857 } |
1858 iter.Advance(); | 1858 iter.Advance(); |
1859 } | 1859 } |
1860 return PrototypeIterator::GetCurrent(iter); | 1860 return PrototypeIterator::GetCurrent(iter); |
1861 } | 1861 } |
1862 | 1862 |
1863 | 1863 |
1864 RUNTIME_FUNCTION(Runtime_SetPrototype) { | 1864 RUNTIME_FUNCTION(Runtime_SetPrototype) { |
1865 HandleScope scope(isolate); | 1865 HandleScope scope(isolate); |
1866 ASSERT(args.length() == 2); | 1866 DCHECK(args.length() == 2); |
1867 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1867 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
1868 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 1868 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
1869 if (obj->IsAccessCheckNeeded() && | 1869 if (obj->IsAccessCheckNeeded() && |
1870 !isolate->MayNamedAccess( | 1870 !isolate->MayNamedAccess( |
1871 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { | 1871 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { |
1872 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); | 1872 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); |
1873 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 1873 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
1874 return isolate->heap()->undefined_value(); | 1874 return isolate->heap()->undefined_value(); |
1875 } | 1875 } |
1876 if (obj->map()->is_observed()) { | 1876 if (obj->map()->is_observed()) { |
(...skipping 14 matching lines...) Expand all Loading... |
1891 Handle<Object> result; | 1891 Handle<Object> result; |
1892 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1892 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1893 isolate, result, | 1893 isolate, result, |
1894 JSObject::SetPrototype(obj, prototype, true)); | 1894 JSObject::SetPrototype(obj, prototype, true)); |
1895 return *result; | 1895 return *result; |
1896 } | 1896 } |
1897 | 1897 |
1898 | 1898 |
1899 RUNTIME_FUNCTION(Runtime_IsInPrototypeChain) { | 1899 RUNTIME_FUNCTION(Runtime_IsInPrototypeChain) { |
1900 HandleScope shs(isolate); | 1900 HandleScope shs(isolate); |
1901 ASSERT(args.length() == 2); | 1901 DCHECK(args.length() == 2); |
1902 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 1902 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
1903 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); | 1903 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); |
1904 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); | 1904 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); |
1905 PrototypeIterator iter(isolate, V, PrototypeIterator::START_AT_RECEIVER); | 1905 PrototypeIterator iter(isolate, V, PrototypeIterator::START_AT_RECEIVER); |
1906 while (true) { | 1906 while (true) { |
1907 iter.AdvanceIgnoringProxies(); | 1907 iter.AdvanceIgnoringProxies(); |
1908 if (iter.IsAtEnd()) return isolate->heap()->false_value(); | 1908 if (iter.IsAtEnd()) return isolate->heap()->false_value(); |
1909 if (iter.IsAtEnd(O)) return isolate->heap()->true_value(); | 1909 if (iter.IsAtEnd(O)) return isolate->heap()->true_value(); |
1910 } | 1910 } |
1911 } | 1911 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 it.GetAccessors()->IsAccessorPair()) { | 1966 it.GetAccessors()->IsAccessorPair()) { |
1967 maybe_accessors = Handle<AccessorPair>::cast(it.GetAccessors()); | 1967 maybe_accessors = Handle<AccessorPair>::cast(it.GetAccessors()); |
1968 } | 1968 } |
1969 | 1969 |
1970 // Get value if not an AccessorPair. | 1970 // Get value if not an AccessorPair. |
1971 if (maybe_accessors.is_null()) { | 1971 if (maybe_accessors.is_null()) { |
1972 ASSIGN_RETURN_ON_EXCEPTION( | 1972 ASSIGN_RETURN_ON_EXCEPTION( |
1973 isolate, value, Object::GetProperty(&it), Object); | 1973 isolate, value, Object::GetProperty(&it), Object); |
1974 } | 1974 } |
1975 } | 1975 } |
1976 ASSERT(!isolate->has_pending_exception()); | 1976 DCHECK(!isolate->has_pending_exception()); |
1977 Handle<FixedArray> elms = factory->NewFixedArray(DESCRIPTOR_SIZE); | 1977 Handle<FixedArray> elms = factory->NewFixedArray(DESCRIPTOR_SIZE); |
1978 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); | 1978 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); |
1979 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); | 1979 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); |
1980 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(!maybe_accessors.is_null())); | 1980 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(!maybe_accessors.is_null())); |
1981 | 1981 |
1982 Handle<AccessorPair> accessors; | 1982 Handle<AccessorPair> accessors; |
1983 if (maybe_accessors.ToHandle(&accessors)) { | 1983 if (maybe_accessors.ToHandle(&accessors)) { |
1984 Handle<Object> getter(accessors->GetComponent(ACCESSOR_GETTER), isolate); | 1984 Handle<Object> getter(accessors->GetComponent(ACCESSOR_GETTER), isolate); |
1985 Handle<Object> setter(accessors->GetComponent(ACCESSOR_SETTER), isolate); | 1985 Handle<Object> setter(accessors->GetComponent(ACCESSOR_SETTER), isolate); |
1986 elms->set(GETTER_INDEX, *getter); | 1986 elms->set(GETTER_INDEX, *getter); |
1987 elms->set(SETTER_INDEX, *setter); | 1987 elms->set(SETTER_INDEX, *setter); |
1988 } else { | 1988 } else { |
1989 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); | 1989 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); |
1990 elms->set(VALUE_INDEX, *value); | 1990 elms->set(VALUE_INDEX, *value); |
1991 } | 1991 } |
1992 | 1992 |
1993 return factory->NewJSArrayWithElements(elms); | 1993 return factory->NewJSArrayWithElements(elms); |
1994 } | 1994 } |
1995 | 1995 |
1996 | 1996 |
1997 // Returns an array with the property description: | 1997 // Returns an array with the property description: |
1998 // if args[1] is not a property on args[0] | 1998 // if args[1] is not a property on args[0] |
1999 // returns undefined | 1999 // returns undefined |
2000 // if args[1] is a data property on args[0] | 2000 // if args[1] is a data property on args[0] |
2001 // [false, value, Writeable, Enumerable, Configurable] | 2001 // [false, value, Writeable, Enumerable, Configurable] |
2002 // if args[1] is an accessor on args[0] | 2002 // if args[1] is an accessor on args[0] |
2003 // [true, GetFunction, SetFunction, Enumerable, Configurable] | 2003 // [true, GetFunction, SetFunction, Enumerable, Configurable] |
2004 RUNTIME_FUNCTION(Runtime_GetOwnProperty) { | 2004 RUNTIME_FUNCTION(Runtime_GetOwnProperty) { |
2005 HandleScope scope(isolate); | 2005 HandleScope scope(isolate); |
2006 ASSERT(args.length() == 2); | 2006 DCHECK(args.length() == 2); |
2007 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 2007 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
2008 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 2008 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
2009 Handle<Object> result; | 2009 Handle<Object> result; |
2010 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2010 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2011 isolate, result, GetOwnProperty(isolate, obj, name)); | 2011 isolate, result, GetOwnProperty(isolate, obj, name)); |
2012 return *result; | 2012 return *result; |
2013 } | 2013 } |
2014 | 2014 |
2015 | 2015 |
2016 RUNTIME_FUNCTION(Runtime_PreventExtensions) { | 2016 RUNTIME_FUNCTION(Runtime_PreventExtensions) { |
2017 HandleScope scope(isolate); | 2017 HandleScope scope(isolate); |
2018 ASSERT(args.length() == 1); | 2018 DCHECK(args.length() == 1); |
2019 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 2019 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
2020 Handle<Object> result; | 2020 Handle<Object> result; |
2021 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2021 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2022 isolate, result, JSObject::PreventExtensions(obj)); | 2022 isolate, result, JSObject::PreventExtensions(obj)); |
2023 return *result; | 2023 return *result; |
2024 } | 2024 } |
2025 | 2025 |
2026 | 2026 |
2027 RUNTIME_FUNCTION(Runtime_IsExtensible) { | 2027 RUNTIME_FUNCTION(Runtime_IsExtensible) { |
2028 SealHandleScope shs(isolate); | 2028 SealHandleScope shs(isolate); |
2029 ASSERT(args.length() == 1); | 2029 DCHECK(args.length() == 1); |
2030 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 2030 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
2031 if (obj->IsJSGlobalProxy()) { | 2031 if (obj->IsJSGlobalProxy()) { |
2032 PrototypeIterator iter(isolate, obj); | 2032 PrototypeIterator iter(isolate, obj); |
2033 if (iter.IsAtEnd()) return isolate->heap()->false_value(); | 2033 if (iter.IsAtEnd()) return isolate->heap()->false_value(); |
2034 ASSERT(iter.GetCurrent()->IsJSGlobalObject()); | 2034 DCHECK(iter.GetCurrent()->IsJSGlobalObject()); |
2035 obj = JSObject::cast(iter.GetCurrent()); | 2035 obj = JSObject::cast(iter.GetCurrent()); |
2036 } | 2036 } |
2037 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); | 2037 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
2038 } | 2038 } |
2039 | 2039 |
2040 | 2040 |
2041 RUNTIME_FUNCTION(Runtime_RegExpCompile) { | 2041 RUNTIME_FUNCTION(Runtime_RegExpCompile) { |
2042 HandleScope scope(isolate); | 2042 HandleScope scope(isolate); |
2043 ASSERT(args.length() == 3); | 2043 DCHECK(args.length() == 3); |
2044 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); | 2044 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); |
2045 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 2045 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
2046 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); | 2046 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); |
2047 Handle<Object> result; | 2047 Handle<Object> result; |
2048 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2048 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2049 isolate, result, RegExpImpl::Compile(re, pattern, flags)); | 2049 isolate, result, RegExpImpl::Compile(re, pattern, flags)); |
2050 return *result; | 2050 return *result; |
2051 } | 2051 } |
2052 | 2052 |
2053 | 2053 |
2054 RUNTIME_FUNCTION(Runtime_CreateApiFunction) { | 2054 RUNTIME_FUNCTION(Runtime_CreateApiFunction) { |
2055 HandleScope scope(isolate); | 2055 HandleScope scope(isolate); |
2056 ASSERT(args.length() == 2); | 2056 DCHECK(args.length() == 2); |
2057 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); | 2057 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); |
2058 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 2058 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
2059 return *isolate->factory()->CreateApiFunction(data, prototype); | 2059 return *isolate->factory()->CreateApiFunction(data, prototype); |
2060 } | 2060 } |
2061 | 2061 |
2062 | 2062 |
2063 RUNTIME_FUNCTION(Runtime_IsTemplate) { | 2063 RUNTIME_FUNCTION(Runtime_IsTemplate) { |
2064 SealHandleScope shs(isolate); | 2064 SealHandleScope shs(isolate); |
2065 ASSERT(args.length() == 1); | 2065 DCHECK(args.length() == 1); |
2066 CONVERT_ARG_HANDLE_CHECKED(Object, arg, 0); | 2066 CONVERT_ARG_HANDLE_CHECKED(Object, arg, 0); |
2067 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 2067 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
2068 return isolate->heap()->ToBoolean(result); | 2068 return isolate->heap()->ToBoolean(result); |
2069 } | 2069 } |
2070 | 2070 |
2071 | 2071 |
2072 RUNTIME_FUNCTION(Runtime_GetTemplateField) { | 2072 RUNTIME_FUNCTION(Runtime_GetTemplateField) { |
2073 SealHandleScope shs(isolate); | 2073 SealHandleScope shs(isolate); |
2074 ASSERT(args.length() == 2); | 2074 DCHECK(args.length() == 2); |
2075 CONVERT_ARG_CHECKED(HeapObject, templ, 0); | 2075 CONVERT_ARG_CHECKED(HeapObject, templ, 0); |
2076 CONVERT_SMI_ARG_CHECKED(index, 1); | 2076 CONVERT_SMI_ARG_CHECKED(index, 1); |
2077 int offset = index * kPointerSize + HeapObject::kHeaderSize; | 2077 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
2078 InstanceType type = templ->map()->instance_type(); | 2078 InstanceType type = templ->map()->instance_type(); |
2079 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | 2079 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
2080 type == OBJECT_TEMPLATE_INFO_TYPE); | 2080 type == OBJECT_TEMPLATE_INFO_TYPE); |
2081 RUNTIME_ASSERT(offset > 0); | 2081 RUNTIME_ASSERT(offset > 0); |
2082 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | 2082 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
2083 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | 2083 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
2084 } else { | 2084 } else { |
2085 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | 2085 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
2086 } | 2086 } |
2087 return *HeapObject::RawField(templ, offset); | 2087 return *HeapObject::RawField(templ, offset); |
2088 } | 2088 } |
2089 | 2089 |
2090 | 2090 |
2091 RUNTIME_FUNCTION(Runtime_DisableAccessChecks) { | 2091 RUNTIME_FUNCTION(Runtime_DisableAccessChecks) { |
2092 HandleScope scope(isolate); | 2092 HandleScope scope(isolate); |
2093 ASSERT(args.length() == 1); | 2093 DCHECK(args.length() == 1); |
2094 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); | 2094 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); |
2095 Handle<Map> old_map(object->map()); | 2095 Handle<Map> old_map(object->map()); |
2096 bool needs_access_checks = old_map->is_access_check_needed(); | 2096 bool needs_access_checks = old_map->is_access_check_needed(); |
2097 if (needs_access_checks) { | 2097 if (needs_access_checks) { |
2098 // Copy map so it won't interfere constructor's initial map. | 2098 // Copy map so it won't interfere constructor's initial map. |
2099 Handle<Map> new_map = Map::Copy(old_map); | 2099 Handle<Map> new_map = Map::Copy(old_map); |
2100 new_map->set_is_access_check_needed(false); | 2100 new_map->set_is_access_check_needed(false); |
2101 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); | 2101 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); |
2102 } | 2102 } |
2103 return isolate->heap()->ToBoolean(needs_access_checks); | 2103 return isolate->heap()->ToBoolean(needs_access_checks); |
2104 } | 2104 } |
2105 | 2105 |
2106 | 2106 |
2107 RUNTIME_FUNCTION(Runtime_EnableAccessChecks) { | 2107 RUNTIME_FUNCTION(Runtime_EnableAccessChecks) { |
2108 HandleScope scope(isolate); | 2108 HandleScope scope(isolate); |
2109 ASSERT(args.length() == 1); | 2109 DCHECK(args.length() == 1); |
2110 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 2110 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
2111 Handle<Map> old_map(object->map()); | 2111 Handle<Map> old_map(object->map()); |
2112 RUNTIME_ASSERT(!old_map->is_access_check_needed()); | 2112 RUNTIME_ASSERT(!old_map->is_access_check_needed()); |
2113 // Copy map so it won't interfere constructor's initial map. | 2113 // Copy map so it won't interfere constructor's initial map. |
2114 Handle<Map> new_map = Map::Copy(old_map); | 2114 Handle<Map> new_map = Map::Copy(old_map); |
2115 new_map->set_is_access_check_needed(true); | 2115 new_map->set_is_access_check_needed(true); |
2116 JSObject::MigrateToMap(object, new_map); | 2116 JSObject::MigrateToMap(object, new_map); |
2117 return isolate->heap()->undefined_value(); | 2117 return isolate->heap()->undefined_value(); |
2118 } | 2118 } |
2119 | 2119 |
2120 | 2120 |
2121 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { | 2121 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { |
2122 HandleScope scope(isolate); | 2122 HandleScope scope(isolate); |
2123 Handle<Object> args[1] = { name }; | 2123 Handle<Object> args[1] = { name }; |
2124 Handle<Object> error = isolate->factory()->NewTypeError( | 2124 Handle<Object> error = isolate->factory()->NewTypeError( |
2125 "var_redeclaration", HandleVector(args, 1)); | 2125 "var_redeclaration", HandleVector(args, 1)); |
2126 return isolate->Throw(*error); | 2126 return isolate->Throw(*error); |
2127 } | 2127 } |
2128 | 2128 |
2129 | 2129 |
2130 // May throw a RedeclarationError. | 2130 // May throw a RedeclarationError. |
2131 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global, | 2131 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global, |
2132 Handle<String> name, Handle<Object> value, | 2132 Handle<String> name, Handle<Object> value, |
2133 PropertyAttributes attr, bool is_var, | 2133 PropertyAttributes attr, bool is_var, |
2134 bool is_const, bool is_function) { | 2134 bool is_const, bool is_function) { |
2135 // Do the lookup own properties only, see ES5 erratum. | 2135 // Do the lookup own properties only, see ES5 erratum. |
2136 LookupIterator it(global, name, LookupIterator::CHECK_HIDDEN); | 2136 LookupIterator it(global, name, LookupIterator::CHECK_HIDDEN); |
2137 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 2137 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
2138 ASSERT(maybe.has_value); | 2138 DCHECK(maybe.has_value); |
2139 PropertyAttributes old_attributes = maybe.value; | 2139 PropertyAttributes old_attributes = maybe.value; |
2140 | 2140 |
2141 if (old_attributes != ABSENT) { | 2141 if (old_attributes != ABSENT) { |
2142 // The name was declared before; check for conflicting re-declarations. | 2142 // The name was declared before; check for conflicting re-declarations. |
2143 if (is_const) return ThrowRedeclarationError(isolate, name); | 2143 if (is_const) return ThrowRedeclarationError(isolate, name); |
2144 | 2144 |
2145 // Skip var re-declarations. | 2145 // Skip var re-declarations. |
2146 if (is_var) return isolate->heap()->undefined_value(); | 2146 if (is_var) return isolate->heap()->undefined_value(); |
2147 | 2147 |
2148 ASSERT(is_function); | 2148 DCHECK(is_function); |
2149 if ((old_attributes & DONT_DELETE) != 0) { | 2149 if ((old_attributes & DONT_DELETE) != 0) { |
2150 // Only allow reconfiguring globals to functions in user code (no | 2150 // Only allow reconfiguring globals to functions in user code (no |
2151 // natives, which are marked as read-only). | 2151 // natives, which are marked as read-only). |
2152 ASSERT((attr & READ_ONLY) == 0); | 2152 DCHECK((attr & READ_ONLY) == 0); |
2153 | 2153 |
2154 // Check whether we can reconfigure the existing property into a | 2154 // Check whether we can reconfigure the existing property into a |
2155 // function. | 2155 // function. |
2156 PropertyDetails old_details = it.property_details(); | 2156 PropertyDetails old_details = it.property_details(); |
2157 // TODO(verwaest): CALLBACKS invalidly includes ExecutableAccessInfo, | 2157 // TODO(verwaest): CALLBACKS invalidly includes ExecutableAccessInfo, |
2158 // which are actually data properties, not accessor properties. | 2158 // which are actually data properties, not accessor properties. |
2159 if (old_details.IsReadOnly() || old_details.IsDontEnum() || | 2159 if (old_details.IsReadOnly() || old_details.IsDontEnum() || |
2160 old_details.type() == CALLBACKS) { | 2160 old_details.type() == CALLBACKS) { |
2161 return ThrowRedeclarationError(isolate, name); | 2161 return ThrowRedeclarationError(isolate, name); |
2162 } | 2162 } |
2163 // If the existing property is not configurable, keep its attributes. Do | 2163 // If the existing property is not configurable, keep its attributes. Do |
2164 attr = old_attributes; | 2164 attr = old_attributes; |
2165 } | 2165 } |
2166 } | 2166 } |
2167 | 2167 |
2168 // Define or redefine own property. | 2168 // Define or redefine own property. |
2169 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 2169 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
2170 global, name, value, attr)); | 2170 global, name, value, attr)); |
2171 | 2171 |
2172 return isolate->heap()->undefined_value(); | 2172 return isolate->heap()->undefined_value(); |
2173 } | 2173 } |
2174 | 2174 |
2175 | 2175 |
2176 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { | 2176 RUNTIME_FUNCTION(Runtime_DeclareGlobals) { |
2177 HandleScope scope(isolate); | 2177 HandleScope scope(isolate); |
2178 ASSERT(args.length() == 3); | 2178 DCHECK(args.length() == 3); |
2179 Handle<GlobalObject> global(isolate->global_object()); | 2179 Handle<GlobalObject> global(isolate->global_object()); |
2180 | 2180 |
2181 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 2181 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
2182 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); | 2182 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); |
2183 CONVERT_SMI_ARG_CHECKED(flags, 2); | 2183 CONVERT_SMI_ARG_CHECKED(flags, 2); |
2184 | 2184 |
2185 // Traverse the name/value pairs and set the properties. | 2185 // Traverse the name/value pairs and set the properties. |
2186 int length = pairs->length(); | 2186 int length = pairs->length(); |
2187 for (int i = 0; i < length; i += 2) { | 2187 for (int i = 0; i < length; i += 2) { |
2188 HandleScope scope(isolate); | 2188 HandleScope scope(isolate); |
2189 Handle<String> name(String::cast(pairs->get(i))); | 2189 Handle<String> name(String::cast(pairs->get(i))); |
2190 Handle<Object> initial_value(pairs->get(i + 1), isolate); | 2190 Handle<Object> initial_value(pairs->get(i + 1), isolate); |
2191 | 2191 |
2192 // We have to declare a global const property. To capture we only | 2192 // We have to declare a global const property. To capture we only |
2193 // assign to it when evaluating the assignment for "const x = | 2193 // assign to it when evaluating the assignment for "const x = |
2194 // <expr>" the initial value is the hole. | 2194 // <expr>" the initial value is the hole. |
2195 bool is_var = initial_value->IsUndefined(); | 2195 bool is_var = initial_value->IsUndefined(); |
2196 bool is_const = initial_value->IsTheHole(); | 2196 bool is_const = initial_value->IsTheHole(); |
2197 bool is_function = initial_value->IsSharedFunctionInfo(); | 2197 bool is_function = initial_value->IsSharedFunctionInfo(); |
2198 ASSERT(is_var + is_const + is_function == 1); | 2198 DCHECK(is_var + is_const + is_function == 1); |
2199 | 2199 |
2200 Handle<Object> value; | 2200 Handle<Object> value; |
2201 if (is_function) { | 2201 if (is_function) { |
2202 // Copy the function and update its context. Use it as value. | 2202 // Copy the function and update its context. Use it as value. |
2203 Handle<SharedFunctionInfo> shared = | 2203 Handle<SharedFunctionInfo> shared = |
2204 Handle<SharedFunctionInfo>::cast(initial_value); | 2204 Handle<SharedFunctionInfo>::cast(initial_value); |
2205 Handle<JSFunction> function = | 2205 Handle<JSFunction> function = |
2206 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, | 2206 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context, |
2207 TENURED); | 2207 TENURED); |
2208 value = function; | 2208 value = function; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2258 // is the second. | 2258 // is the second. |
2259 RUNTIME_ASSERT(args.length() == 2); | 2259 RUNTIME_ASSERT(args.length() == 2); |
2260 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 2260 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
2261 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 2261 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
2262 | 2262 |
2263 Handle<GlobalObject> global = isolate->global_object(); | 2263 Handle<GlobalObject> global = isolate->global_object(); |
2264 | 2264 |
2265 // Lookup the property as own on the global object. | 2265 // Lookup the property as own on the global object. |
2266 LookupIterator it(global, name, LookupIterator::CHECK_HIDDEN); | 2266 LookupIterator it(global, name, LookupIterator::CHECK_HIDDEN); |
2267 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 2267 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
2268 ASSERT(maybe.has_value); | 2268 DCHECK(maybe.has_value); |
2269 PropertyAttributes old_attributes = maybe.value; | 2269 PropertyAttributes old_attributes = maybe.value; |
2270 | 2270 |
2271 PropertyAttributes attr = | 2271 PropertyAttributes attr = |
2272 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | 2272 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); |
2273 // Set the value if the property is either missing, or the property attributes | 2273 // Set the value if the property is either missing, or the property attributes |
2274 // allow setting the value without invoking an accessor. | 2274 // allow setting the value without invoking an accessor. |
2275 if (it.IsFound()) { | 2275 if (it.IsFound()) { |
2276 // Ignore if we can't reconfigure the value. | 2276 // Ignore if we can't reconfigure the value. |
2277 if ((old_attributes & DONT_DELETE) != 0) { | 2277 if ((old_attributes & DONT_DELETE) != 0) { |
2278 if ((old_attributes & READ_ONLY) != 0 || | 2278 if ((old_attributes & READ_ONLY) != 0 || |
2279 it.property_kind() == LookupIterator::ACCESSOR) { | 2279 it.property_kind() == LookupIterator::ACCESSOR) { |
2280 return *value; | 2280 return *value; |
2281 } | 2281 } |
2282 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY); | 2282 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY); |
2283 } | 2283 } |
2284 } | 2284 } |
2285 | 2285 |
2286 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 2286 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
2287 global, name, value, attr)); | 2287 global, name, value, attr)); |
2288 | 2288 |
2289 return *value; | 2289 return *value; |
2290 } | 2290 } |
2291 | 2291 |
2292 | 2292 |
2293 RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) { | 2293 RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) { |
2294 HandleScope scope(isolate); | 2294 HandleScope scope(isolate); |
2295 ASSERT(args.length() == 4); | 2295 DCHECK(args.length() == 4); |
2296 | 2296 |
2297 // Declarations are always made in a function, native, or global context. In | 2297 // Declarations are always made in a function, native, or global context. In |
2298 // the case of eval code, the context passed is the context of the caller, | 2298 // the case of eval code, the context passed is the context of the caller, |
2299 // which may be some nested context and not the declaration context. | 2299 // which may be some nested context and not the declaration context. |
2300 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); | 2300 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); |
2301 Handle<Context> context(context_arg->declaration_context()); | 2301 Handle<Context> context(context_arg->declaration_context()); |
2302 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 2302 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
2303 CONVERT_SMI_ARG_CHECKED(attr_arg, 2); | 2303 CONVERT_SMI_ARG_CHECKED(attr_arg, 2); |
2304 PropertyAttributes attr = static_cast<PropertyAttributes>(attr_arg); | 2304 PropertyAttributes attr = static_cast<PropertyAttributes>(attr_arg); |
2305 RUNTIME_ASSERT(attr == READ_ONLY || attr == NONE); | 2305 RUNTIME_ASSERT(attr == READ_ONLY || attr == NONE); |
2306 CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 3); | 2306 CONVERT_ARG_HANDLE_CHECKED(Object, initial_value, 3); |
2307 | 2307 |
2308 // TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals. | 2308 // TODO(verwaest): Unify the encoding indicating "var" with DeclareGlobals. |
2309 bool is_var = *initial_value == NULL; | 2309 bool is_var = *initial_value == NULL; |
2310 bool is_const = initial_value->IsTheHole(); | 2310 bool is_const = initial_value->IsTheHole(); |
2311 bool is_function = initial_value->IsJSFunction(); | 2311 bool is_function = initial_value->IsJSFunction(); |
2312 ASSERT(is_var + is_const + is_function == 1); | 2312 DCHECK(is_var + is_const + is_function == 1); |
2313 | 2313 |
2314 int index; | 2314 int index; |
2315 PropertyAttributes attributes; | 2315 PropertyAttributes attributes; |
2316 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; | 2316 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; |
2317 BindingFlags binding_flags; | 2317 BindingFlags binding_flags; |
2318 Handle<Object> holder = | 2318 Handle<Object> holder = |
2319 context->Lookup(name, flags, &index, &attributes, &binding_flags); | 2319 context->Lookup(name, flags, &index, &attributes, &binding_flags); |
2320 | 2320 |
2321 Handle<JSObject> object; | 2321 Handle<JSObject> object; |
2322 Handle<Object> value = | 2322 Handle<Object> value = |
(...skipping 11 matching lines...) Expand all Loading... |
2334 | 2334 |
2335 if (attributes != ABSENT) { | 2335 if (attributes != ABSENT) { |
2336 // The name was declared before; check for conflicting re-declarations. | 2336 // The name was declared before; check for conflicting re-declarations. |
2337 if (is_const || (attributes & READ_ONLY) != 0) { | 2337 if (is_const || (attributes & READ_ONLY) != 0) { |
2338 return ThrowRedeclarationError(isolate, name); | 2338 return ThrowRedeclarationError(isolate, name); |
2339 } | 2339 } |
2340 | 2340 |
2341 // Skip var re-declarations. | 2341 // Skip var re-declarations. |
2342 if (is_var) return isolate->heap()->undefined_value(); | 2342 if (is_var) return isolate->heap()->undefined_value(); |
2343 | 2343 |
2344 ASSERT(is_function); | 2344 DCHECK(is_function); |
2345 if (index >= 0) { | 2345 if (index >= 0) { |
2346 ASSERT(holder.is_identical_to(context)); | 2346 DCHECK(holder.is_identical_to(context)); |
2347 context->set(index, *initial_value); | 2347 context->set(index, *initial_value); |
2348 return isolate->heap()->undefined_value(); | 2348 return isolate->heap()->undefined_value(); |
2349 } | 2349 } |
2350 | 2350 |
2351 object = Handle<JSObject>::cast(holder); | 2351 object = Handle<JSObject>::cast(holder); |
2352 | 2352 |
2353 } else if (context->has_extension()) { | 2353 } else if (context->has_extension()) { |
2354 object = handle(JSObject::cast(context->extension())); | 2354 object = handle(JSObject::cast(context->extension())); |
2355 ASSERT(object->IsJSContextExtensionObject() || object->IsJSGlobalObject()); | 2355 DCHECK(object->IsJSContextExtensionObject() || object->IsJSGlobalObject()); |
2356 } else { | 2356 } else { |
2357 ASSERT(context->IsFunctionContext()); | 2357 DCHECK(context->IsFunctionContext()); |
2358 object = | 2358 object = |
2359 isolate->factory()->NewJSObject(isolate->context_extension_function()); | 2359 isolate->factory()->NewJSObject(isolate->context_extension_function()); |
2360 context->set_extension(*object); | 2360 context->set_extension(*object); |
2361 } | 2361 } |
2362 | 2362 |
2363 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 2363 RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
2364 object, name, value, attr)); | 2364 object, name, value, attr)); |
2365 | 2365 |
2366 return isolate->heap()->undefined_value(); | 2366 return isolate->heap()->undefined_value(); |
2367 } | 2367 } |
2368 | 2368 |
2369 | 2369 |
2370 RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) { | 2370 RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) { |
2371 HandleScope scope(isolate); | 2371 HandleScope scope(isolate); |
2372 ASSERT(args.length() == 3); | 2372 DCHECK(args.length() == 3); |
2373 | 2373 |
2374 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 2374 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
2375 ASSERT(!value->IsTheHole()); | 2375 DCHECK(!value->IsTheHole()); |
2376 // Initializations are always done in a function or native context. | 2376 // Initializations are always done in a function or native context. |
2377 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); | 2377 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); |
2378 Handle<Context> context(context_arg->declaration_context()); | 2378 Handle<Context> context(context_arg->declaration_context()); |
2379 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 2379 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
2380 | 2380 |
2381 int index; | 2381 int index; |
2382 PropertyAttributes attributes; | 2382 PropertyAttributes attributes; |
2383 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; | 2383 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; |
2384 BindingFlags binding_flags; | 2384 BindingFlags binding_flags; |
2385 Handle<Object> holder = | 2385 Handle<Object> holder = |
2386 context->Lookup(name, flags, &index, &attributes, &binding_flags); | 2386 context->Lookup(name, flags, &index, &attributes, &binding_flags); |
2387 | 2387 |
2388 if (index >= 0) { | 2388 if (index >= 0) { |
2389 ASSERT(holder->IsContext()); | 2389 DCHECK(holder->IsContext()); |
2390 // Property was found in a context. Perform the assignment if the constant | 2390 // Property was found in a context. Perform the assignment if the constant |
2391 // was uninitialized. | 2391 // was uninitialized. |
2392 Handle<Context> context = Handle<Context>::cast(holder); | 2392 Handle<Context> context = Handle<Context>::cast(holder); |
2393 ASSERT((attributes & READ_ONLY) != 0); | 2393 DCHECK((attributes & READ_ONLY) != 0); |
2394 if (context->get(index)->IsTheHole()) context->set(index, *value); | 2394 if (context->get(index)->IsTheHole()) context->set(index, *value); |
2395 return *value; | 2395 return *value; |
2396 } | 2396 } |
2397 | 2397 |
2398 PropertyAttributes attr = | 2398 PropertyAttributes attr = |
2399 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | 2399 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); |
2400 | 2400 |
2401 // Strict mode handling not needed (legacy const is disallowed in strict | 2401 // Strict mode handling not needed (legacy const is disallowed in strict |
2402 // mode). | 2402 // mode). |
2403 | 2403 |
2404 // The declared const was configurable, and may have been deleted in the | 2404 // The declared const was configurable, and may have been deleted in the |
2405 // meanwhile. If so, re-introduce the variable in the context extension. | 2405 // meanwhile. If so, re-introduce the variable in the context extension. |
2406 ASSERT(context_arg->has_extension()); | 2406 DCHECK(context_arg->has_extension()); |
2407 if (attributes == ABSENT) { | 2407 if (attributes == ABSENT) { |
2408 holder = handle(context_arg->extension(), isolate); | 2408 holder = handle(context_arg->extension(), isolate); |
2409 } else { | 2409 } else { |
2410 // For JSContextExtensionObjects, the initializer can be run multiple times | 2410 // For JSContextExtensionObjects, the initializer can be run multiple times |
2411 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the | 2411 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the |
2412 // first assignment should go through. For JSGlobalObjects, additionally any | 2412 // first assignment should go through. For JSGlobalObjects, additionally any |
2413 // code can run in between that modifies the declared property. | 2413 // code can run in between that modifies the declared property. |
2414 ASSERT(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject()); | 2414 DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject()); |
2415 | 2415 |
2416 LookupIterator it(holder, name, LookupIterator::CHECK_HIDDEN); | 2416 LookupIterator it(holder, name, LookupIterator::CHECK_HIDDEN); |
2417 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 2417 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
2418 if (!maybe.has_value) return isolate->heap()->exception(); | 2418 if (!maybe.has_value) return isolate->heap()->exception(); |
2419 PropertyAttributes old_attributes = maybe.value; | 2419 PropertyAttributes old_attributes = maybe.value; |
2420 | 2420 |
2421 // Ignore if we can't reconfigure the value. | 2421 // Ignore if we can't reconfigure the value. |
2422 if ((old_attributes & DONT_DELETE) != 0) { | 2422 if ((old_attributes & DONT_DELETE) != 0) { |
2423 if ((old_attributes & READ_ONLY) != 0 || | 2423 if ((old_attributes & READ_ONLY) != 0 || |
2424 it.property_kind() == LookupIterator::ACCESSOR) { | 2424 it.property_kind() == LookupIterator::ACCESSOR) { |
2425 return *value; | 2425 return *value; |
2426 } | 2426 } |
2427 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY); | 2427 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY); |
2428 } | 2428 } |
2429 } | 2429 } |
2430 | 2430 |
2431 RETURN_FAILURE_ON_EXCEPTION( | 2431 RETURN_FAILURE_ON_EXCEPTION( |
2432 isolate, JSObject::SetOwnPropertyIgnoreAttributes( | 2432 isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
2433 Handle<JSObject>::cast(holder), name, value, attr)); | 2433 Handle<JSObject>::cast(holder), name, value, attr)); |
2434 | 2434 |
2435 return *value; | 2435 return *value; |
2436 } | 2436 } |
2437 | 2437 |
2438 | 2438 |
2439 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { | 2439 RUNTIME_FUNCTION(Runtime_OptimizeObjectForAddingMultipleProperties) { |
2440 HandleScope scope(isolate); | 2440 HandleScope scope(isolate); |
2441 ASSERT(args.length() == 2); | 2441 DCHECK(args.length() == 2); |
2442 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 2442 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
2443 CONVERT_SMI_ARG_CHECKED(properties, 1); | 2443 CONVERT_SMI_ARG_CHECKED(properties, 1); |
2444 // Conservative upper limit to prevent fuzz tests from going OOM. | 2444 // Conservative upper limit to prevent fuzz tests from going OOM. |
2445 RUNTIME_ASSERT(properties <= 100000); | 2445 RUNTIME_ASSERT(properties <= 100000); |
2446 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 2446 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
2447 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 2447 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
2448 } | 2448 } |
2449 return *object; | 2449 return *object; |
2450 } | 2450 } |
2451 | 2451 |
2452 | 2452 |
2453 RUNTIME_FUNCTION(Runtime_RegExpExecRT) { | 2453 RUNTIME_FUNCTION(Runtime_RegExpExecRT) { |
2454 HandleScope scope(isolate); | 2454 HandleScope scope(isolate); |
2455 ASSERT(args.length() == 4); | 2455 DCHECK(args.length() == 4); |
2456 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2456 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2457 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 2457 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
2458 // Due to the way the JS calls are constructed this must be less than the | 2458 // Due to the way the JS calls are constructed this must be less than the |
2459 // length of a string, i.e. it is always a Smi. We check anyway for security. | 2459 // length of a string, i.e. it is always a Smi. We check anyway for security. |
2460 CONVERT_SMI_ARG_CHECKED(index, 2); | 2460 CONVERT_SMI_ARG_CHECKED(index, 2); |
2461 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 2461 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
2462 RUNTIME_ASSERT(index >= 0); | 2462 RUNTIME_ASSERT(index >= 0); |
2463 RUNTIME_ASSERT(index <= subject->length()); | 2463 RUNTIME_ASSERT(index <= subject->length()); |
2464 isolate->counters()->regexp_entry_runtime()->Increment(); | 2464 isolate->counters()->regexp_entry_runtime()->Increment(); |
2465 Handle<Object> result; | 2465 Handle<Object> result; |
2466 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2466 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2467 isolate, result, | 2467 isolate, result, |
2468 RegExpImpl::Exec(regexp, subject, index, last_match_info)); | 2468 RegExpImpl::Exec(regexp, subject, index, last_match_info)); |
2469 return *result; | 2469 return *result; |
2470 } | 2470 } |
2471 | 2471 |
2472 | 2472 |
2473 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { | 2473 RUNTIME_FUNCTION(Runtime_RegExpConstructResult) { |
2474 HandleScope handle_scope(isolate); | 2474 HandleScope handle_scope(isolate); |
2475 ASSERT(args.length() == 3); | 2475 DCHECK(args.length() == 3); |
2476 CONVERT_SMI_ARG_CHECKED(size, 0); | 2476 CONVERT_SMI_ARG_CHECKED(size, 0); |
2477 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); | 2477 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
2478 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 2478 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
2479 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); | 2479 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); |
2480 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); | 2480 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
2481 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); | 2481 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
2482 Handle<JSObject> object = | 2482 Handle<JSObject> object = |
2483 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); | 2483 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); |
2484 Handle<JSArray> array = Handle<JSArray>::cast(object); | 2484 Handle<JSArray> array = Handle<JSArray>::cast(object); |
2485 array->set_elements(*elements); | 2485 array->set_elements(*elements); |
2486 array->set_length(Smi::FromInt(size)); | 2486 array->set_length(Smi::FromInt(size)); |
2487 // Write in-object properties after the length of the array. | 2487 // Write in-object properties after the length of the array. |
2488 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); | 2488 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); |
2489 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); | 2489 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); |
2490 return *array; | 2490 return *array; |
2491 } | 2491 } |
2492 | 2492 |
2493 | 2493 |
2494 RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) { | 2494 RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) { |
2495 HandleScope scope(isolate); | 2495 HandleScope scope(isolate); |
2496 ASSERT(args.length() == 5); | 2496 DCHECK(args.length() == 5); |
2497 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2497 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2498 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 2498 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
2499 // If source is the empty string we set it to "(?:)" instead as | 2499 // If source is the empty string we set it to "(?:)" instead as |
2500 // suggested by ECMA-262, 5th, section 15.10.4.1. | 2500 // suggested by ECMA-262, 5th, section 15.10.4.1. |
2501 if (source->length() == 0) source = isolate->factory()->query_colon_string(); | 2501 if (source->length() == 0) source = isolate->factory()->query_colon_string(); |
2502 | 2502 |
2503 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); | 2503 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); |
2504 if (!global->IsTrue()) global = isolate->factory()->false_value(); | 2504 if (!global->IsTrue()) global = isolate->factory()->false_value(); |
2505 | 2505 |
2506 CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3); | 2506 CONVERT_ARG_HANDLE_CHECKED(Object, ignoreCase, 3); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 JSObject::SetOwnPropertyIgnoreAttributes( | 2544 JSObject::SetOwnPropertyIgnoreAttributes( |
2545 regexp, factory->multiline_string(), multiline, final).Check(); | 2545 regexp, factory->multiline_string(), multiline, final).Check(); |
2546 JSObject::SetOwnPropertyIgnoreAttributes( | 2546 JSObject::SetOwnPropertyIgnoreAttributes( |
2547 regexp, factory->last_index_string(), zero, writable).Check(); | 2547 regexp, factory->last_index_string(), zero, writable).Check(); |
2548 return *regexp; | 2548 return *regexp; |
2549 } | 2549 } |
2550 | 2550 |
2551 | 2551 |
2552 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { | 2552 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { |
2553 HandleScope scope(isolate); | 2553 HandleScope scope(isolate); |
2554 ASSERT(args.length() == 1); | 2554 DCHECK(args.length() == 1); |
2555 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 2555 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
2556 Object* length = prototype->length(); | 2556 Object* length = prototype->length(); |
2557 RUNTIME_ASSERT(length->IsSmi() && Smi::cast(length)->value() == 0); | 2557 RUNTIME_ASSERT(length->IsSmi() && Smi::cast(length)->value() == 0); |
2558 RUNTIME_ASSERT(prototype->HasFastSmiOrObjectElements()); | 2558 RUNTIME_ASSERT(prototype->HasFastSmiOrObjectElements()); |
2559 // This is necessary to enable fast checks for absence of elements | 2559 // This is necessary to enable fast checks for absence of elements |
2560 // on Array.prototype and below. | 2560 // on Array.prototype and below. |
2561 prototype->set_elements(isolate->heap()->empty_fixed_array()); | 2561 prototype->set_elements(isolate->heap()->empty_fixed_array()); |
2562 return Smi::FromInt(0); | 2562 return Smi::FromInt(0); |
2563 } | 2563 } |
2564 | 2564 |
2565 | 2565 |
2566 static void InstallBuiltin(Isolate* isolate, | 2566 static void InstallBuiltin(Isolate* isolate, |
2567 Handle<JSObject> holder, | 2567 Handle<JSObject> holder, |
2568 const char* name, | 2568 const char* name, |
2569 Builtins::Name builtin_name) { | 2569 Builtins::Name builtin_name) { |
2570 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); | 2570 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); |
2571 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); | 2571 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); |
2572 Handle<JSFunction> optimized = | 2572 Handle<JSFunction> optimized = |
2573 isolate->factory()->NewFunctionWithoutPrototype(key, code); | 2573 isolate->factory()->NewFunctionWithoutPrototype(key, code); |
2574 optimized->shared()->DontAdaptArguments(); | 2574 optimized->shared()->DontAdaptArguments(); |
2575 JSObject::AddProperty(holder, key, optimized, NONE); | 2575 JSObject::AddProperty(holder, key, optimized, NONE); |
2576 } | 2576 } |
2577 | 2577 |
2578 | 2578 |
2579 RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) { | 2579 RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) { |
2580 HandleScope scope(isolate); | 2580 HandleScope scope(isolate); |
2581 ASSERT(args.length() == 0); | 2581 DCHECK(args.length() == 0); |
2582 Handle<JSObject> holder = | 2582 Handle<JSObject> holder = |
2583 isolate->factory()->NewJSObject(isolate->object_function()); | 2583 isolate->factory()->NewJSObject(isolate->object_function()); |
2584 | 2584 |
2585 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); | 2585 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); |
2586 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); | 2586 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); |
2587 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); | 2587 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); |
2588 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); | 2588 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); |
2589 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 2589 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
2590 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 2590 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
2591 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); | 2591 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); |
2592 | 2592 |
2593 return *holder; | 2593 return *holder; |
2594 } | 2594 } |
2595 | 2595 |
2596 | 2596 |
2597 RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) { | 2597 RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) { |
2598 SealHandleScope shs(isolate); | 2598 SealHandleScope shs(isolate); |
2599 ASSERT(args.length() == 1); | 2599 DCHECK(args.length() == 1); |
2600 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2600 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
2601 if (!callable->IsJSFunction()) { | 2601 if (!callable->IsJSFunction()) { |
2602 HandleScope scope(isolate); | 2602 HandleScope scope(isolate); |
2603 Handle<Object> delegate; | 2603 Handle<Object> delegate; |
2604 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2604 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2605 isolate, delegate, | 2605 isolate, delegate, |
2606 Execution::TryGetFunctionDelegate( | 2606 Execution::TryGetFunctionDelegate( |
2607 isolate, Handle<JSReceiver>(callable))); | 2607 isolate, Handle<JSReceiver>(callable))); |
2608 callable = JSFunction::cast(*delegate); | 2608 callable = JSFunction::cast(*delegate); |
2609 } | 2609 } |
2610 JSFunction* function = JSFunction::cast(callable); | 2610 JSFunction* function = JSFunction::cast(callable); |
2611 SharedFunctionInfo* shared = function->shared(); | 2611 SharedFunctionInfo* shared = function->shared(); |
2612 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY); | 2612 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY); |
2613 } | 2613 } |
2614 | 2614 |
2615 | 2615 |
2616 RUNTIME_FUNCTION(Runtime_GetDefaultReceiver) { | 2616 RUNTIME_FUNCTION(Runtime_GetDefaultReceiver) { |
2617 SealHandleScope shs(isolate); | 2617 SealHandleScope shs(isolate); |
2618 ASSERT(args.length() == 1); | 2618 DCHECK(args.length() == 1); |
2619 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2619 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
2620 | 2620 |
2621 if (!callable->IsJSFunction()) { | 2621 if (!callable->IsJSFunction()) { |
2622 HandleScope scope(isolate); | 2622 HandleScope scope(isolate); |
2623 Handle<Object> delegate; | 2623 Handle<Object> delegate; |
2624 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2624 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2625 isolate, delegate, | 2625 isolate, delegate, |
2626 Execution::TryGetFunctionDelegate( | 2626 Execution::TryGetFunctionDelegate( |
2627 isolate, Handle<JSReceiver>(callable))); | 2627 isolate, Handle<JSReceiver>(callable))); |
2628 callable = JSFunction::cast(*delegate); | 2628 callable = JSFunction::cast(*delegate); |
2629 } | 2629 } |
2630 JSFunction* function = JSFunction::cast(callable); | 2630 JSFunction* function = JSFunction::cast(callable); |
2631 | 2631 |
2632 SharedFunctionInfo* shared = function->shared(); | 2632 SharedFunctionInfo* shared = function->shared(); |
2633 if (shared->native() || shared->strict_mode() == STRICT) { | 2633 if (shared->native() || shared->strict_mode() == STRICT) { |
2634 return isolate->heap()->undefined_value(); | 2634 return isolate->heap()->undefined_value(); |
2635 } | 2635 } |
2636 // Returns undefined for strict or native functions, or | 2636 // Returns undefined for strict or native functions, or |
2637 // the associated global receiver for "normal" functions. | 2637 // the associated global receiver for "normal" functions. |
2638 | 2638 |
2639 return function->global_proxy(); | 2639 return function->global_proxy(); |
2640 } | 2640 } |
2641 | 2641 |
2642 | 2642 |
2643 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { | 2643 RUNTIME_FUNCTION(Runtime_MaterializeRegExpLiteral) { |
2644 HandleScope scope(isolate); | 2644 HandleScope scope(isolate); |
2645 ASSERT(args.length() == 4); | 2645 DCHECK(args.length() == 4); |
2646 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 2646 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
2647 CONVERT_SMI_ARG_CHECKED(index, 1); | 2647 CONVERT_SMI_ARG_CHECKED(index, 1); |
2648 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); | 2648 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
2649 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); | 2649 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
2650 | 2650 |
2651 // Get the RegExp function from the context in the literals array. | 2651 // Get the RegExp function from the context in the literals array. |
2652 // This is the RegExp function from the context in which the | 2652 // This is the RegExp function from the context in which the |
2653 // function was created. We do not use the RegExp function from the | 2653 // function was created. We do not use the RegExp function from the |
2654 // current native context because this might be the RegExp function | 2654 // current native context because this might be the RegExp function |
2655 // from another context which we should not have access to. | 2655 // from another context which we should not have access to. |
2656 Handle<JSFunction> constructor = | 2656 Handle<JSFunction> constructor = |
2657 Handle<JSFunction>( | 2657 Handle<JSFunction>( |
2658 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); | 2658 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); |
2659 // Compute the regular expression literal. | 2659 // Compute the regular expression literal. |
2660 Handle<Object> regexp; | 2660 Handle<Object> regexp; |
2661 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2661 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2662 isolate, regexp, | 2662 isolate, regexp, |
2663 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); | 2663 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); |
2664 literals->set(index, *regexp); | 2664 literals->set(index, *regexp); |
2665 return *regexp; | 2665 return *regexp; |
2666 } | 2666 } |
2667 | 2667 |
2668 | 2668 |
2669 RUNTIME_FUNCTION(Runtime_FunctionGetName) { | 2669 RUNTIME_FUNCTION(Runtime_FunctionGetName) { |
2670 SealHandleScope shs(isolate); | 2670 SealHandleScope shs(isolate); |
2671 ASSERT(args.length() == 1); | 2671 DCHECK(args.length() == 1); |
2672 | 2672 |
2673 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2673 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2674 return f->shared()->name(); | 2674 return f->shared()->name(); |
2675 } | 2675 } |
2676 | 2676 |
2677 | 2677 |
2678 RUNTIME_FUNCTION(Runtime_FunctionSetName) { | 2678 RUNTIME_FUNCTION(Runtime_FunctionSetName) { |
2679 SealHandleScope shs(isolate); | 2679 SealHandleScope shs(isolate); |
2680 ASSERT(args.length() == 2); | 2680 DCHECK(args.length() == 2); |
2681 | 2681 |
2682 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2682 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2683 CONVERT_ARG_CHECKED(String, name, 1); | 2683 CONVERT_ARG_CHECKED(String, name, 1); |
2684 f->shared()->set_name(name); | 2684 f->shared()->set_name(name); |
2685 return isolate->heap()->undefined_value(); | 2685 return isolate->heap()->undefined_value(); |
2686 } | 2686 } |
2687 | 2687 |
2688 | 2688 |
2689 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { | 2689 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { |
2690 SealHandleScope shs(isolate); | 2690 SealHandleScope shs(isolate); |
2691 ASSERT(args.length() == 1); | 2691 DCHECK(args.length() == 1); |
2692 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2692 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2693 return isolate->heap()->ToBoolean( | 2693 return isolate->heap()->ToBoolean( |
2694 f->shared()->name_should_print_as_anonymous()); | 2694 f->shared()->name_should_print_as_anonymous()); |
2695 } | 2695 } |
2696 | 2696 |
2697 | 2697 |
2698 RUNTIME_FUNCTION(Runtime_FunctionMarkNameShouldPrintAsAnonymous) { | 2698 RUNTIME_FUNCTION(Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
2699 SealHandleScope shs(isolate); | 2699 SealHandleScope shs(isolate); |
2700 ASSERT(args.length() == 1); | 2700 DCHECK(args.length() == 1); |
2701 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2701 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2702 f->shared()->set_name_should_print_as_anonymous(true); | 2702 f->shared()->set_name_should_print_as_anonymous(true); |
2703 return isolate->heap()->undefined_value(); | 2703 return isolate->heap()->undefined_value(); |
2704 } | 2704 } |
2705 | 2705 |
2706 | 2706 |
2707 RUNTIME_FUNCTION(Runtime_FunctionIsGenerator) { | 2707 RUNTIME_FUNCTION(Runtime_FunctionIsGenerator) { |
2708 SealHandleScope shs(isolate); | 2708 SealHandleScope shs(isolate); |
2709 ASSERT(args.length() == 1); | 2709 DCHECK(args.length() == 1); |
2710 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2710 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2711 return isolate->heap()->ToBoolean(f->shared()->is_generator()); | 2711 return isolate->heap()->ToBoolean(f->shared()->is_generator()); |
2712 } | 2712 } |
2713 | 2713 |
2714 | 2714 |
2715 RUNTIME_FUNCTION(Runtime_FunctionIsArrow) { | 2715 RUNTIME_FUNCTION(Runtime_FunctionIsArrow) { |
2716 SealHandleScope shs(isolate); | 2716 SealHandleScope shs(isolate); |
2717 ASSERT(args.length() == 1); | 2717 DCHECK(args.length() == 1); |
2718 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2718 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2719 return isolate->heap()->ToBoolean(f->shared()->is_arrow()); | 2719 return isolate->heap()->ToBoolean(f->shared()->is_arrow()); |
2720 } | 2720 } |
2721 | 2721 |
2722 | 2722 |
2723 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { | 2723 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { |
2724 SealHandleScope shs(isolate); | 2724 SealHandleScope shs(isolate); |
2725 ASSERT(args.length() == 1); | 2725 DCHECK(args.length() == 1); |
2726 | 2726 |
2727 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2727 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2728 RUNTIME_ASSERT(f->RemovePrototype()); | 2728 RUNTIME_ASSERT(f->RemovePrototype()); |
2729 | 2729 |
2730 return isolate->heap()->undefined_value(); | 2730 return isolate->heap()->undefined_value(); |
2731 } | 2731 } |
2732 | 2732 |
2733 | 2733 |
2734 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { | 2734 RUNTIME_FUNCTION(Runtime_FunctionGetScript) { |
2735 HandleScope scope(isolate); | 2735 HandleScope scope(isolate); |
2736 ASSERT(args.length() == 1); | 2736 DCHECK(args.length() == 1); |
2737 | 2737 |
2738 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2738 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2739 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); | 2739 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); |
2740 if (!script->IsScript()) return isolate->heap()->undefined_value(); | 2740 if (!script->IsScript()) return isolate->heap()->undefined_value(); |
2741 | 2741 |
2742 return *Script::GetWrapper(Handle<Script>::cast(script)); | 2742 return *Script::GetWrapper(Handle<Script>::cast(script)); |
2743 } | 2743 } |
2744 | 2744 |
2745 | 2745 |
2746 RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { | 2746 RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { |
2747 HandleScope scope(isolate); | 2747 HandleScope scope(isolate); |
2748 ASSERT(args.length() == 1); | 2748 DCHECK(args.length() == 1); |
2749 | 2749 |
2750 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); | 2750 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
2751 Handle<SharedFunctionInfo> shared(f->shared()); | 2751 Handle<SharedFunctionInfo> shared(f->shared()); |
2752 return *shared->GetSourceCode(); | 2752 return *shared->GetSourceCode(); |
2753 } | 2753 } |
2754 | 2754 |
2755 | 2755 |
2756 RUNTIME_FUNCTION(Runtime_FunctionGetScriptSourcePosition) { | 2756 RUNTIME_FUNCTION(Runtime_FunctionGetScriptSourcePosition) { |
2757 SealHandleScope shs(isolate); | 2757 SealHandleScope shs(isolate); |
2758 ASSERT(args.length() == 1); | 2758 DCHECK(args.length() == 1); |
2759 | 2759 |
2760 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2760 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2761 int pos = fun->shared()->start_position(); | 2761 int pos = fun->shared()->start_position(); |
2762 return Smi::FromInt(pos); | 2762 return Smi::FromInt(pos); |
2763 } | 2763 } |
2764 | 2764 |
2765 | 2765 |
2766 RUNTIME_FUNCTION(Runtime_FunctionGetPositionForOffset) { | 2766 RUNTIME_FUNCTION(Runtime_FunctionGetPositionForOffset) { |
2767 SealHandleScope shs(isolate); | 2767 SealHandleScope shs(isolate); |
2768 ASSERT(args.length() == 2); | 2768 DCHECK(args.length() == 2); |
2769 | 2769 |
2770 CONVERT_ARG_CHECKED(Code, code, 0); | 2770 CONVERT_ARG_CHECKED(Code, code, 0); |
2771 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 2771 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
2772 | 2772 |
2773 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 2773 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
2774 | 2774 |
2775 Address pc = code->address() + offset; | 2775 Address pc = code->address() + offset; |
2776 return Smi::FromInt(code->SourcePosition(pc)); | 2776 return Smi::FromInt(code->SourcePosition(pc)); |
2777 } | 2777 } |
2778 | 2778 |
2779 | 2779 |
2780 RUNTIME_FUNCTION(Runtime_FunctionSetInstanceClassName) { | 2780 RUNTIME_FUNCTION(Runtime_FunctionSetInstanceClassName) { |
2781 SealHandleScope shs(isolate); | 2781 SealHandleScope shs(isolate); |
2782 ASSERT(args.length() == 2); | 2782 DCHECK(args.length() == 2); |
2783 | 2783 |
2784 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2784 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2785 CONVERT_ARG_CHECKED(String, name, 1); | 2785 CONVERT_ARG_CHECKED(String, name, 1); |
2786 fun->SetInstanceClassName(name); | 2786 fun->SetInstanceClassName(name); |
2787 return isolate->heap()->undefined_value(); | 2787 return isolate->heap()->undefined_value(); |
2788 } | 2788 } |
2789 | 2789 |
2790 | 2790 |
2791 RUNTIME_FUNCTION(Runtime_FunctionSetLength) { | 2791 RUNTIME_FUNCTION(Runtime_FunctionSetLength) { |
2792 SealHandleScope shs(isolate); | 2792 SealHandleScope shs(isolate); |
2793 ASSERT(args.length() == 2); | 2793 DCHECK(args.length() == 2); |
2794 | 2794 |
2795 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2795 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2796 CONVERT_SMI_ARG_CHECKED(length, 1); | 2796 CONVERT_SMI_ARG_CHECKED(length, 1); |
2797 RUNTIME_ASSERT((length & 0xC0000000) == 0xC0000000 || | 2797 RUNTIME_ASSERT((length & 0xC0000000) == 0xC0000000 || |
2798 (length & 0xC0000000) == 0x0); | 2798 (length & 0xC0000000) == 0x0); |
2799 fun->shared()->set_length(length); | 2799 fun->shared()->set_length(length); |
2800 return isolate->heap()->undefined_value(); | 2800 return isolate->heap()->undefined_value(); |
2801 } | 2801 } |
2802 | 2802 |
2803 | 2803 |
2804 RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { | 2804 RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { |
2805 HandleScope scope(isolate); | 2805 HandleScope scope(isolate); |
2806 ASSERT(args.length() == 2); | 2806 DCHECK(args.length() == 2); |
2807 | 2807 |
2808 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 2808 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
2809 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 2809 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
2810 RUNTIME_ASSERT(fun->should_have_prototype()); | 2810 RUNTIME_ASSERT(fun->should_have_prototype()); |
2811 Accessors::FunctionSetPrototype(fun, value); | 2811 Accessors::FunctionSetPrototype(fun, value); |
2812 return args[0]; // return TOS | 2812 return args[0]; // return TOS |
2813 } | 2813 } |
2814 | 2814 |
2815 | 2815 |
2816 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { | 2816 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { |
2817 SealHandleScope shs(isolate); | 2817 SealHandleScope shs(isolate); |
2818 ASSERT(args.length() == 1); | 2818 DCHECK(args.length() == 1); |
2819 | 2819 |
2820 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2820 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2821 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 2821 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
2822 } | 2822 } |
2823 | 2823 |
2824 | 2824 |
2825 RUNTIME_FUNCTION(Runtime_FunctionIsBuiltin) { | 2825 RUNTIME_FUNCTION(Runtime_FunctionIsBuiltin) { |
2826 SealHandleScope shs(isolate); | 2826 SealHandleScope shs(isolate); |
2827 ASSERT(args.length() == 1); | 2827 DCHECK(args.length() == 1); |
2828 | 2828 |
2829 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2829 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2830 return isolate->heap()->ToBoolean(f->IsBuiltin()); | 2830 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
2831 } | 2831 } |
2832 | 2832 |
2833 | 2833 |
2834 RUNTIME_FUNCTION(Runtime_SetCode) { | 2834 RUNTIME_FUNCTION(Runtime_SetCode) { |
2835 HandleScope scope(isolate); | 2835 HandleScope scope(isolate); |
2836 ASSERT(args.length() == 2); | 2836 DCHECK(args.length() == 2); |
2837 | 2837 |
2838 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); | 2838 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); |
2839 CONVERT_ARG_HANDLE_CHECKED(JSFunction, source, 1); | 2839 CONVERT_ARG_HANDLE_CHECKED(JSFunction, source, 1); |
2840 | 2840 |
2841 Handle<SharedFunctionInfo> target_shared(target->shared()); | 2841 Handle<SharedFunctionInfo> target_shared(target->shared()); |
2842 Handle<SharedFunctionInfo> source_shared(source->shared()); | 2842 Handle<SharedFunctionInfo> source_shared(source->shared()); |
2843 RUNTIME_ASSERT(!source_shared->bound()); | 2843 RUNTIME_ASSERT(!source_shared->bound()); |
2844 | 2844 |
2845 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) { | 2845 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) { |
2846 return isolate->heap()->exception(); | 2846 return isolate->heap()->exception(); |
2847 } | 2847 } |
2848 | 2848 |
2849 // Mark both, the source and the target, as un-flushable because the | 2849 // Mark both, the source and the target, as un-flushable because the |
2850 // shared unoptimized code makes them impossible to enqueue in a list. | 2850 // shared unoptimized code makes them impossible to enqueue in a list. |
2851 ASSERT(target_shared->code()->gc_metadata() == NULL); | 2851 DCHECK(target_shared->code()->gc_metadata() == NULL); |
2852 ASSERT(source_shared->code()->gc_metadata() == NULL); | 2852 DCHECK(source_shared->code()->gc_metadata() == NULL); |
2853 target_shared->set_dont_flush(true); | 2853 target_shared->set_dont_flush(true); |
2854 source_shared->set_dont_flush(true); | 2854 source_shared->set_dont_flush(true); |
2855 | 2855 |
2856 // Set the code, scope info, formal parameter count, and the length | 2856 // Set the code, scope info, formal parameter count, and the length |
2857 // of the target shared function info. | 2857 // of the target shared function info. |
2858 target_shared->ReplaceCode(source_shared->code()); | 2858 target_shared->ReplaceCode(source_shared->code()); |
2859 target_shared->set_scope_info(source_shared->scope_info()); | 2859 target_shared->set_scope_info(source_shared->scope_info()); |
2860 target_shared->set_length(source_shared->length()); | 2860 target_shared->set_length(source_shared->length()); |
2861 target_shared->set_feedback_vector(source_shared->feedback_vector()); | 2861 target_shared->set_feedback_vector(source_shared->feedback_vector()); |
2862 target_shared->set_formal_parameter_count( | 2862 target_shared->set_formal_parameter_count( |
2863 source_shared->formal_parameter_count()); | 2863 source_shared->formal_parameter_count()); |
2864 target_shared->set_script(source_shared->script()); | 2864 target_shared->set_script(source_shared->script()); |
2865 target_shared->set_start_position_and_type( | 2865 target_shared->set_start_position_and_type( |
2866 source_shared->start_position_and_type()); | 2866 source_shared->start_position_and_type()); |
2867 target_shared->set_end_position(source_shared->end_position()); | 2867 target_shared->set_end_position(source_shared->end_position()); |
2868 bool was_native = target_shared->native(); | 2868 bool was_native = target_shared->native(); |
2869 target_shared->set_compiler_hints(source_shared->compiler_hints()); | 2869 target_shared->set_compiler_hints(source_shared->compiler_hints()); |
2870 target_shared->set_native(was_native); | 2870 target_shared->set_native(was_native); |
2871 target_shared->set_profiler_ticks(source_shared->profiler_ticks()); | 2871 target_shared->set_profiler_ticks(source_shared->profiler_ticks()); |
2872 | 2872 |
2873 // Set the code of the target function. | 2873 // Set the code of the target function. |
2874 target->ReplaceCode(source_shared->code()); | 2874 target->ReplaceCode(source_shared->code()); |
2875 ASSERT(target->next_function_link()->IsUndefined()); | 2875 DCHECK(target->next_function_link()->IsUndefined()); |
2876 | 2876 |
2877 // Make sure we get a fresh copy of the literal vector to avoid cross | 2877 // Make sure we get a fresh copy of the literal vector to avoid cross |
2878 // context contamination. | 2878 // context contamination. |
2879 Handle<Context> context(source->context()); | 2879 Handle<Context> context(source->context()); |
2880 int number_of_literals = source->NumberOfLiterals(); | 2880 int number_of_literals = source->NumberOfLiterals(); |
2881 Handle<FixedArray> literals = | 2881 Handle<FixedArray> literals = |
2882 isolate->factory()->NewFixedArray(number_of_literals, TENURED); | 2882 isolate->factory()->NewFixedArray(number_of_literals, TENURED); |
2883 if (number_of_literals > 0) { | 2883 if (number_of_literals > 0) { |
2884 literals->set(JSFunction::kLiteralNativeContextIndex, | 2884 literals->set(JSFunction::kLiteralNativeContextIndex, |
2885 context->native_context()); | 2885 context->native_context()); |
2886 } | 2886 } |
2887 target->set_context(*context); | 2887 target->set_context(*context); |
2888 target->set_literals(*literals); | 2888 target->set_literals(*literals); |
2889 | 2889 |
2890 if (isolate->logger()->is_logging_code_events() || | 2890 if (isolate->logger()->is_logging_code_events() || |
2891 isolate->cpu_profiler()->is_profiling()) { | 2891 isolate->cpu_profiler()->is_profiling()) { |
2892 isolate->logger()->LogExistingFunction( | 2892 isolate->logger()->LogExistingFunction( |
2893 source_shared, Handle<Code>(source_shared->code())); | 2893 source_shared, Handle<Code>(source_shared->code())); |
2894 } | 2894 } |
2895 | 2895 |
2896 return *target; | 2896 return *target; |
2897 } | 2897 } |
2898 | 2898 |
2899 | 2899 |
2900 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { | 2900 RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) { |
2901 HandleScope scope(isolate); | 2901 HandleScope scope(isolate); |
2902 ASSERT(args.length() == 0); | 2902 DCHECK(args.length() == 0); |
2903 | 2903 |
2904 JavaScriptFrameIterator it(isolate); | 2904 JavaScriptFrameIterator it(isolate); |
2905 JavaScriptFrame* frame = it.frame(); | 2905 JavaScriptFrame* frame = it.frame(); |
2906 Handle<JSFunction> function(frame->function()); | 2906 Handle<JSFunction> function(frame->function()); |
2907 RUNTIME_ASSERT(function->shared()->is_generator()); | 2907 RUNTIME_ASSERT(function->shared()->is_generator()); |
2908 | 2908 |
2909 Handle<JSGeneratorObject> generator; | 2909 Handle<JSGeneratorObject> generator; |
2910 if (frame->IsConstructor()) { | 2910 if (frame->IsConstructor()) { |
2911 generator = handle(JSGeneratorObject::cast(frame->receiver())); | 2911 generator = handle(JSGeneratorObject::cast(frame->receiver())); |
2912 } else { | 2912 } else { |
2913 generator = isolate->factory()->NewJSGeneratorObject(function); | 2913 generator = isolate->factory()->NewJSGeneratorObject(function); |
2914 } | 2914 } |
2915 generator->set_function(*function); | 2915 generator->set_function(*function); |
2916 generator->set_context(Context::cast(frame->context())); | 2916 generator->set_context(Context::cast(frame->context())); |
2917 generator->set_receiver(frame->receiver()); | 2917 generator->set_receiver(frame->receiver()); |
2918 generator->set_continuation(0); | 2918 generator->set_continuation(0); |
2919 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); | 2919 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); |
2920 generator->set_stack_handler_index(-1); | 2920 generator->set_stack_handler_index(-1); |
2921 | 2921 |
2922 return *generator; | 2922 return *generator; |
2923 } | 2923 } |
2924 | 2924 |
2925 | 2925 |
2926 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) { | 2926 RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) { |
2927 HandleScope handle_scope(isolate); | 2927 HandleScope handle_scope(isolate); |
2928 ASSERT(args.length() == 1); | 2928 DCHECK(args.length() == 1); |
2929 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); | 2929 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); |
2930 | 2930 |
2931 JavaScriptFrameIterator stack_iterator(isolate); | 2931 JavaScriptFrameIterator stack_iterator(isolate); |
2932 JavaScriptFrame* frame = stack_iterator.frame(); | 2932 JavaScriptFrame* frame = stack_iterator.frame(); |
2933 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); | 2933 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); |
2934 ASSERT_EQ(frame->function(), generator_object->function()); | 2934 DCHECK_EQ(frame->function(), generator_object->function()); |
2935 | 2935 |
2936 // The caller should have saved the context and continuation already. | 2936 // The caller should have saved the context and continuation already. |
2937 ASSERT_EQ(generator_object->context(), Context::cast(frame->context())); | 2937 DCHECK_EQ(generator_object->context(), Context::cast(frame->context())); |
2938 ASSERT_LT(0, generator_object->continuation()); | 2938 DCHECK_LT(0, generator_object->continuation()); |
2939 | 2939 |
2940 // We expect there to be at least two values on the operand stack: the return | 2940 // We expect there to be at least two values on the operand stack: the return |
2941 // value of the yield expression, and the argument to this runtime call. | 2941 // value of the yield expression, and the argument to this runtime call. |
2942 // Neither of those should be saved. | 2942 // Neither of those should be saved. |
2943 int operands_count = frame->ComputeOperandsCount(); | 2943 int operands_count = frame->ComputeOperandsCount(); |
2944 ASSERT_GE(operands_count, 2); | 2944 DCHECK_GE(operands_count, 2); |
2945 operands_count -= 2; | 2945 operands_count -= 2; |
2946 | 2946 |
2947 if (operands_count == 0) { | 2947 if (operands_count == 0) { |
2948 // Although it's semantically harmless to call this function with an | 2948 // Although it's semantically harmless to call this function with an |
2949 // operands_count of zero, it is also unnecessary. | 2949 // operands_count of zero, it is also unnecessary. |
2950 ASSERT_EQ(generator_object->operand_stack(), | 2950 DCHECK_EQ(generator_object->operand_stack(), |
2951 isolate->heap()->empty_fixed_array()); | 2951 isolate->heap()->empty_fixed_array()); |
2952 ASSERT_EQ(generator_object->stack_handler_index(), -1); | 2952 DCHECK_EQ(generator_object->stack_handler_index(), -1); |
2953 // If there are no operands on the stack, there shouldn't be a handler | 2953 // If there are no operands on the stack, there shouldn't be a handler |
2954 // active either. | 2954 // active either. |
2955 ASSERT(!frame->HasHandler()); | 2955 DCHECK(!frame->HasHandler()); |
2956 } else { | 2956 } else { |
2957 int stack_handler_index = -1; | 2957 int stack_handler_index = -1; |
2958 Handle<FixedArray> operand_stack = | 2958 Handle<FixedArray> operand_stack = |
2959 isolate->factory()->NewFixedArray(operands_count); | 2959 isolate->factory()->NewFixedArray(operands_count); |
2960 frame->SaveOperandStack(*operand_stack, &stack_handler_index); | 2960 frame->SaveOperandStack(*operand_stack, &stack_handler_index); |
2961 generator_object->set_operand_stack(*operand_stack); | 2961 generator_object->set_operand_stack(*operand_stack); |
2962 generator_object->set_stack_handler_index(stack_handler_index); | 2962 generator_object->set_stack_handler_index(stack_handler_index); |
2963 } | 2963 } |
2964 | 2964 |
2965 return isolate->heap()->undefined_value(); | 2965 return isolate->heap()->undefined_value(); |
2966 } | 2966 } |
2967 | 2967 |
2968 | 2968 |
2969 // Note that this function is the slow path for resuming generators. It is only | 2969 // Note that this function is the slow path for resuming generators. It is only |
2970 // called if the suspended activation had operands on the stack, stack handlers | 2970 // called if the suspended activation had operands on the stack, stack handlers |
2971 // needing rewinding, or if the resume should throw an exception. The fast path | 2971 // needing rewinding, or if the resume should throw an exception. The fast path |
2972 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is | 2972 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is |
2973 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is | 2973 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is |
2974 // called in any case, as it needs to reconstruct the stack frame and make space | 2974 // called in any case, as it needs to reconstruct the stack frame and make space |
2975 // for arguments and operands. | 2975 // for arguments and operands. |
2976 RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) { | 2976 RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) { |
2977 SealHandleScope shs(isolate); | 2977 SealHandleScope shs(isolate); |
2978 ASSERT(args.length() == 3); | 2978 DCHECK(args.length() == 3); |
2979 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); | 2979 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); |
2980 CONVERT_ARG_CHECKED(Object, value, 1); | 2980 CONVERT_ARG_CHECKED(Object, value, 1); |
2981 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); | 2981 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); |
2982 JavaScriptFrameIterator stack_iterator(isolate); | 2982 JavaScriptFrameIterator stack_iterator(isolate); |
2983 JavaScriptFrame* frame = stack_iterator.frame(); | 2983 JavaScriptFrame* frame = stack_iterator.frame(); |
2984 | 2984 |
2985 ASSERT_EQ(frame->function(), generator_object->function()); | 2985 DCHECK_EQ(frame->function(), generator_object->function()); |
2986 ASSERT(frame->function()->is_compiled()); | 2986 DCHECK(frame->function()->is_compiled()); |
2987 | 2987 |
2988 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); | 2988 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); |
2989 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0); | 2989 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0); |
2990 | 2990 |
2991 Address pc = generator_object->function()->code()->instruction_start(); | 2991 Address pc = generator_object->function()->code()->instruction_start(); |
2992 int offset = generator_object->continuation(); | 2992 int offset = generator_object->continuation(); |
2993 ASSERT(offset > 0); | 2993 DCHECK(offset > 0); |
2994 frame->set_pc(pc + offset); | 2994 frame->set_pc(pc + offset); |
2995 if (FLAG_enable_ool_constant_pool) { | 2995 if (FLAG_enable_ool_constant_pool) { |
2996 frame->set_constant_pool( | 2996 frame->set_constant_pool( |
2997 generator_object->function()->code()->constant_pool()); | 2997 generator_object->function()->code()->constant_pool()); |
2998 } | 2998 } |
2999 generator_object->set_continuation(JSGeneratorObject::kGeneratorExecuting); | 2999 generator_object->set_continuation(JSGeneratorObject::kGeneratorExecuting); |
3000 | 3000 |
3001 FixedArray* operand_stack = generator_object->operand_stack(); | 3001 FixedArray* operand_stack = generator_object->operand_stack(); |
3002 int operands_count = operand_stack->length(); | 3002 int operands_count = operand_stack->length(); |
3003 if (operands_count != 0) { | 3003 if (operands_count != 0) { |
(...skipping 12 matching lines...) Expand all Loading... |
3016 return isolate->Throw(value); | 3016 return isolate->Throw(value); |
3017 } | 3017 } |
3018 | 3018 |
3019 UNREACHABLE(); | 3019 UNREACHABLE(); |
3020 return isolate->ThrowIllegalOperation(); | 3020 return isolate->ThrowIllegalOperation(); |
3021 } | 3021 } |
3022 | 3022 |
3023 | 3023 |
3024 RUNTIME_FUNCTION(Runtime_ThrowGeneratorStateError) { | 3024 RUNTIME_FUNCTION(Runtime_ThrowGeneratorStateError) { |
3025 HandleScope scope(isolate); | 3025 HandleScope scope(isolate); |
3026 ASSERT(args.length() == 1); | 3026 DCHECK(args.length() == 1); |
3027 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 3027 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
3028 int continuation = generator->continuation(); | 3028 int continuation = generator->continuation(); |
3029 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? | 3029 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? |
3030 "generator_finished" : "generator_running"; | 3030 "generator_finished" : "generator_running"; |
3031 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); | 3031 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); |
3032 Handle<Object> error = isolate->factory()->NewError(message, argv); | 3032 Handle<Object> error = isolate->factory()->NewError(message, argv); |
3033 return isolate->Throw(*error); | 3033 return isolate->Throw(*error); |
3034 } | 3034 } |
3035 | 3035 |
3036 | 3036 |
3037 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { | 3037 RUNTIME_FUNCTION(Runtime_ObjectFreeze) { |
3038 HandleScope scope(isolate); | 3038 HandleScope scope(isolate); |
3039 ASSERT(args.length() == 1); | 3039 DCHECK(args.length() == 1); |
3040 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 3040 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
3041 | 3041 |
3042 // %ObjectFreeze is a fast path and these cases are handled elsewhere. | 3042 // %ObjectFreeze is a fast path and these cases are handled elsewhere. |
3043 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && | 3043 RUNTIME_ASSERT(!object->HasSloppyArgumentsElements() && |
3044 !object->map()->is_observed() && | 3044 !object->map()->is_observed() && |
3045 !object->IsJSProxy()); | 3045 !object->IsJSProxy()); |
3046 | 3046 |
3047 Handle<Object> result; | 3047 Handle<Object> result; |
3048 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); | 3048 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); |
3049 return *result; | 3049 return *result; |
3050 } | 3050 } |
3051 | 3051 |
3052 | 3052 |
3053 RUNTIME_FUNCTION(Runtime_StringCharCodeAtRT) { | 3053 RUNTIME_FUNCTION(Runtime_StringCharCodeAtRT) { |
3054 HandleScope handle_scope(isolate); | 3054 HandleScope handle_scope(isolate); |
3055 ASSERT(args.length() == 2); | 3055 DCHECK(args.length() == 2); |
3056 | 3056 |
3057 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 3057 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
3058 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 3058 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
3059 | 3059 |
3060 // Flatten the string. If someone wants to get a char at an index | 3060 // Flatten the string. If someone wants to get a char at an index |
3061 // in a cons string, it is likely that more indices will be | 3061 // in a cons string, it is likely that more indices will be |
3062 // accessed. | 3062 // accessed. |
3063 subject = String::Flatten(subject); | 3063 subject = String::Flatten(subject); |
3064 | 3064 |
3065 if (i >= static_cast<uint32_t>(subject->length())) { | 3065 if (i >= static_cast<uint32_t>(subject->length())) { |
3066 return isolate->heap()->nan_value(); | 3066 return isolate->heap()->nan_value(); |
3067 } | 3067 } |
3068 | 3068 |
3069 return Smi::FromInt(subject->Get(i)); | 3069 return Smi::FromInt(subject->Get(i)); |
3070 } | 3070 } |
3071 | 3071 |
3072 | 3072 |
3073 RUNTIME_FUNCTION(Runtime_CharFromCode) { | 3073 RUNTIME_FUNCTION(Runtime_CharFromCode) { |
3074 HandleScope handlescope(isolate); | 3074 HandleScope handlescope(isolate); |
3075 ASSERT(args.length() == 1); | 3075 DCHECK(args.length() == 1); |
3076 if (args[0]->IsNumber()) { | 3076 if (args[0]->IsNumber()) { |
3077 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); | 3077 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); |
3078 code &= 0xffff; | 3078 code &= 0xffff; |
3079 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); | 3079 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); |
3080 } | 3080 } |
3081 return isolate->heap()->empty_string(); | 3081 return isolate->heap()->empty_string(); |
3082 } | 3082 } |
3083 | 3083 |
3084 | 3084 |
3085 class FixedArrayBuilder { | 3085 class FixedArrayBuilder { |
3086 public: | 3086 public: |
3087 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) | 3087 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) |
3088 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), | 3088 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), |
3089 length_(0), | 3089 length_(0), |
3090 has_non_smi_elements_(false) { | 3090 has_non_smi_elements_(false) { |
3091 // Require a non-zero initial size. Ensures that doubling the size to | 3091 // Require a non-zero initial size. Ensures that doubling the size to |
3092 // extend the array will work. | 3092 // extend the array will work. |
3093 ASSERT(initial_capacity > 0); | 3093 DCHECK(initial_capacity > 0); |
3094 } | 3094 } |
3095 | 3095 |
3096 explicit FixedArrayBuilder(Handle<FixedArray> backing_store) | 3096 explicit FixedArrayBuilder(Handle<FixedArray> backing_store) |
3097 : array_(backing_store), | 3097 : array_(backing_store), |
3098 length_(0), | 3098 length_(0), |
3099 has_non_smi_elements_(false) { | 3099 has_non_smi_elements_(false) { |
3100 // Require a non-zero initial size. Ensures that doubling the size to | 3100 // Require a non-zero initial size. Ensures that doubling the size to |
3101 // extend the array will work. | 3101 // extend the array will work. |
3102 ASSERT(backing_store->length() > 0); | 3102 DCHECK(backing_store->length() > 0); |
3103 } | 3103 } |
3104 | 3104 |
3105 bool HasCapacity(int elements) { | 3105 bool HasCapacity(int elements) { |
3106 int length = array_->length(); | 3106 int length = array_->length(); |
3107 int required_length = length_ + elements; | 3107 int required_length = length_ + elements; |
3108 return (length >= required_length); | 3108 return (length >= required_length); |
3109 } | 3109 } |
3110 | 3110 |
3111 void EnsureCapacity(int elements) { | 3111 void EnsureCapacity(int elements) { |
3112 int length = array_->length(); | 3112 int length = array_->length(); |
3113 int required_length = length_ + elements; | 3113 int required_length = length_ + elements; |
3114 if (length < required_length) { | 3114 if (length < required_length) { |
3115 int new_length = length; | 3115 int new_length = length; |
3116 do { | 3116 do { |
3117 new_length *= 2; | 3117 new_length *= 2; |
3118 } while (new_length < required_length); | 3118 } while (new_length < required_length); |
3119 Handle<FixedArray> extended_array = | 3119 Handle<FixedArray> extended_array = |
3120 array_->GetIsolate()->factory()->NewFixedArrayWithHoles(new_length); | 3120 array_->GetIsolate()->factory()->NewFixedArrayWithHoles(new_length); |
3121 array_->CopyTo(0, *extended_array, 0, length_); | 3121 array_->CopyTo(0, *extended_array, 0, length_); |
3122 array_ = extended_array; | 3122 array_ = extended_array; |
3123 } | 3123 } |
3124 } | 3124 } |
3125 | 3125 |
3126 void Add(Object* value) { | 3126 void Add(Object* value) { |
3127 ASSERT(!value->IsSmi()); | 3127 DCHECK(!value->IsSmi()); |
3128 ASSERT(length_ < capacity()); | 3128 DCHECK(length_ < capacity()); |
3129 array_->set(length_, value); | 3129 array_->set(length_, value); |
3130 length_++; | 3130 length_++; |
3131 has_non_smi_elements_ = true; | 3131 has_non_smi_elements_ = true; |
3132 } | 3132 } |
3133 | 3133 |
3134 void Add(Smi* value) { | 3134 void Add(Smi* value) { |
3135 ASSERT(value->IsSmi()); | 3135 DCHECK(value->IsSmi()); |
3136 ASSERT(length_ < capacity()); | 3136 DCHECK(length_ < capacity()); |
3137 array_->set(length_, value); | 3137 array_->set(length_, value); |
3138 length_++; | 3138 length_++; |
3139 } | 3139 } |
3140 | 3140 |
3141 Handle<FixedArray> array() { | 3141 Handle<FixedArray> array() { |
3142 return array_; | 3142 return array_; |
3143 } | 3143 } |
3144 | 3144 |
3145 int length() { | 3145 int length() { |
3146 return length_; | 3146 return length_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3187 ReplacementStringBuilder(Heap* heap, | 3187 ReplacementStringBuilder(Heap* heap, |
3188 Handle<String> subject, | 3188 Handle<String> subject, |
3189 int estimated_part_count) | 3189 int estimated_part_count) |
3190 : heap_(heap), | 3190 : heap_(heap), |
3191 array_builder_(heap->isolate(), estimated_part_count), | 3191 array_builder_(heap->isolate(), estimated_part_count), |
3192 subject_(subject), | 3192 subject_(subject), |
3193 character_count_(0), | 3193 character_count_(0), |
3194 is_ascii_(subject->IsOneByteRepresentation()) { | 3194 is_ascii_(subject->IsOneByteRepresentation()) { |
3195 // Require a non-zero initial size. Ensures that doubling the size to | 3195 // Require a non-zero initial size. Ensures that doubling the size to |
3196 // extend the array will work. | 3196 // extend the array will work. |
3197 ASSERT(estimated_part_count > 0); | 3197 DCHECK(estimated_part_count > 0); |
3198 } | 3198 } |
3199 | 3199 |
3200 static inline void AddSubjectSlice(FixedArrayBuilder* builder, | 3200 static inline void AddSubjectSlice(FixedArrayBuilder* builder, |
3201 int from, | 3201 int from, |
3202 int to) { | 3202 int to) { |
3203 ASSERT(from >= 0); | 3203 DCHECK(from >= 0); |
3204 int length = to - from; | 3204 int length = to - from; |
3205 ASSERT(length > 0); | 3205 DCHECK(length > 0); |
3206 if (StringBuilderSubstringLength::is_valid(length) && | 3206 if (StringBuilderSubstringLength::is_valid(length) && |
3207 StringBuilderSubstringPosition::is_valid(from)) { | 3207 StringBuilderSubstringPosition::is_valid(from)) { |
3208 int encoded_slice = StringBuilderSubstringLength::encode(length) | | 3208 int encoded_slice = StringBuilderSubstringLength::encode(length) | |
3209 StringBuilderSubstringPosition::encode(from); | 3209 StringBuilderSubstringPosition::encode(from); |
3210 builder->Add(Smi::FromInt(encoded_slice)); | 3210 builder->Add(Smi::FromInt(encoded_slice)); |
3211 } else { | 3211 } else { |
3212 // Otherwise encode as two smis. | 3212 // Otherwise encode as two smis. |
3213 builder->Add(Smi::FromInt(-length)); | 3213 builder->Add(Smi::FromInt(-length)); |
3214 builder->Add(Smi::FromInt(from)); | 3214 builder->Add(Smi::FromInt(from)); |
3215 } | 3215 } |
3216 } | 3216 } |
3217 | 3217 |
3218 | 3218 |
3219 void EnsureCapacity(int elements) { | 3219 void EnsureCapacity(int elements) { |
3220 array_builder_.EnsureCapacity(elements); | 3220 array_builder_.EnsureCapacity(elements); |
3221 } | 3221 } |
3222 | 3222 |
3223 | 3223 |
3224 void AddSubjectSlice(int from, int to) { | 3224 void AddSubjectSlice(int from, int to) { |
3225 AddSubjectSlice(&array_builder_, from, to); | 3225 AddSubjectSlice(&array_builder_, from, to); |
3226 IncrementCharacterCount(to - from); | 3226 IncrementCharacterCount(to - from); |
3227 } | 3227 } |
3228 | 3228 |
3229 | 3229 |
3230 void AddString(Handle<String> string) { | 3230 void AddString(Handle<String> string) { |
3231 int length = string->length(); | 3231 int length = string->length(); |
3232 ASSERT(length > 0); | 3232 DCHECK(length > 0); |
3233 AddElement(*string); | 3233 AddElement(*string); |
3234 if (!string->IsOneByteRepresentation()) { | 3234 if (!string->IsOneByteRepresentation()) { |
3235 is_ascii_ = false; | 3235 is_ascii_ = false; |
3236 } | 3236 } |
3237 IncrementCharacterCount(length); | 3237 IncrementCharacterCount(length); |
3238 } | 3238 } |
3239 | 3239 |
3240 | 3240 |
3241 MaybeHandle<String> ToString() { | 3241 MaybeHandle<String> ToString() { |
3242 Isolate* isolate = heap_->isolate(); | 3242 Isolate* isolate = heap_->isolate(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3283 if (character_count_ > String::kMaxLength - by) { | 3283 if (character_count_ > String::kMaxLength - by) { |
3284 STATIC_ASSERT(String::kMaxLength < kMaxInt); | 3284 STATIC_ASSERT(String::kMaxLength < kMaxInt); |
3285 character_count_ = kMaxInt; | 3285 character_count_ = kMaxInt; |
3286 } else { | 3286 } else { |
3287 character_count_ += by; | 3287 character_count_ += by; |
3288 } | 3288 } |
3289 } | 3289 } |
3290 | 3290 |
3291 private: | 3291 private: |
3292 void AddElement(Object* element) { | 3292 void AddElement(Object* element) { |
3293 ASSERT(element->IsSmi() || element->IsString()); | 3293 DCHECK(element->IsSmi() || element->IsString()); |
3294 ASSERT(array_builder_.capacity() > array_builder_.length()); | 3294 DCHECK(array_builder_.capacity() > array_builder_.length()); |
3295 array_builder_.Add(element); | 3295 array_builder_.Add(element); |
3296 } | 3296 } |
3297 | 3297 |
3298 Heap* heap_; | 3298 Heap* heap_; |
3299 FixedArrayBuilder array_builder_; | 3299 FixedArrayBuilder array_builder_; |
3300 Handle<String> subject_; | 3300 Handle<String> subject_; |
3301 int character_count_; | 3301 int character_count_; |
3302 bool is_ascii_; | 3302 bool is_ascii_; |
3303 }; | 3303 }; |
3304 | 3304 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 static inline ReplacementPart SubjectPrefix() { | 3347 static inline ReplacementPart SubjectPrefix() { |
3348 return ReplacementPart(SUBJECT_PREFIX, 0); | 3348 return ReplacementPart(SUBJECT_PREFIX, 0); |
3349 } | 3349 } |
3350 static inline ReplacementPart SubjectSuffix(int subject_length) { | 3350 static inline ReplacementPart SubjectSuffix(int subject_length) { |
3351 return ReplacementPart(SUBJECT_SUFFIX, subject_length); | 3351 return ReplacementPart(SUBJECT_SUFFIX, subject_length); |
3352 } | 3352 } |
3353 static inline ReplacementPart ReplacementString() { | 3353 static inline ReplacementPart ReplacementString() { |
3354 return ReplacementPart(REPLACEMENT_STRING, 0); | 3354 return ReplacementPart(REPLACEMENT_STRING, 0); |
3355 } | 3355 } |
3356 static inline ReplacementPart ReplacementSubString(int from, int to) { | 3356 static inline ReplacementPart ReplacementSubString(int from, int to) { |
3357 ASSERT(from >= 0); | 3357 DCHECK(from >= 0); |
3358 ASSERT(to > from); | 3358 DCHECK(to > from); |
3359 return ReplacementPart(-from, to); | 3359 return ReplacementPart(-from, to); |
3360 } | 3360 } |
3361 | 3361 |
3362 // If tag <= 0 then it is the negation of a start index of a substring of | 3362 // If tag <= 0 then it is the negation of a start index of a substring of |
3363 // the replacement pattern, otherwise it's a value from PartType. | 3363 // the replacement pattern, otherwise it's a value from PartType. |
3364 ReplacementPart(int tag, int data) | 3364 ReplacementPart(int tag, int data) |
3365 : tag(tag), data(data) { | 3365 : tag(tag), data(data) { |
3366 // Must be non-positive or a PartType value. | 3366 // Must be non-positive or a PartType value. |
3367 ASSERT(tag < NUMBER_OF_PART_TYPES); | 3367 DCHECK(tag < NUMBER_OF_PART_TYPES); |
3368 } | 3368 } |
3369 // Either a value of PartType or a non-positive number that is | 3369 // Either a value of PartType or a non-positive number that is |
3370 // the negation of an index into the replacement string. | 3370 // the negation of an index into the replacement string. |
3371 int tag; | 3371 int tag; |
3372 // The data value's interpretation depends on the value of tag: | 3372 // The data value's interpretation depends on the value of tag: |
3373 // tag == SUBJECT_PREFIX || | 3373 // tag == SUBJECT_PREFIX || |
3374 // tag == SUBJECT_SUFFIX: data is unused. | 3374 // tag == SUBJECT_SUFFIX: data is unused. |
3375 // tag == SUBJECT_CAPTURE: data is the number of the capture. | 3375 // tag == SUBJECT_CAPTURE: data is the number of the capture. |
3376 // tag == REPLACEMENT_SUBSTRING || | 3376 // tag == REPLACEMENT_SUBSTRING || |
3377 // tag == REPLACEMENT_STRING: data is index into array of substrings | 3377 // tag == REPLACEMENT_STRING: data is index into array of substrings |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3460 if (double_digit_ref <= capture_count) { | 3460 if (double_digit_ref <= capture_count) { |
3461 next_index = second_digit_index; | 3461 next_index = second_digit_index; |
3462 capture_ref = double_digit_ref; | 3462 capture_ref = double_digit_ref; |
3463 } | 3463 } |
3464 } | 3464 } |
3465 } | 3465 } |
3466 if (capture_ref > 0) { | 3466 if (capture_ref > 0) { |
3467 if (i > last) { | 3467 if (i > last) { |
3468 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone); | 3468 parts->Add(ReplacementPart::ReplacementSubString(last, i), zone); |
3469 } | 3469 } |
3470 ASSERT(capture_ref <= capture_count); | 3470 DCHECK(capture_ref <= capture_count); |
3471 parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone); | 3471 parts->Add(ReplacementPart::SubjectCapture(capture_ref), zone); |
3472 last = next_index + 1; | 3472 last = next_index + 1; |
3473 } | 3473 } |
3474 i = next_index; | 3474 i = next_index; |
3475 break; | 3475 break; |
3476 } | 3476 } |
3477 default: | 3477 default: |
3478 i = next_index; | 3478 i = next_index; |
3479 break; | 3479 break; |
3480 } | 3480 } |
(...skipping 15 matching lines...) Expand all Loading... |
3496 Zone* zone_; | 3496 Zone* zone_; |
3497 }; | 3497 }; |
3498 | 3498 |
3499 | 3499 |
3500 bool CompiledReplacement::Compile(Handle<String> replacement, | 3500 bool CompiledReplacement::Compile(Handle<String> replacement, |
3501 int capture_count, | 3501 int capture_count, |
3502 int subject_length) { | 3502 int subject_length) { |
3503 { | 3503 { |
3504 DisallowHeapAllocation no_gc; | 3504 DisallowHeapAllocation no_gc; |
3505 String::FlatContent content = replacement->GetFlatContent(); | 3505 String::FlatContent content = replacement->GetFlatContent(); |
3506 ASSERT(content.IsFlat()); | 3506 DCHECK(content.IsFlat()); |
3507 bool simple = false; | 3507 bool simple = false; |
3508 if (content.IsAscii()) { | 3508 if (content.IsAscii()) { |
3509 simple = ParseReplacementPattern(&parts_, | 3509 simple = ParseReplacementPattern(&parts_, |
3510 content.ToOneByteVector(), | 3510 content.ToOneByteVector(), |
3511 capture_count, | 3511 capture_count, |
3512 subject_length, | 3512 subject_length, |
3513 zone()); | 3513 zone()); |
3514 } else { | 3514 } else { |
3515 ASSERT(content.IsTwoByte()); | 3515 DCHECK(content.IsTwoByte()); |
3516 simple = ParseReplacementPattern(&parts_, | 3516 simple = ParseReplacementPattern(&parts_, |
3517 content.ToUC16Vector(), | 3517 content.ToUC16Vector(), |
3518 capture_count, | 3518 capture_count, |
3519 subject_length, | 3519 subject_length, |
3520 zone()); | 3520 zone()); |
3521 } | 3521 } |
3522 if (simple) return true; | 3522 if (simple) return true; |
3523 } | 3523 } |
3524 | 3524 |
3525 Isolate* isolate = replacement->GetIsolate(); | 3525 Isolate* isolate = replacement->GetIsolate(); |
(...skipping 16 matching lines...) Expand all Loading... |
3542 } | 3542 } |
3543 } | 3543 } |
3544 return false; | 3544 return false; |
3545 } | 3545 } |
3546 | 3546 |
3547 | 3547 |
3548 void CompiledReplacement::Apply(ReplacementStringBuilder* builder, | 3548 void CompiledReplacement::Apply(ReplacementStringBuilder* builder, |
3549 int match_from, | 3549 int match_from, |
3550 int match_to, | 3550 int match_to, |
3551 int32_t* match) { | 3551 int32_t* match) { |
3552 ASSERT_LT(0, parts_.length()); | 3552 DCHECK_LT(0, parts_.length()); |
3553 for (int i = 0, n = parts_.length(); i < n; i++) { | 3553 for (int i = 0, n = parts_.length(); i < n; i++) { |
3554 ReplacementPart part = parts_[i]; | 3554 ReplacementPart part = parts_[i]; |
3555 switch (part.tag) { | 3555 switch (part.tag) { |
3556 case SUBJECT_PREFIX: | 3556 case SUBJECT_PREFIX: |
3557 if (match_from > 0) builder->AddSubjectSlice(0, match_from); | 3557 if (match_from > 0) builder->AddSubjectSlice(0, match_from); |
3558 break; | 3558 break; |
3559 case SUBJECT_SUFFIX: { | 3559 case SUBJECT_SUFFIX: { |
3560 int subject_length = part.data; | 3560 int subject_length = part.data; |
3561 if (match_to < subject_length) { | 3561 if (match_to < subject_length) { |
3562 builder->AddSubjectSlice(match_to, subject_length); | 3562 builder->AddSubjectSlice(match_to, subject_length); |
(...skipping 18 matching lines...) Expand all Loading... |
3581 } | 3581 } |
3582 } | 3582 } |
3583 } | 3583 } |
3584 | 3584 |
3585 | 3585 |
3586 void FindAsciiStringIndices(Vector<const uint8_t> subject, | 3586 void FindAsciiStringIndices(Vector<const uint8_t> subject, |
3587 char pattern, | 3587 char pattern, |
3588 ZoneList<int>* indices, | 3588 ZoneList<int>* indices, |
3589 unsigned int limit, | 3589 unsigned int limit, |
3590 Zone* zone) { | 3590 Zone* zone) { |
3591 ASSERT(limit > 0); | 3591 DCHECK(limit > 0); |
3592 // Collect indices of pattern in subject using memchr. | 3592 // Collect indices of pattern in subject using memchr. |
3593 // Stop after finding at most limit values. | 3593 // Stop after finding at most limit values. |
3594 const uint8_t* subject_start = subject.start(); | 3594 const uint8_t* subject_start = subject.start(); |
3595 const uint8_t* subject_end = subject_start + subject.length(); | 3595 const uint8_t* subject_end = subject_start + subject.length(); |
3596 const uint8_t* pos = subject_start; | 3596 const uint8_t* pos = subject_start; |
3597 while (limit > 0) { | 3597 while (limit > 0) { |
3598 pos = reinterpret_cast<const uint8_t*>( | 3598 pos = reinterpret_cast<const uint8_t*>( |
3599 memchr(pos, pattern, subject_end - pos)); | 3599 memchr(pos, pattern, subject_end - pos)); |
3600 if (pos == NULL) return; | 3600 if (pos == NULL) return; |
3601 indices->Add(static_cast<int>(pos - subject_start), zone); | 3601 indices->Add(static_cast<int>(pos - subject_start), zone); |
3602 pos++; | 3602 pos++; |
3603 limit--; | 3603 limit--; |
3604 } | 3604 } |
3605 } | 3605 } |
3606 | 3606 |
3607 | 3607 |
3608 void FindTwoByteStringIndices(const Vector<const uc16> subject, | 3608 void FindTwoByteStringIndices(const Vector<const uc16> subject, |
3609 uc16 pattern, | 3609 uc16 pattern, |
3610 ZoneList<int>* indices, | 3610 ZoneList<int>* indices, |
3611 unsigned int limit, | 3611 unsigned int limit, |
3612 Zone* zone) { | 3612 Zone* zone) { |
3613 ASSERT(limit > 0); | 3613 DCHECK(limit > 0); |
3614 const uc16* subject_start = subject.start(); | 3614 const uc16* subject_start = subject.start(); |
3615 const uc16* subject_end = subject_start + subject.length(); | 3615 const uc16* subject_end = subject_start + subject.length(); |
3616 for (const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) { | 3616 for (const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) { |
3617 if (*pos == pattern) { | 3617 if (*pos == pattern) { |
3618 indices->Add(static_cast<int>(pos - subject_start), zone); | 3618 indices->Add(static_cast<int>(pos - subject_start), zone); |
3619 limit--; | 3619 limit--; |
3620 } | 3620 } |
3621 } | 3621 } |
3622 } | 3622 } |
3623 | 3623 |
3624 | 3624 |
3625 template <typename SubjectChar, typename PatternChar> | 3625 template <typename SubjectChar, typename PatternChar> |
3626 void FindStringIndices(Isolate* isolate, | 3626 void FindStringIndices(Isolate* isolate, |
3627 Vector<const SubjectChar> subject, | 3627 Vector<const SubjectChar> subject, |
3628 Vector<const PatternChar> pattern, | 3628 Vector<const PatternChar> pattern, |
3629 ZoneList<int>* indices, | 3629 ZoneList<int>* indices, |
3630 unsigned int limit, | 3630 unsigned int limit, |
3631 Zone* zone) { | 3631 Zone* zone) { |
3632 ASSERT(limit > 0); | 3632 DCHECK(limit > 0); |
3633 // Collect indices of pattern in subject. | 3633 // Collect indices of pattern in subject. |
3634 // Stop after finding at most limit values. | 3634 // Stop after finding at most limit values. |
3635 int pattern_length = pattern.length(); | 3635 int pattern_length = pattern.length(); |
3636 int index = 0; | 3636 int index = 0; |
3637 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); | 3637 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); |
3638 while (limit > 0) { | 3638 while (limit > 0) { |
3639 index = search.Search(subject, index); | 3639 index = search.Search(subject, index); |
3640 if (index < 0) return; | 3640 if (index < 0) return; |
3641 indices->Add(index, zone); | 3641 indices->Add(index, zone); |
3642 index += pattern_length; | 3642 index += pattern_length; |
3643 limit--; | 3643 limit--; |
3644 } | 3644 } |
3645 } | 3645 } |
3646 | 3646 |
3647 | 3647 |
3648 void FindStringIndicesDispatch(Isolate* isolate, | 3648 void FindStringIndicesDispatch(Isolate* isolate, |
3649 String* subject, | 3649 String* subject, |
3650 String* pattern, | 3650 String* pattern, |
3651 ZoneList<int>* indices, | 3651 ZoneList<int>* indices, |
3652 unsigned int limit, | 3652 unsigned int limit, |
3653 Zone* zone) { | 3653 Zone* zone) { |
3654 { | 3654 { |
3655 DisallowHeapAllocation no_gc; | 3655 DisallowHeapAllocation no_gc; |
3656 String::FlatContent subject_content = subject->GetFlatContent(); | 3656 String::FlatContent subject_content = subject->GetFlatContent(); |
3657 String::FlatContent pattern_content = pattern->GetFlatContent(); | 3657 String::FlatContent pattern_content = pattern->GetFlatContent(); |
3658 ASSERT(subject_content.IsFlat()); | 3658 DCHECK(subject_content.IsFlat()); |
3659 ASSERT(pattern_content.IsFlat()); | 3659 DCHECK(pattern_content.IsFlat()); |
3660 if (subject_content.IsAscii()) { | 3660 if (subject_content.IsAscii()) { |
3661 Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector(); | 3661 Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector(); |
3662 if (pattern_content.IsAscii()) { | 3662 if (pattern_content.IsAscii()) { |
3663 Vector<const uint8_t> pattern_vector = | 3663 Vector<const uint8_t> pattern_vector = |
3664 pattern_content.ToOneByteVector(); | 3664 pattern_content.ToOneByteVector(); |
3665 if (pattern_vector.length() == 1) { | 3665 if (pattern_vector.length() == 1) { |
3666 FindAsciiStringIndices(subject_vector, | 3666 FindAsciiStringIndices(subject_vector, |
3667 pattern_vector[0], | 3667 pattern_vector[0], |
3668 indices, | 3668 indices, |
3669 limit, | 3669 limit, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3725 } | 3725 } |
3726 | 3726 |
3727 | 3727 |
3728 template<typename ResultSeqString> | 3728 template<typename ResultSeqString> |
3729 MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( | 3729 MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( |
3730 Isolate* isolate, | 3730 Isolate* isolate, |
3731 Handle<String> subject, | 3731 Handle<String> subject, |
3732 Handle<JSRegExp> pattern_regexp, | 3732 Handle<JSRegExp> pattern_regexp, |
3733 Handle<String> replacement, | 3733 Handle<String> replacement, |
3734 Handle<JSArray> last_match_info) { | 3734 Handle<JSArray> last_match_info) { |
3735 ASSERT(subject->IsFlat()); | 3735 DCHECK(subject->IsFlat()); |
3736 ASSERT(replacement->IsFlat()); | 3736 DCHECK(replacement->IsFlat()); |
3737 | 3737 |
3738 ZoneScope zone_scope(isolate->runtime_zone()); | 3738 ZoneScope zone_scope(isolate->runtime_zone()); |
3739 ZoneList<int> indices(8, zone_scope.zone()); | 3739 ZoneList<int> indices(8, zone_scope.zone()); |
3740 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); | 3740 DCHECK_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); |
3741 String* pattern = | 3741 String* pattern = |
3742 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); | 3742 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); |
3743 int subject_len = subject->length(); | 3743 int subject_len = subject->length(); |
3744 int pattern_len = pattern->length(); | 3744 int pattern_len = pattern->length(); |
3745 int replacement_len = replacement->length(); | 3745 int replacement_len = replacement->length(); |
3746 | 3746 |
3747 FindStringIndicesDispatch( | 3747 FindStringIndicesDispatch( |
3748 isolate, *subject, pattern, &indices, 0xffffffff, zone_scope.zone()); | 3748 isolate, *subject, pattern, &indices, 0xffffffff, zone_scope.zone()); |
3749 | 3749 |
3750 int matches = indices.length(); | 3750 int matches = indices.length(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3813 return *result; | 3813 return *result; |
3814 } | 3814 } |
3815 | 3815 |
3816 | 3816 |
3817 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString( | 3817 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString( |
3818 Isolate* isolate, | 3818 Isolate* isolate, |
3819 Handle<String> subject, | 3819 Handle<String> subject, |
3820 Handle<JSRegExp> regexp, | 3820 Handle<JSRegExp> regexp, |
3821 Handle<String> replacement, | 3821 Handle<String> replacement, |
3822 Handle<JSArray> last_match_info) { | 3822 Handle<JSArray> last_match_info) { |
3823 ASSERT(subject->IsFlat()); | 3823 DCHECK(subject->IsFlat()); |
3824 ASSERT(replacement->IsFlat()); | 3824 DCHECK(replacement->IsFlat()); |
3825 | 3825 |
3826 int capture_count = regexp->CaptureCount(); | 3826 int capture_count = regexp->CaptureCount(); |
3827 int subject_length = subject->length(); | 3827 int subject_length = subject->length(); |
3828 | 3828 |
3829 // CompiledReplacement uses zone allocation. | 3829 // CompiledReplacement uses zone allocation. |
3830 ZoneScope zone_scope(isolate->runtime_zone()); | 3830 ZoneScope zone_scope(isolate->runtime_zone()); |
3831 CompiledReplacement compiled_replacement(zone_scope.zone()); | 3831 CompiledReplacement compiled_replacement(zone_scope.zone()); |
3832 bool simple_replace = compiled_replacement.Compile(replacement, | 3832 bool simple_replace = compiled_replacement.Compile(replacement, |
3833 capture_count, | 3833 capture_count, |
3834 subject_length); | 3834 subject_length); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3909 return *result; | 3909 return *result; |
3910 } | 3910 } |
3911 | 3911 |
3912 | 3912 |
3913 template <typename ResultSeqString> | 3913 template <typename ResultSeqString> |
3914 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( | 3914 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( |
3915 Isolate* isolate, | 3915 Isolate* isolate, |
3916 Handle<String> subject, | 3916 Handle<String> subject, |
3917 Handle<JSRegExp> regexp, | 3917 Handle<JSRegExp> regexp, |
3918 Handle<JSArray> last_match_info) { | 3918 Handle<JSArray> last_match_info) { |
3919 ASSERT(subject->IsFlat()); | 3919 DCHECK(subject->IsFlat()); |
3920 | 3920 |
3921 // Shortcut for simple non-regexp global replacements | 3921 // Shortcut for simple non-regexp global replacements |
3922 if (regexp->TypeTag() == JSRegExp::ATOM) { | 3922 if (regexp->TypeTag() == JSRegExp::ATOM) { |
3923 Handle<String> empty_string = isolate->factory()->empty_string(); | 3923 Handle<String> empty_string = isolate->factory()->empty_string(); |
3924 if (subject->IsOneByteRepresentation()) { | 3924 if (subject->IsOneByteRepresentation()) { |
3925 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( | 3925 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( |
3926 isolate, subject, regexp, empty_string, last_match_info); | 3926 isolate, subject, regexp, empty_string, last_match_info); |
3927 } else { | 3927 } else { |
3928 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( | 3928 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( |
3929 isolate, subject, regexp, empty_string, last_match_info); | 3929 isolate, subject, regexp, empty_string, last_match_info); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4004 // thread can not get confused with the filler creation. No synchronization | 4004 // thread can not get confused with the filler creation. No synchronization |
4005 // needed. | 4005 // needed. |
4006 heap->CreateFillerObjectAt(end_of_string, delta); | 4006 heap->CreateFillerObjectAt(end_of_string, delta); |
4007 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); | 4007 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); |
4008 return *answer; | 4008 return *answer; |
4009 } | 4009 } |
4010 | 4010 |
4011 | 4011 |
4012 RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) { | 4012 RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) { |
4013 HandleScope scope(isolate); | 4013 HandleScope scope(isolate); |
4014 ASSERT(args.length() == 4); | 4014 DCHECK(args.length() == 4); |
4015 | 4015 |
4016 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4016 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
4017 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); | 4017 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); |
4018 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 4018 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
4019 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 4019 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
4020 | 4020 |
4021 RUNTIME_ASSERT(regexp->GetFlags().is_global()); | 4021 RUNTIME_ASSERT(regexp->GetFlags().is_global()); |
4022 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); | 4022 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); |
4023 | 4023 |
4024 subject = String::Flatten(subject); | 4024 subject = String::Flatten(subject); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4086 String); | 4086 String); |
4087 Handle<String> second = | 4087 Handle<String> second = |
4088 isolate->factory()->NewSubString(subject, index + 1, subject->length()); | 4088 isolate->factory()->NewSubString(subject, index + 1, subject->length()); |
4089 return isolate->factory()->NewConsString(cons1, second); | 4089 return isolate->factory()->NewConsString(cons1, second); |
4090 } | 4090 } |
4091 } | 4091 } |
4092 | 4092 |
4093 | 4093 |
4094 RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) { | 4094 RUNTIME_FUNCTION(Runtime_StringReplaceOneCharWithString) { |
4095 HandleScope scope(isolate); | 4095 HandleScope scope(isolate); |
4096 ASSERT(args.length() == 3); | 4096 DCHECK(args.length() == 3); |
4097 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4097 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
4098 CONVERT_ARG_HANDLE_CHECKED(String, search, 1); | 4098 CONVERT_ARG_HANDLE_CHECKED(String, search, 1); |
4099 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2); | 4099 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2); |
4100 | 4100 |
4101 // If the cons string tree is too deep, we simply abort the recursion and | 4101 // If the cons string tree is too deep, we simply abort the recursion and |
4102 // retry with a flattened subject string. | 4102 // retry with a flattened subject string. |
4103 const int kRecursionLimit = 0x1000; | 4103 const int kRecursionLimit = 0x1000; |
4104 bool found = false; | 4104 bool found = false; |
4105 Handle<String> result; | 4105 Handle<String> result; |
4106 if (StringReplaceOneCharWithString( | 4106 if (StringReplaceOneCharWithString( |
(...skipping 12 matching lines...) Expand all Loading... |
4119 } | 4119 } |
4120 | 4120 |
4121 | 4121 |
4122 // Perform string match of pattern on subject, starting at start index. | 4122 // Perform string match of pattern on subject, starting at start index. |
4123 // Caller must ensure that 0 <= start_index <= sub->length(), | 4123 // Caller must ensure that 0 <= start_index <= sub->length(), |
4124 // and should check that pat->length() + start_index <= sub->length(). | 4124 // and should check that pat->length() + start_index <= sub->length(). |
4125 int Runtime::StringMatch(Isolate* isolate, | 4125 int Runtime::StringMatch(Isolate* isolate, |
4126 Handle<String> sub, | 4126 Handle<String> sub, |
4127 Handle<String> pat, | 4127 Handle<String> pat, |
4128 int start_index) { | 4128 int start_index) { |
4129 ASSERT(0 <= start_index); | 4129 DCHECK(0 <= start_index); |
4130 ASSERT(start_index <= sub->length()); | 4130 DCHECK(start_index <= sub->length()); |
4131 | 4131 |
4132 int pattern_length = pat->length(); | 4132 int pattern_length = pat->length(); |
4133 if (pattern_length == 0) return start_index; | 4133 if (pattern_length == 0) return start_index; |
4134 | 4134 |
4135 int subject_length = sub->length(); | 4135 int subject_length = sub->length(); |
4136 if (start_index + pattern_length > subject_length) return -1; | 4136 if (start_index + pattern_length > subject_length) return -1; |
4137 | 4137 |
4138 sub = String::Flatten(sub); | 4138 sub = String::Flatten(sub); |
4139 pat = String::Flatten(pat); | 4139 pat = String::Flatten(pat); |
4140 | 4140 |
(...skipping 25 matching lines...) Expand all Loading... |
4166 } | 4166 } |
4167 return SearchString(isolate, | 4167 return SearchString(isolate, |
4168 seq_sub.ToUC16Vector(), | 4168 seq_sub.ToUC16Vector(), |
4169 pat_vector, | 4169 pat_vector, |
4170 start_index); | 4170 start_index); |
4171 } | 4171 } |
4172 | 4172 |
4173 | 4173 |
4174 RUNTIME_FUNCTION(Runtime_StringIndexOf) { | 4174 RUNTIME_FUNCTION(Runtime_StringIndexOf) { |
4175 HandleScope scope(isolate); | 4175 HandleScope scope(isolate); |
4176 ASSERT(args.length() == 3); | 4176 DCHECK(args.length() == 3); |
4177 | 4177 |
4178 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 4178 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |
4179 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 4179 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |
4180 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 4180 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |
4181 | 4181 |
4182 uint32_t start_index; | 4182 uint32_t start_index; |
4183 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 4183 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
4184 | 4184 |
4185 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); | 4185 RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); |
4186 int position = Runtime::StringMatch(isolate, sub, pat, start_index); | 4186 int position = Runtime::StringMatch(isolate, sub, pat, start_index); |
4187 return Smi::FromInt(position); | 4187 return Smi::FromInt(position); |
4188 } | 4188 } |
4189 | 4189 |
4190 | 4190 |
4191 template <typename schar, typename pchar> | 4191 template <typename schar, typename pchar> |
4192 static int StringMatchBackwards(Vector<const schar> subject, | 4192 static int StringMatchBackwards(Vector<const schar> subject, |
4193 Vector<const pchar> pattern, | 4193 Vector<const pchar> pattern, |
4194 int idx) { | 4194 int idx) { |
4195 int pattern_length = pattern.length(); | 4195 int pattern_length = pattern.length(); |
4196 ASSERT(pattern_length >= 1); | 4196 DCHECK(pattern_length >= 1); |
4197 ASSERT(idx + pattern_length <= subject.length()); | 4197 DCHECK(idx + pattern_length <= subject.length()); |
4198 | 4198 |
4199 if (sizeof(schar) == 1 && sizeof(pchar) > 1) { | 4199 if (sizeof(schar) == 1 && sizeof(pchar) > 1) { |
4200 for (int i = 0; i < pattern_length; i++) { | 4200 for (int i = 0; i < pattern_length; i++) { |
4201 uc16 c = pattern[i]; | 4201 uc16 c = pattern[i]; |
4202 if (c > String::kMaxOneByteCharCode) { | 4202 if (c > String::kMaxOneByteCharCode) { |
4203 return -1; | 4203 return -1; |
4204 } | 4204 } |
4205 } | 4205 } |
4206 } | 4206 } |
4207 | 4207 |
(...skipping 10 matching lines...) Expand all Loading... |
4218 if (j == pattern_length) { | 4218 if (j == pattern_length) { |
4219 return i; | 4219 return i; |
4220 } | 4220 } |
4221 } | 4221 } |
4222 return -1; | 4222 return -1; |
4223 } | 4223 } |
4224 | 4224 |
4225 | 4225 |
4226 RUNTIME_FUNCTION(Runtime_StringLastIndexOf) { | 4226 RUNTIME_FUNCTION(Runtime_StringLastIndexOf) { |
4227 HandleScope scope(isolate); | 4227 HandleScope scope(isolate); |
4228 ASSERT(args.length() == 3); | 4228 DCHECK(args.length() == 3); |
4229 | 4229 |
4230 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 4230 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |
4231 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 4231 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |
4232 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 4232 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |
4233 | 4233 |
4234 uint32_t start_index; | 4234 uint32_t start_index; |
4235 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 4235 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
4236 | 4236 |
4237 uint32_t pat_length = pat->length(); | 4237 uint32_t pat_length = pat->length(); |
4238 uint32_t sub_length = sub->length(); | 4238 uint32_t sub_length = sub->length(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4277 start_index); | 4277 start_index); |
4278 } | 4278 } |
4279 } | 4279 } |
4280 | 4280 |
4281 return Smi::FromInt(position); | 4281 return Smi::FromInt(position); |
4282 } | 4282 } |
4283 | 4283 |
4284 | 4284 |
4285 RUNTIME_FUNCTION(Runtime_StringLocaleCompare) { | 4285 RUNTIME_FUNCTION(Runtime_StringLocaleCompare) { |
4286 HandleScope handle_scope(isolate); | 4286 HandleScope handle_scope(isolate); |
4287 ASSERT(args.length() == 2); | 4287 DCHECK(args.length() == 2); |
4288 | 4288 |
4289 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 4289 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
4290 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 4290 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
4291 | 4291 |
4292 if (str1.is_identical_to(str2)) return Smi::FromInt(0); // Equal. | 4292 if (str1.is_identical_to(str2)) return Smi::FromInt(0); // Equal. |
4293 int str1_length = str1->length(); | 4293 int str1_length = str1->length(); |
4294 int str2_length = str2->length(); | 4294 int str2_length = str2->length(); |
4295 | 4295 |
4296 // Decide trivial cases without flattening. | 4296 // Decide trivial cases without flattening. |
4297 if (str1_length == 0) { | 4297 if (str1_length == 0) { |
(...skipping 23 matching lines...) Expand all Loading... |
4321 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); | 4321 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); |
4322 } | 4322 } |
4323 } | 4323 } |
4324 | 4324 |
4325 return Smi::FromInt(str1_length - str2_length); | 4325 return Smi::FromInt(str1_length - str2_length); |
4326 } | 4326 } |
4327 | 4327 |
4328 | 4328 |
4329 RUNTIME_FUNCTION(Runtime_SubString) { | 4329 RUNTIME_FUNCTION(Runtime_SubString) { |
4330 HandleScope scope(isolate); | 4330 HandleScope scope(isolate); |
4331 ASSERT(args.length() == 3); | 4331 DCHECK(args.length() == 3); |
4332 | 4332 |
4333 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 4333 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
4334 int start, end; | 4334 int start, end; |
4335 // We have a fast integer-only case here to avoid a conversion to double in | 4335 // We have a fast integer-only case here to avoid a conversion to double in |
4336 // the common case where from and to are Smis. | 4336 // the common case where from and to are Smis. |
4337 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 4337 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
4338 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 4338 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
4339 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 4339 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
4340 start = from_number; | 4340 start = from_number; |
4341 end = to_number; | 4341 end = to_number; |
(...skipping 15 matching lines...) Expand all Loading... |
4357 RUNTIME_FUNCTION(Runtime_InternalizeString) { | 4357 RUNTIME_FUNCTION(Runtime_InternalizeString) { |
4358 HandleScope handles(isolate); | 4358 HandleScope handles(isolate); |
4359 RUNTIME_ASSERT(args.length() == 1); | 4359 RUNTIME_ASSERT(args.length() == 1); |
4360 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 4360 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
4361 return *isolate->factory()->InternalizeString(string); | 4361 return *isolate->factory()->InternalizeString(string); |
4362 } | 4362 } |
4363 | 4363 |
4364 | 4364 |
4365 RUNTIME_FUNCTION(Runtime_StringMatch) { | 4365 RUNTIME_FUNCTION(Runtime_StringMatch) { |
4366 HandleScope handles(isolate); | 4366 HandleScope handles(isolate); |
4367 ASSERT(args.length() == 3); | 4367 DCHECK(args.length() == 3); |
4368 | 4368 |
4369 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4369 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
4370 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 4370 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
4371 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); | 4371 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); |
4372 | 4372 |
4373 RUNTIME_ASSERT(regexp_info->HasFastObjectElements()); | 4373 RUNTIME_ASSERT(regexp_info->HasFastObjectElements()); |
4374 | 4374 |
4375 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4375 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
4376 if (global_cache.HasException()) return isolate->heap()->exception(); | 4376 if (global_cache.HasException()) return isolate->heap()->exception(); |
4377 | 4377 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4420 | 4420 |
4421 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain | 4421 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain |
4422 // separate last match info. See comment on that function. | 4422 // separate last match info. See comment on that function. |
4423 template<bool has_capture> | 4423 template<bool has_capture> |
4424 static Object* SearchRegExpMultiple( | 4424 static Object* SearchRegExpMultiple( |
4425 Isolate* isolate, | 4425 Isolate* isolate, |
4426 Handle<String> subject, | 4426 Handle<String> subject, |
4427 Handle<JSRegExp> regexp, | 4427 Handle<JSRegExp> regexp, |
4428 Handle<JSArray> last_match_array, | 4428 Handle<JSArray> last_match_array, |
4429 Handle<JSArray> result_array) { | 4429 Handle<JSArray> result_array) { |
4430 ASSERT(subject->IsFlat()); | 4430 DCHECK(subject->IsFlat()); |
4431 ASSERT_NE(has_capture, regexp->CaptureCount() == 0); | 4431 DCHECK_NE(has_capture, regexp->CaptureCount() == 0); |
4432 | 4432 |
4433 int capture_count = regexp->CaptureCount(); | 4433 int capture_count = regexp->CaptureCount(); |
4434 int subject_length = subject->length(); | 4434 int subject_length = subject->length(); |
4435 | 4435 |
4436 static const int kMinLengthToCache = 0x1000; | 4436 static const int kMinLengthToCache = 0x1000; |
4437 | 4437 |
4438 if (subject_length > kMinLengthToCache) { | 4438 if (subject_length > kMinLengthToCache) { |
4439 Handle<Object> cached_answer(RegExpResultsCache::Lookup( | 4439 Handle<Object> cached_answer(RegExpResultsCache::Lookup( |
4440 isolate->heap(), | 4440 isolate->heap(), |
4441 *subject, | 4441 *subject, |
(...skipping 13 matching lines...) Expand all Loading... |
4455 RegExpImpl::SetLastMatchInfo( | 4455 RegExpImpl::SetLastMatchInfo( |
4456 last_match_array, subject, capture_count, NULL); | 4456 last_match_array, subject, capture_count, NULL); |
4457 return *result_array; | 4457 return *result_array; |
4458 } | 4458 } |
4459 } | 4459 } |
4460 | 4460 |
4461 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4461 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
4462 if (global_cache.HasException()) return isolate->heap()->exception(); | 4462 if (global_cache.HasException()) return isolate->heap()->exception(); |
4463 | 4463 |
4464 // Ensured in Runtime_RegExpExecMultiple. | 4464 // Ensured in Runtime_RegExpExecMultiple. |
4465 ASSERT(result_array->HasFastObjectElements()); | 4465 DCHECK(result_array->HasFastObjectElements()); |
4466 Handle<FixedArray> result_elements( | 4466 Handle<FixedArray> result_elements( |
4467 FixedArray::cast(result_array->elements())); | 4467 FixedArray::cast(result_array->elements())); |
4468 if (result_elements->length() < 16) { | 4468 if (result_elements->length() < 16) { |
4469 result_elements = isolate->factory()->NewFixedArrayWithHoles(16); | 4469 result_elements = isolate->factory()->NewFixedArrayWithHoles(16); |
4470 } | 4470 } |
4471 | 4471 |
4472 FixedArrayBuilder builder(result_elements); | 4472 FixedArrayBuilder builder(result_elements); |
4473 | 4473 |
4474 // Position to search from. | 4474 // Position to search from. |
4475 int match_start = -1; | 4475 int match_start = -1; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4509 // Arguments array to replace function is match, captures, index and | 4509 // Arguments array to replace function is match, captures, index and |
4510 // subject, i.e., 3 + capture count in total. | 4510 // subject, i.e., 3 + capture count in total. |
4511 Handle<FixedArray> elements = | 4511 Handle<FixedArray> elements = |
4512 isolate->factory()->NewFixedArray(3 + capture_count); | 4512 isolate->factory()->NewFixedArray(3 + capture_count); |
4513 | 4513 |
4514 elements->set(0, *match); | 4514 elements->set(0, *match); |
4515 for (int i = 1; i <= capture_count; i++) { | 4515 for (int i = 1; i <= capture_count; i++) { |
4516 int start = current_match[i * 2]; | 4516 int start = current_match[i * 2]; |
4517 if (start >= 0) { | 4517 if (start >= 0) { |
4518 int end = current_match[i * 2 + 1]; | 4518 int end = current_match[i * 2 + 1]; |
4519 ASSERT(start <= end); | 4519 DCHECK(start <= end); |
4520 Handle<String> substring = | 4520 Handle<String> substring = |
4521 isolate->factory()->NewSubString(subject, start, end); | 4521 isolate->factory()->NewSubString(subject, start, end); |
4522 elements->set(i, *substring); | 4522 elements->set(i, *substring); |
4523 } else { | 4523 } else { |
4524 ASSERT(current_match[i * 2 + 1] < 0); | 4524 DCHECK(current_match[i * 2 + 1] < 0); |
4525 elements->set(i, isolate->heap()->undefined_value()); | 4525 elements->set(i, isolate->heap()->undefined_value()); |
4526 } | 4526 } |
4527 } | 4527 } |
4528 elements->set(capture_count + 1, Smi::FromInt(match_start)); | 4528 elements->set(capture_count + 1, Smi::FromInt(match_start)); |
4529 elements->set(capture_count + 2, *subject); | 4529 elements->set(capture_count + 2, *subject); |
4530 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements)); | 4530 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements)); |
4531 } else { | 4531 } else { |
4532 builder.Add(*match); | 4532 builder.Add(*match); |
4533 } | 4533 } |
4534 } | 4534 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4566 return isolate->heap()->null_value(); // No matches at all. | 4566 return isolate->heap()->null_value(); // No matches at all. |
4567 } | 4567 } |
4568 } | 4568 } |
4569 | 4569 |
4570 | 4570 |
4571 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets | 4571 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets |
4572 // lastMatchInfoOverride to maintain the last match info, so we don't need to | 4572 // lastMatchInfoOverride to maintain the last match info, so we don't need to |
4573 // set any other last match array info. | 4573 // set any other last match array info. |
4574 RUNTIME_FUNCTION(Runtime_RegExpExecMultiple) { | 4574 RUNTIME_FUNCTION(Runtime_RegExpExecMultiple) { |
4575 HandleScope handles(isolate); | 4575 HandleScope handles(isolate); |
4576 ASSERT(args.length() == 4); | 4576 DCHECK(args.length() == 4); |
4577 | 4577 |
4578 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 4578 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
4579 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 4579 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
4580 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); | 4580 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); |
4581 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); | 4581 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); |
4582 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); | 4582 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); |
4583 RUNTIME_ASSERT(result_array->HasFastObjectElements()); | 4583 RUNTIME_ASSERT(result_array->HasFastObjectElements()); |
4584 | 4584 |
4585 subject = String::Flatten(subject); | 4585 subject = String::Flatten(subject); |
4586 RUNTIME_ASSERT(regexp->GetFlags().is_global()); | 4586 RUNTIME_ASSERT(regexp->GetFlags().is_global()); |
4587 | 4587 |
4588 if (regexp->CaptureCount() == 0) { | 4588 if (regexp->CaptureCount() == 0) { |
4589 return SearchRegExpMultiple<false>( | 4589 return SearchRegExpMultiple<false>( |
4590 isolate, subject, regexp, last_match_info, result_array); | 4590 isolate, subject, regexp, last_match_info, result_array); |
4591 } else { | 4591 } else { |
4592 return SearchRegExpMultiple<true>( | 4592 return SearchRegExpMultiple<true>( |
4593 isolate, subject, regexp, last_match_info, result_array); | 4593 isolate, subject, regexp, last_match_info, result_array); |
4594 } | 4594 } |
4595 } | 4595 } |
4596 | 4596 |
4597 | 4597 |
4598 RUNTIME_FUNCTION(Runtime_NumberToRadixString) { | 4598 RUNTIME_FUNCTION(Runtime_NumberToRadixString) { |
4599 HandleScope scope(isolate); | 4599 HandleScope scope(isolate); |
4600 ASSERT(args.length() == 2); | 4600 DCHECK(args.length() == 2); |
4601 CONVERT_SMI_ARG_CHECKED(radix, 1); | 4601 CONVERT_SMI_ARG_CHECKED(radix, 1); |
4602 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 4602 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
4603 | 4603 |
4604 // Fast case where the result is a one character string. | 4604 // Fast case where the result is a one character string. |
4605 if (args[0]->IsSmi()) { | 4605 if (args[0]->IsSmi()) { |
4606 int value = args.smi_at(0); | 4606 int value = args.smi_at(0); |
4607 if (value >= 0 && value < radix) { | 4607 if (value >= 0 && value < radix) { |
4608 // Character array used for conversion. | 4608 // Character array used for conversion. |
4609 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; | 4609 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; |
4610 return *isolate->factory()-> | 4610 return *isolate->factory()-> |
(...skipping 14 matching lines...) Expand all Loading... |
4625 } | 4625 } |
4626 char* str = DoubleToRadixCString(value, radix); | 4626 char* str = DoubleToRadixCString(value, radix); |
4627 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4627 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4628 DeleteArray(str); | 4628 DeleteArray(str); |
4629 return *result; | 4629 return *result; |
4630 } | 4630 } |
4631 | 4631 |
4632 | 4632 |
4633 RUNTIME_FUNCTION(Runtime_NumberToFixed) { | 4633 RUNTIME_FUNCTION(Runtime_NumberToFixed) { |
4634 HandleScope scope(isolate); | 4634 HandleScope scope(isolate); |
4635 ASSERT(args.length() == 2); | 4635 DCHECK(args.length() == 2); |
4636 | 4636 |
4637 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4637 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4638 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4638 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4639 int f = FastD2IChecked(f_number); | 4639 int f = FastD2IChecked(f_number); |
4640 // See DoubleToFixedCString for these constants: | 4640 // See DoubleToFixedCString for these constants: |
4641 RUNTIME_ASSERT(f >= 0 && f <= 20); | 4641 RUNTIME_ASSERT(f >= 0 && f <= 20); |
4642 RUNTIME_ASSERT(!Double(value).IsSpecial()); | 4642 RUNTIME_ASSERT(!Double(value).IsSpecial()); |
4643 char* str = DoubleToFixedCString(value, f); | 4643 char* str = DoubleToFixedCString(value, f); |
4644 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4644 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4645 DeleteArray(str); | 4645 DeleteArray(str); |
4646 return *result; | 4646 return *result; |
4647 } | 4647 } |
4648 | 4648 |
4649 | 4649 |
4650 RUNTIME_FUNCTION(Runtime_NumberToExponential) { | 4650 RUNTIME_FUNCTION(Runtime_NumberToExponential) { |
4651 HandleScope scope(isolate); | 4651 HandleScope scope(isolate); |
4652 ASSERT(args.length() == 2); | 4652 DCHECK(args.length() == 2); |
4653 | 4653 |
4654 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4654 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4655 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4655 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4656 int f = FastD2IChecked(f_number); | 4656 int f = FastD2IChecked(f_number); |
4657 RUNTIME_ASSERT(f >= -1 && f <= 20); | 4657 RUNTIME_ASSERT(f >= -1 && f <= 20); |
4658 RUNTIME_ASSERT(!Double(value).IsSpecial()); | 4658 RUNTIME_ASSERT(!Double(value).IsSpecial()); |
4659 char* str = DoubleToExponentialCString(value, f); | 4659 char* str = DoubleToExponentialCString(value, f); |
4660 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4660 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4661 DeleteArray(str); | 4661 DeleteArray(str); |
4662 return *result; | 4662 return *result; |
4663 } | 4663 } |
4664 | 4664 |
4665 | 4665 |
4666 RUNTIME_FUNCTION(Runtime_NumberToPrecision) { | 4666 RUNTIME_FUNCTION(Runtime_NumberToPrecision) { |
4667 HandleScope scope(isolate); | 4667 HandleScope scope(isolate); |
4668 ASSERT(args.length() == 2); | 4668 DCHECK(args.length() == 2); |
4669 | 4669 |
4670 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4670 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4671 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4671 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4672 int f = FastD2IChecked(f_number); | 4672 int f = FastD2IChecked(f_number); |
4673 RUNTIME_ASSERT(f >= 1 && f <= 21); | 4673 RUNTIME_ASSERT(f >= 1 && f <= 21); |
4674 RUNTIME_ASSERT(!Double(value).IsSpecial()); | 4674 RUNTIME_ASSERT(!Double(value).IsSpecial()); |
4675 char* str = DoubleToPrecisionCString(value, f); | 4675 char* str = DoubleToPrecisionCString(value, f); |
4676 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4676 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4677 DeleteArray(str); | 4677 DeleteArray(str); |
4678 return *result; | 4678 return *result; |
4679 } | 4679 } |
4680 | 4680 |
4681 | 4681 |
4682 RUNTIME_FUNCTION(Runtime_IsValidSmi) { | 4682 RUNTIME_FUNCTION(Runtime_IsValidSmi) { |
4683 SealHandleScope shs(isolate); | 4683 SealHandleScope shs(isolate); |
4684 ASSERT(args.length() == 1); | 4684 DCHECK(args.length() == 1); |
4685 | 4685 |
4686 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); | 4686 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); |
4687 return isolate->heap()->ToBoolean(Smi::IsValid(number)); | 4687 return isolate->heap()->ToBoolean(Smi::IsValid(number)); |
4688 } | 4688 } |
4689 | 4689 |
4690 | 4690 |
4691 // Returns a single character string where first character equals | 4691 // Returns a single character string where first character equals |
4692 // string->Get(index). | 4692 // string->Get(index). |
4693 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { | 4693 static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { |
4694 if (index < static_cast<uint32_t>(string->length())) { | 4694 if (index < static_cast<uint32_t>(string->length())) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4787 if (name->AsArrayIndex(&index)) { | 4787 if (name->AsArrayIndex(&index)) { |
4788 return GetElementOrCharAt(isolate, object, index); | 4788 return GetElementOrCharAt(isolate, object, index); |
4789 } else { | 4789 } else { |
4790 return Object::GetProperty(object, name); | 4790 return Object::GetProperty(object, name); |
4791 } | 4791 } |
4792 } | 4792 } |
4793 | 4793 |
4794 | 4794 |
4795 RUNTIME_FUNCTION(Runtime_GetProperty) { | 4795 RUNTIME_FUNCTION(Runtime_GetProperty) { |
4796 HandleScope scope(isolate); | 4796 HandleScope scope(isolate); |
4797 ASSERT(args.length() == 2); | 4797 DCHECK(args.length() == 2); |
4798 | 4798 |
4799 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 4799 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
4800 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 4800 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
4801 Handle<Object> result; | 4801 Handle<Object> result; |
4802 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 4802 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
4803 isolate, result, | 4803 isolate, result, |
4804 Runtime::GetObjectProperty(isolate, object, key)); | 4804 Runtime::GetObjectProperty(isolate, object, key)); |
4805 return *result; | 4805 return *result; |
4806 } | 4806 } |
4807 | 4807 |
4808 | 4808 |
4809 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 4809 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
4810 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { | 4810 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
4811 HandleScope scope(isolate); | 4811 HandleScope scope(isolate); |
4812 ASSERT(args.length() == 2); | 4812 DCHECK(args.length() == 2); |
4813 | 4813 |
4814 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 4814 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
4815 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 4815 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
4816 | 4816 |
4817 // Fast cases for getting named properties of the receiver JSObject | 4817 // Fast cases for getting named properties of the receiver JSObject |
4818 // itself. | 4818 // itself. |
4819 // | 4819 // |
4820 // The global proxy objects has to be excluded since LookupOwn on | 4820 // The global proxy objects has to be excluded since LookupOwn on |
4821 // the global proxy object can return a valid result even though the | 4821 // the global proxy object can return a valid result even though the |
4822 // global proxy object never has properties. This is the case | 4822 // global proxy object never has properties. This is the case |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4885 if (key->value() >= js_object->elements()->length()) { | 4885 if (key->value() >= js_object->elements()->length()) { |
4886 if (IsFastHoleyElementsKind(elements_kind)) { | 4886 if (IsFastHoleyElementsKind(elements_kind)) { |
4887 elements_kind = FAST_HOLEY_ELEMENTS; | 4887 elements_kind = FAST_HOLEY_ELEMENTS; |
4888 } else { | 4888 } else { |
4889 elements_kind = FAST_ELEMENTS; | 4889 elements_kind = FAST_ELEMENTS; |
4890 } | 4890 } |
4891 RETURN_FAILURE_ON_EXCEPTION( | 4891 RETURN_FAILURE_ON_EXCEPTION( |
4892 isolate, TransitionElements(js_object, elements_kind, isolate)); | 4892 isolate, TransitionElements(js_object, elements_kind, isolate)); |
4893 } | 4893 } |
4894 } else { | 4894 } else { |
4895 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || | 4895 DCHECK(IsFastSmiOrObjectElementsKind(elements_kind) || |
4896 !IsFastElementsKind(elements_kind)); | 4896 !IsFastElementsKind(elements_kind)); |
4897 } | 4897 } |
4898 } | 4898 } |
4899 } else if (receiver_obj->IsString() && key_obj->IsSmi()) { | 4899 } else if (receiver_obj->IsString() && key_obj->IsSmi()) { |
4900 // Fast case for string indexing using [] with a smi index. | 4900 // Fast case for string indexing using [] with a smi index. |
4901 Handle<String> str = Handle<String>::cast(receiver_obj); | 4901 Handle<String> str = Handle<String>::cast(receiver_obj); |
4902 int index = args.smi_at(1); | 4902 int index = args.smi_at(1); |
4903 if (index >= 0 && index < str->length()) { | 4903 if (index >= 0 && index < str->length()) { |
4904 return *GetCharAt(str, index); | 4904 return *GetCharAt(str, index); |
4905 } | 4905 } |
(...skipping 18 matching lines...) Expand all Loading... |
4924 Handle<Object> component) { | 4924 Handle<Object> component) { |
4925 if (component->IsUndefined()) return isolate->factory()->null_value(); | 4925 if (component->IsUndefined()) return isolate->factory()->null_value(); |
4926 Handle<FunctionTemplateInfo> info = | 4926 Handle<FunctionTemplateInfo> info = |
4927 Handle<FunctionTemplateInfo>::cast(component); | 4927 Handle<FunctionTemplateInfo>::cast(component); |
4928 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); | 4928 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); |
4929 } | 4929 } |
4930 | 4930 |
4931 | 4931 |
4932 RUNTIME_FUNCTION(Runtime_DefineApiAccessorProperty) { | 4932 RUNTIME_FUNCTION(Runtime_DefineApiAccessorProperty) { |
4933 HandleScope scope(isolate); | 4933 HandleScope scope(isolate); |
4934 ASSERT(args.length() == 5); | 4934 DCHECK(args.length() == 5); |
4935 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 4935 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
4936 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 4936 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
4937 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 4937 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
4938 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 4938 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
4939 CONVERT_SMI_ARG_CHECKED(attribute, 4); | 4939 CONVERT_SMI_ARG_CHECKED(attribute, 4); |
4940 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); | 4940 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); |
4941 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); | 4941 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); |
4942 RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid( | 4942 RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid( |
4943 static_cast<PropertyAttributes>(attribute))); | 4943 static_cast<PropertyAttributes>(attribute))); |
4944 RETURN_FAILURE_ON_EXCEPTION( | 4944 RETURN_FAILURE_ON_EXCEPTION( |
4945 isolate, JSObject::DefineAccessor( | 4945 isolate, JSObject::DefineAccessor( |
4946 object, name, InstantiateAccessorComponent(isolate, getter), | 4946 object, name, InstantiateAccessorComponent(isolate, getter), |
4947 InstantiateAccessorComponent(isolate, setter), | 4947 InstantiateAccessorComponent(isolate, setter), |
4948 static_cast<PropertyAttributes>(attribute))); | 4948 static_cast<PropertyAttributes>(attribute))); |
4949 return isolate->heap()->undefined_value(); | 4949 return isolate->heap()->undefined_value(); |
4950 } | 4950 } |
4951 | 4951 |
4952 | 4952 |
4953 // Implements part of 8.12.9 DefineOwnProperty. | 4953 // Implements part of 8.12.9 DefineOwnProperty. |
4954 // There are 3 cases that lead here: | 4954 // There are 3 cases that lead here: |
4955 // Step 4b - define a new accessor property. | 4955 // Step 4b - define a new accessor property. |
4956 // Steps 9c & 12 - replace an existing data property with an accessor property. | 4956 // Steps 9c & 12 - replace an existing data property with an accessor property. |
4957 // Step 12 - update an existing accessor property with an accessor or generic | 4957 // Step 12 - update an existing accessor property with an accessor or generic |
4958 // descriptor. | 4958 // descriptor. |
4959 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { | 4959 RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { |
4960 HandleScope scope(isolate); | 4960 HandleScope scope(isolate); |
4961 ASSERT(args.length() == 5); | 4961 DCHECK(args.length() == 5); |
4962 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 4962 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
4963 RUNTIME_ASSERT(!obj->IsNull()); | 4963 RUNTIME_ASSERT(!obj->IsNull()); |
4964 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 4964 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
4965 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 4965 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
4966 RUNTIME_ASSERT(IsValidAccessor(getter)); | 4966 RUNTIME_ASSERT(IsValidAccessor(getter)); |
4967 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 4967 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
4968 RUNTIME_ASSERT(IsValidAccessor(setter)); | 4968 RUNTIME_ASSERT(IsValidAccessor(setter)); |
4969 CONVERT_SMI_ARG_CHECKED(unchecked, 4); | 4969 CONVERT_SMI_ARG_CHECKED(unchecked, 4); |
4970 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4970 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4971 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 4971 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
4972 | 4972 |
4973 bool fast = obj->HasFastProperties(); | 4973 bool fast = obj->HasFastProperties(); |
4974 RETURN_FAILURE_ON_EXCEPTION( | 4974 RETURN_FAILURE_ON_EXCEPTION( |
4975 isolate, JSObject::DefineAccessor(obj, name, getter, setter, attr)); | 4975 isolate, JSObject::DefineAccessor(obj, name, getter, setter, attr)); |
4976 if (fast) JSObject::MigrateSlowToFast(obj, 0); | 4976 if (fast) JSObject::MigrateSlowToFast(obj, 0); |
4977 return isolate->heap()->undefined_value(); | 4977 return isolate->heap()->undefined_value(); |
4978 } | 4978 } |
4979 | 4979 |
4980 | 4980 |
4981 // Implements part of 8.12.9 DefineOwnProperty. | 4981 // Implements part of 8.12.9 DefineOwnProperty. |
4982 // There are 3 cases that lead here: | 4982 // There are 3 cases that lead here: |
4983 // Step 4a - define a new data property. | 4983 // Step 4a - define a new data property. |
4984 // Steps 9b & 12 - replace an existing accessor property with a data property. | 4984 // Steps 9b & 12 - replace an existing accessor property with a data property. |
4985 // Step 12 - update an existing data property with a data or generic | 4985 // Step 12 - update an existing data property with a data or generic |
4986 // descriptor. | 4986 // descriptor. |
4987 RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) { | 4987 RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) { |
4988 HandleScope scope(isolate); | 4988 HandleScope scope(isolate); |
4989 ASSERT(args.length() == 4); | 4989 DCHECK(args.length() == 4); |
4990 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); | 4990 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); |
4991 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 4991 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
4992 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); | 4992 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); |
4993 CONVERT_SMI_ARG_CHECKED(unchecked, 3); | 4993 CONVERT_SMI_ARG_CHECKED(unchecked, 3); |
4994 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4994 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4995 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 4995 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
4996 | 4996 |
4997 // Check access rights if needed. | 4997 // Check access rights if needed. |
4998 if (js_object->IsAccessCheckNeeded() && | 4998 if (js_object->IsAccessCheckNeeded() && |
4999 !isolate->MayNamedAccess(js_object, name, v8::ACCESS_SET)) { | 4999 !isolate->MayNamedAccess(js_object, name, v8::ACCESS_SET)) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5042 Runtime::DefineObjectProperty( | 5042 Runtime::DefineObjectProperty( |
5043 js_object, name, obj_value, attr, | 5043 js_object, name, obj_value, attr, |
5044 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED)); | 5044 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED)); |
5045 return *result; | 5045 return *result; |
5046 } | 5046 } |
5047 | 5047 |
5048 | 5048 |
5049 // Return property without being observable by accessors or interceptors. | 5049 // Return property without being observable by accessors or interceptors. |
5050 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 5050 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
5051 HandleScope scope(isolate); | 5051 HandleScope scope(isolate); |
5052 ASSERT(args.length() == 2); | 5052 DCHECK(args.length() == 2); |
5053 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5053 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5054 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5054 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5055 return *JSObject::GetDataProperty(object, key); | 5055 return *JSObject::GetDataProperty(object, key); |
5056 } | 5056 } |
5057 | 5057 |
5058 | 5058 |
5059 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, | 5059 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
5060 Handle<Object> object, | 5060 Handle<Object> object, |
5061 Handle<Object> key, | 5061 Handle<Object> key, |
5062 Handle<Object> value, | 5062 Handle<Object> value, |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5265 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5265 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
5266 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 5266 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
5267 RUNTIME_ASSERT( | 5267 RUNTIME_ASSERT( |
5268 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5268 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
5269 // Compute attributes. | 5269 // Compute attributes. |
5270 PropertyAttributes attributes = | 5270 PropertyAttributes attributes = |
5271 static_cast<PropertyAttributes>(unchecked_attributes); | 5271 static_cast<PropertyAttributes>(unchecked_attributes); |
5272 | 5272 |
5273 #ifdef DEBUG | 5273 #ifdef DEBUG |
5274 uint32_t index = 0; | 5274 uint32_t index = 0; |
5275 ASSERT(!key->ToArrayIndex(&index)); | 5275 DCHECK(!key->ToArrayIndex(&index)); |
5276 LookupIterator it(object, key, LookupIterator::CHECK_OWN_REAL); | 5276 LookupIterator it(object, key, LookupIterator::CHECK_OWN_REAL); |
5277 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 5277 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
5278 ASSERT(maybe.has_value); | 5278 DCHECK(maybe.has_value); |
5279 RUNTIME_ASSERT(!it.IsFound()); | 5279 RUNTIME_ASSERT(!it.IsFound()); |
5280 #endif | 5280 #endif |
5281 | 5281 |
5282 Handle<Object> result; | 5282 Handle<Object> result; |
5283 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5283 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5284 isolate, result, | 5284 isolate, result, |
5285 JSObject::SetOwnPropertyIgnoreAttributes(object, key, value, attributes)); | 5285 JSObject::SetOwnPropertyIgnoreAttributes(object, key, value, attributes)); |
5286 return *result; | 5286 return *result; |
5287 } | 5287 } |
5288 | 5288 |
(...skipping 11 matching lines...) Expand all Loading... |
5300 // Compute attributes. | 5300 // Compute attributes. |
5301 PropertyAttributes attributes = | 5301 PropertyAttributes attributes = |
5302 static_cast<PropertyAttributes>(unchecked_attributes); | 5302 static_cast<PropertyAttributes>(unchecked_attributes); |
5303 | 5303 |
5304 #ifdef DEBUG | 5304 #ifdef DEBUG |
5305 bool duplicate; | 5305 bool duplicate; |
5306 if (key->IsName()) { | 5306 if (key->IsName()) { |
5307 LookupIterator it(object, Handle<Name>::cast(key), | 5307 LookupIterator it(object, Handle<Name>::cast(key), |
5308 LookupIterator::CHECK_OWN_REAL); | 5308 LookupIterator::CHECK_OWN_REAL); |
5309 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 5309 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
5310 ASSERT(maybe.has_value); | 5310 DCHECK(maybe.has_value); |
5311 duplicate = it.IsFound(); | 5311 duplicate = it.IsFound(); |
5312 } else { | 5312 } else { |
5313 uint32_t index = 0; | 5313 uint32_t index = 0; |
5314 RUNTIME_ASSERT(key->ToArrayIndex(&index)); | 5314 RUNTIME_ASSERT(key->ToArrayIndex(&index)); |
5315 Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index); | 5315 Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index); |
5316 if (!maybe.has_value) return isolate->heap()->exception(); | 5316 if (!maybe.has_value) return isolate->heap()->exception(); |
5317 duplicate = maybe.value; | 5317 duplicate = maybe.value; |
5318 } | 5318 } |
5319 if (duplicate) { | 5319 if (duplicate) { |
5320 Handle<Object> args[1] = { key }; | 5320 Handle<Object> args[1] = { key }; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5402 Object* raw_literal_cell = literals->get(literal_index); | 5402 Object* raw_literal_cell = literals->get(literal_index); |
5403 JSArray* boilerplate = NULL; | 5403 JSArray* boilerplate = NULL; |
5404 if (raw_literal_cell->IsAllocationSite()) { | 5404 if (raw_literal_cell->IsAllocationSite()) { |
5405 AllocationSite* site = AllocationSite::cast(raw_literal_cell); | 5405 AllocationSite* site = AllocationSite::cast(raw_literal_cell); |
5406 boilerplate = JSArray::cast(site->transition_info()); | 5406 boilerplate = JSArray::cast(site->transition_info()); |
5407 } else { | 5407 } else { |
5408 boilerplate = JSArray::cast(raw_literal_cell); | 5408 boilerplate = JSArray::cast(raw_literal_cell); |
5409 } | 5409 } |
5410 Handle<JSArray> boilerplate_object(boilerplate); | 5410 Handle<JSArray> boilerplate_object(boilerplate); |
5411 ElementsKind elements_kind = object->GetElementsKind(); | 5411 ElementsKind elements_kind = object->GetElementsKind(); |
5412 ASSERT(IsFastElementsKind(elements_kind)); | 5412 DCHECK(IsFastElementsKind(elements_kind)); |
5413 // Smis should never trigger transitions. | 5413 // Smis should never trigger transitions. |
5414 ASSERT(!value->IsSmi()); | 5414 DCHECK(!value->IsSmi()); |
5415 | 5415 |
5416 if (value->IsNumber()) { | 5416 if (value->IsNumber()) { |
5417 ASSERT(IsFastSmiElementsKind(elements_kind)); | 5417 DCHECK(IsFastSmiElementsKind(elements_kind)); |
5418 ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind) | 5418 ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind) |
5419 ? FAST_HOLEY_DOUBLE_ELEMENTS | 5419 ? FAST_HOLEY_DOUBLE_ELEMENTS |
5420 : FAST_DOUBLE_ELEMENTS; | 5420 : FAST_DOUBLE_ELEMENTS; |
5421 if (IsMoreGeneralElementsKindTransition( | 5421 if (IsMoreGeneralElementsKindTransition( |
5422 boilerplate_object->GetElementsKind(), | 5422 boilerplate_object->GetElementsKind(), |
5423 transitioned_kind)) { | 5423 transitioned_kind)) { |
5424 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); | 5424 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); |
5425 } | 5425 } |
5426 JSObject::TransitionElementsKind(object, transitioned_kind); | 5426 JSObject::TransitionElementsKind(object, transitioned_kind); |
5427 ASSERT(IsFastDoubleElementsKind(object->GetElementsKind())); | 5427 DCHECK(IsFastDoubleElementsKind(object->GetElementsKind())); |
5428 FixedDoubleArray* double_array = FixedDoubleArray::cast(object->elements()); | 5428 FixedDoubleArray* double_array = FixedDoubleArray::cast(object->elements()); |
5429 HeapNumber* number = HeapNumber::cast(*value); | 5429 HeapNumber* number = HeapNumber::cast(*value); |
5430 double_array->set(store_index, number->Number()); | 5430 double_array->set(store_index, number->Number()); |
5431 } else { | 5431 } else { |
5432 if (!IsFastObjectElementsKind(elements_kind)) { | 5432 if (!IsFastObjectElementsKind(elements_kind)) { |
5433 ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind) | 5433 ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind) |
5434 ? FAST_HOLEY_ELEMENTS | 5434 ? FAST_HOLEY_ELEMENTS |
5435 : FAST_ELEMENTS; | 5435 : FAST_ELEMENTS; |
5436 JSObject::TransitionElementsKind(object, transitioned_kind); | 5436 JSObject::TransitionElementsKind(object, transitioned_kind); |
5437 ElementsKind boilerplate_elements_kind = | 5437 ElementsKind boilerplate_elements_kind = |
5438 boilerplate_object->GetElementsKind(); | 5438 boilerplate_object->GetElementsKind(); |
5439 if (IsMoreGeneralElementsKindTransition(boilerplate_elements_kind, | 5439 if (IsMoreGeneralElementsKindTransition(boilerplate_elements_kind, |
5440 transitioned_kind)) { | 5440 transitioned_kind)) { |
5441 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); | 5441 JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind); |
5442 } | 5442 } |
5443 } | 5443 } |
5444 FixedArray* object_array = FixedArray::cast(object->elements()); | 5444 FixedArray* object_array = FixedArray::cast(object->elements()); |
5445 object_array->set(store_index, *value); | 5445 object_array->set(store_index, *value); |
5446 } | 5446 } |
5447 return *object; | 5447 return *object; |
5448 } | 5448 } |
5449 | 5449 |
5450 | 5450 |
5451 // Check whether debugger and is about to step into the callback that is passed | 5451 // Check whether debugger and is about to step into the callback that is passed |
5452 // to a built-in function such as Array.forEach. | 5452 // to a built-in function such as Array.forEach. |
5453 RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) { | 5453 RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) { |
5454 ASSERT(args.length() == 1); | 5454 DCHECK(args.length() == 1); |
5455 if (!isolate->debug()->is_active() || !isolate->debug()->StepInActive()) { | 5455 if (!isolate->debug()->is_active() || !isolate->debug()->StepInActive()) { |
5456 return isolate->heap()->false_value(); | 5456 return isolate->heap()->false_value(); |
5457 } | 5457 } |
5458 CONVERT_ARG_CHECKED(Object, callback, 0); | 5458 CONVERT_ARG_CHECKED(Object, callback, 0); |
5459 // We do not step into the callback if it's a builtin or not even a function. | 5459 // We do not step into the callback if it's a builtin or not even a function. |
5460 return isolate->heap()->ToBoolean( | 5460 return isolate->heap()->ToBoolean( |
5461 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); | 5461 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); |
5462 } | 5462 } |
5463 | 5463 |
5464 | 5464 |
5465 // Set one shot breakpoints for the callback function that is passed to a | 5465 // Set one shot breakpoints for the callback function that is passed to a |
5466 // built-in function such as Array.forEach to enable stepping into the callback. | 5466 // built-in function such as Array.forEach to enable stepping into the callback. |
5467 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { | 5467 RUNTIME_FUNCTION(Runtime_DebugPrepareStepInIfStepping) { |
5468 ASSERT(args.length() == 1); | 5468 DCHECK(args.length() == 1); |
5469 Debug* debug = isolate->debug(); | 5469 Debug* debug = isolate->debug(); |
5470 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); | 5470 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); |
5471 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); | 5471 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); |
5472 HandleScope scope(isolate); | 5472 HandleScope scope(isolate); |
5473 // When leaving the callback, step out has been activated, but not performed | 5473 // When leaving the callback, step out has been activated, but not performed |
5474 // if we do not leave the builtin. To be able to step into the callback | 5474 // if we do not leave the builtin. To be able to step into the callback |
5475 // again, we need to clear the step out at this point. | 5475 // again, we need to clear the step out at this point. |
5476 debug->ClearStepOut(); | 5476 debug->ClearStepOut(); |
5477 debug->FloodWithOneShot(callback); | 5477 debug->FloodWithOneShot(callback); |
5478 return isolate->heap()->undefined_value(); | 5478 return isolate->heap()->undefined_value(); |
5479 } | 5479 } |
5480 | 5480 |
5481 | 5481 |
5482 // The argument is a closure that is kept until the epilogue is called. | 5482 // The argument is a closure that is kept until the epilogue is called. |
5483 // On exception, the closure is called, which returns the promise if the | 5483 // On exception, the closure is called, which returns the promise if the |
5484 // exception is considered uncaught, or undefined otherwise. | 5484 // exception is considered uncaught, or undefined otherwise. |
5485 RUNTIME_FUNCTION(Runtime_DebugPromiseHandlePrologue) { | 5485 RUNTIME_FUNCTION(Runtime_DebugPromiseHandlePrologue) { |
5486 ASSERT(args.length() == 1); | 5486 DCHECK(args.length() == 1); |
5487 HandleScope scope(isolate); | 5487 HandleScope scope(isolate); |
5488 CONVERT_ARG_HANDLE_CHECKED(JSFunction, promise_getter, 0); | 5488 CONVERT_ARG_HANDLE_CHECKED(JSFunction, promise_getter, 0); |
5489 isolate->debug()->PromiseHandlePrologue(promise_getter); | 5489 isolate->debug()->PromiseHandlePrologue(promise_getter); |
5490 return isolate->heap()->undefined_value(); | 5490 return isolate->heap()->undefined_value(); |
5491 } | 5491 } |
5492 | 5492 |
5493 | 5493 |
5494 RUNTIME_FUNCTION(Runtime_DebugPromiseHandleEpilogue) { | 5494 RUNTIME_FUNCTION(Runtime_DebugPromiseHandleEpilogue) { |
5495 ASSERT(args.length() == 0); | 5495 DCHECK(args.length() == 0); |
5496 SealHandleScope shs(isolate); | 5496 SealHandleScope shs(isolate); |
5497 isolate->debug()->PromiseHandleEpilogue(); | 5497 isolate->debug()->PromiseHandleEpilogue(); |
5498 return isolate->heap()->undefined_value(); | 5498 return isolate->heap()->undefined_value(); |
5499 } | 5499 } |
5500 | 5500 |
5501 | 5501 |
5502 RUNTIME_FUNCTION(Runtime_DebugPromiseEvent) { | 5502 RUNTIME_FUNCTION(Runtime_DebugPromiseEvent) { |
5503 ASSERT(args.length() == 1); | 5503 DCHECK(args.length() == 1); |
5504 HandleScope scope(isolate); | 5504 HandleScope scope(isolate); |
5505 CONVERT_ARG_HANDLE_CHECKED(JSObject, data, 0); | 5505 CONVERT_ARG_HANDLE_CHECKED(JSObject, data, 0); |
5506 isolate->debug()->OnPromiseEvent(data); | 5506 isolate->debug()->OnPromiseEvent(data); |
5507 return isolate->heap()->undefined_value(); | 5507 return isolate->heap()->undefined_value(); |
5508 } | 5508 } |
5509 | 5509 |
5510 | 5510 |
5511 RUNTIME_FUNCTION(Runtime_DebugAsyncTaskEvent) { | 5511 RUNTIME_FUNCTION(Runtime_DebugAsyncTaskEvent) { |
5512 ASSERT(args.length() == 1); | 5512 DCHECK(args.length() == 1); |
5513 HandleScope scope(isolate); | 5513 HandleScope scope(isolate); |
5514 CONVERT_ARG_HANDLE_CHECKED(JSObject, data, 0); | 5514 CONVERT_ARG_HANDLE_CHECKED(JSObject, data, 0); |
5515 isolate->debug()->OnAsyncTaskEvent(data); | 5515 isolate->debug()->OnAsyncTaskEvent(data); |
5516 return isolate->heap()->undefined_value(); | 5516 return isolate->heap()->undefined_value(); |
5517 } | 5517 } |
5518 | 5518 |
5519 | 5519 |
5520 RUNTIME_FUNCTION(Runtime_DeleteProperty) { | 5520 RUNTIME_FUNCTION(Runtime_DeleteProperty) { |
5521 HandleScope scope(isolate); | 5521 HandleScope scope(isolate); |
5522 ASSERT(args.length() == 3); | 5522 DCHECK(args.length() == 3); |
5523 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5523 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
5524 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5524 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5525 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 5525 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
5526 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT | 5526 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT |
5527 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; | 5527 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; |
5528 Handle<Object> result; | 5528 Handle<Object> result; |
5529 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5529 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5530 isolate, result, | 5530 isolate, result, |
5531 JSReceiver::DeleteProperty(object, key, delete_mode)); | 5531 JSReceiver::DeleteProperty(object, key, delete_mode)); |
5532 return *result; | 5532 return *result; |
(...skipping 20 matching lines...) Expand all Loading... |
5553 isolate, Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), | 5553 isolate, Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), |
5554 key); | 5554 key); |
5555 } | 5555 } |
5556 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5556 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
5557 return isolate->heap()->false_value(); | 5557 return isolate->heap()->false_value(); |
5558 } | 5558 } |
5559 | 5559 |
5560 | 5560 |
5561 RUNTIME_FUNCTION(Runtime_HasOwnProperty) { | 5561 RUNTIME_FUNCTION(Runtime_HasOwnProperty) { |
5562 HandleScope scope(isolate); | 5562 HandleScope scope(isolate); |
5563 ASSERT(args.length() == 2); | 5563 DCHECK(args.length() == 2); |
5564 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) | 5564 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) |
5565 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5565 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5566 | 5566 |
5567 uint32_t index; | 5567 uint32_t index; |
5568 const bool key_is_array_index = key->AsArrayIndex(&index); | 5568 const bool key_is_array_index = key->AsArrayIndex(&index); |
5569 | 5569 |
5570 // Only JS objects can have properties. | 5570 // Only JS objects can have properties. |
5571 if (object->IsJSObject()) { | 5571 if (object->IsJSObject()) { |
5572 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); | 5572 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); |
5573 // Fast case: either the key is a real named property or it is not | 5573 // Fast case: either the key is a real named property or it is not |
5574 // an array index and there are no interceptors or hidden | 5574 // an array index and there are no interceptors or hidden |
5575 // prototypes. | 5575 // prototypes. |
5576 Maybe<bool> maybe = JSObject::HasRealNamedProperty(js_obj, key); | 5576 Maybe<bool> maybe = JSObject::HasRealNamedProperty(js_obj, key); |
5577 if (!maybe.has_value) return isolate->heap()->exception(); | 5577 if (!maybe.has_value) return isolate->heap()->exception(); |
5578 ASSERT(!isolate->has_pending_exception()); | 5578 DCHECK(!isolate->has_pending_exception()); |
5579 if (maybe.value) { | 5579 if (maybe.value) { |
5580 return isolate->heap()->true_value(); | 5580 return isolate->heap()->true_value(); |
5581 } | 5581 } |
5582 Map* map = js_obj->map(); | 5582 Map* map = js_obj->map(); |
5583 if (!key_is_array_index && | 5583 if (!key_is_array_index && |
5584 !map->has_named_interceptor() && | 5584 !map->has_named_interceptor() && |
5585 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { | 5585 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { |
5586 return isolate->heap()->false_value(); | 5586 return isolate->heap()->false_value(); |
5587 } | 5587 } |
5588 // Slow case. | 5588 // Slow case. |
5589 return HasOwnPropertyImplementation(isolate, | 5589 return HasOwnPropertyImplementation(isolate, |
5590 Handle<JSObject>(js_obj), | 5590 Handle<JSObject>(js_obj), |
5591 Handle<Name>(key)); | 5591 Handle<Name>(key)); |
5592 } else if (object->IsString() && key_is_array_index) { | 5592 } else if (object->IsString() && key_is_array_index) { |
5593 // Well, there is one exception: Handle [] on strings. | 5593 // Well, there is one exception: Handle [] on strings. |
5594 Handle<String> string = Handle<String>::cast(object); | 5594 Handle<String> string = Handle<String>::cast(object); |
5595 if (index < static_cast<uint32_t>(string->length())) { | 5595 if (index < static_cast<uint32_t>(string->length())) { |
5596 return isolate->heap()->true_value(); | 5596 return isolate->heap()->true_value(); |
5597 } | 5597 } |
5598 } | 5598 } |
5599 return isolate->heap()->false_value(); | 5599 return isolate->heap()->false_value(); |
5600 } | 5600 } |
5601 | 5601 |
5602 | 5602 |
5603 RUNTIME_FUNCTION(Runtime_HasProperty) { | 5603 RUNTIME_FUNCTION(Runtime_HasProperty) { |
5604 HandleScope scope(isolate); | 5604 HandleScope scope(isolate); |
5605 ASSERT(args.length() == 2); | 5605 DCHECK(args.length() == 2); |
5606 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 5606 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
5607 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5607 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5608 | 5608 |
5609 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, key); | 5609 Maybe<bool> maybe = JSReceiver::HasProperty(receiver, key); |
5610 if (!maybe.has_value) return isolate->heap()->exception(); | 5610 if (!maybe.has_value) return isolate->heap()->exception(); |
5611 return isolate->heap()->ToBoolean(maybe.value); | 5611 return isolate->heap()->ToBoolean(maybe.value); |
5612 } | 5612 } |
5613 | 5613 |
5614 | 5614 |
5615 RUNTIME_FUNCTION(Runtime_HasElement) { | 5615 RUNTIME_FUNCTION(Runtime_HasElement) { |
5616 HandleScope scope(isolate); | 5616 HandleScope scope(isolate); |
5617 ASSERT(args.length() == 2); | 5617 DCHECK(args.length() == 2); |
5618 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 5618 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
5619 CONVERT_SMI_ARG_CHECKED(index, 1); | 5619 CONVERT_SMI_ARG_CHECKED(index, 1); |
5620 | 5620 |
5621 Maybe<bool> maybe = JSReceiver::HasElement(receiver, index); | 5621 Maybe<bool> maybe = JSReceiver::HasElement(receiver, index); |
5622 if (!maybe.has_value) return isolate->heap()->exception(); | 5622 if (!maybe.has_value) return isolate->heap()->exception(); |
5623 return isolate->heap()->ToBoolean(maybe.value); | 5623 return isolate->heap()->ToBoolean(maybe.value); |
5624 } | 5624 } |
5625 | 5625 |
5626 | 5626 |
5627 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { | 5627 RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) { |
5628 HandleScope scope(isolate); | 5628 HandleScope scope(isolate); |
5629 ASSERT(args.length() == 2); | 5629 DCHECK(args.length() == 2); |
5630 | 5630 |
5631 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5631 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5632 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5632 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5633 | 5633 |
5634 Maybe<PropertyAttributes> maybe = | 5634 Maybe<PropertyAttributes> maybe = |
5635 JSReceiver::GetOwnPropertyAttributes(object, key); | 5635 JSReceiver::GetOwnPropertyAttributes(object, key); |
5636 if (!maybe.has_value) return isolate->heap()->exception(); | 5636 if (!maybe.has_value) return isolate->heap()->exception(); |
5637 if (maybe.value == ABSENT) maybe.value = DONT_ENUM; | 5637 if (maybe.value == ABSENT) maybe.value = DONT_ENUM; |
5638 return isolate->heap()->ToBoolean((maybe.value & DONT_ENUM) == 0); | 5638 return isolate->heap()->ToBoolean((maybe.value & DONT_ENUM) == 0); |
5639 } | 5639 } |
5640 | 5640 |
5641 | 5641 |
5642 RUNTIME_FUNCTION(Runtime_GetPropertyNames) { | 5642 RUNTIME_FUNCTION(Runtime_GetPropertyNames) { |
5643 HandleScope scope(isolate); | 5643 HandleScope scope(isolate); |
5644 ASSERT(args.length() == 1); | 5644 DCHECK(args.length() == 1); |
5645 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5645 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
5646 Handle<JSArray> result; | 5646 Handle<JSArray> result; |
5647 | 5647 |
5648 isolate->counters()->for_in()->Increment(); | 5648 isolate->counters()->for_in()->Increment(); |
5649 Handle<FixedArray> elements; | 5649 Handle<FixedArray> elements; |
5650 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5650 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5651 isolate, elements, | 5651 isolate, elements, |
5652 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); | 5652 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); |
5653 return *isolate->factory()->NewJSArrayWithElements(elements); | 5653 return *isolate->factory()->NewJSArrayWithElements(elements); |
5654 } | 5654 } |
5655 | 5655 |
5656 | 5656 |
5657 // Returns either a FixedArray as Runtime_GetPropertyNames, | 5657 // Returns either a FixedArray as Runtime_GetPropertyNames, |
5658 // or, if the given object has an enum cache that contains | 5658 // or, if the given object has an enum cache that contains |
5659 // all enumerable properties of the object and its prototypes | 5659 // all enumerable properties of the object and its prototypes |
5660 // have none, the map of the object. This is used to speed up | 5660 // have none, the map of the object. This is used to speed up |
5661 // the check for deletions during a for-in. | 5661 // the check for deletions during a for-in. |
5662 RUNTIME_FUNCTION(Runtime_GetPropertyNamesFast) { | 5662 RUNTIME_FUNCTION(Runtime_GetPropertyNamesFast) { |
5663 SealHandleScope shs(isolate); | 5663 SealHandleScope shs(isolate); |
5664 ASSERT(args.length() == 1); | 5664 DCHECK(args.length() == 1); |
5665 | 5665 |
5666 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); | 5666 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); |
5667 | 5667 |
5668 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 5668 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
5669 | 5669 |
5670 HandleScope scope(isolate); | 5670 HandleScope scope(isolate); |
5671 Handle<JSReceiver> object(raw_object); | 5671 Handle<JSReceiver> object(raw_object); |
5672 Handle<FixedArray> content; | 5672 Handle<FixedArray> content; |
5673 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5673 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5674 isolate, content, | 5674 isolate, content, |
(...skipping 17 matching lines...) Expand all Loading... |
5692 } | 5692 } |
5693 return count; | 5693 return count; |
5694 } | 5694 } |
5695 | 5695 |
5696 | 5696 |
5697 // Return the names of the own named properties. | 5697 // Return the names of the own named properties. |
5698 // args[0]: object | 5698 // args[0]: object |
5699 // args[1]: PropertyAttributes as int | 5699 // args[1]: PropertyAttributes as int |
5700 RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) { | 5700 RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) { |
5701 HandleScope scope(isolate); | 5701 HandleScope scope(isolate); |
5702 ASSERT(args.length() == 2); | 5702 DCHECK(args.length() == 2); |
5703 if (!args[0]->IsJSObject()) { | 5703 if (!args[0]->IsJSObject()) { |
5704 return isolate->heap()->undefined_value(); | 5704 return isolate->heap()->undefined_value(); |
5705 } | 5705 } |
5706 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5706 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5707 CONVERT_SMI_ARG_CHECKED(filter_value, 1); | 5707 CONVERT_SMI_ARG_CHECKED(filter_value, 1); |
5708 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); | 5708 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); |
5709 | 5709 |
5710 // Skip the global proxy as it has no properties and always delegates to the | 5710 // Skip the global proxy as it has no properties and always delegates to the |
5711 // real global object. | 5711 // real global object. |
5712 if (obj->IsJSGlobalProxy()) { | 5712 if (obj->IsJSGlobalProxy()) { |
(...skipping 11 matching lines...) Expand all Loading... |
5724 | 5724 |
5725 // Find the number of objects making up this. | 5725 // Find the number of objects making up this. |
5726 int length = OwnPrototypeChainLength(*obj); | 5726 int length = OwnPrototypeChainLength(*obj); |
5727 | 5727 |
5728 // Find the number of own properties for each of the objects. | 5728 // Find the number of own properties for each of the objects. |
5729 ScopedVector<int> own_property_count(length); | 5729 ScopedVector<int> own_property_count(length); |
5730 int total_property_count = 0; | 5730 int total_property_count = 0; |
5731 { | 5731 { |
5732 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 5732 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
5733 for (int i = 0; i < length; i++) { | 5733 for (int i = 0; i < length; i++) { |
5734 ASSERT(!iter.IsAtEnd()); | 5734 DCHECK(!iter.IsAtEnd()); |
5735 Handle<JSObject> jsproto = | 5735 Handle<JSObject> jsproto = |
5736 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | 5736 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
5737 // Only collect names if access is permitted. | 5737 // Only collect names if access is permitted. |
5738 if (jsproto->IsAccessCheckNeeded() && | 5738 if (jsproto->IsAccessCheckNeeded() && |
5739 !isolate->MayNamedAccess(jsproto, | 5739 !isolate->MayNamedAccess(jsproto, |
5740 isolate->factory()->undefined_value(), | 5740 isolate->factory()->undefined_value(), |
5741 v8::ACCESS_KEYS)) { | 5741 v8::ACCESS_KEYS)) { |
5742 isolate->ReportFailedAccessCheck(jsproto, v8::ACCESS_KEYS); | 5742 isolate->ReportFailedAccessCheck(jsproto, v8::ACCESS_KEYS); |
5743 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5743 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
5744 return *isolate->factory()->NewJSArray(0); | 5744 return *isolate->factory()->NewJSArray(0); |
5745 } | 5745 } |
5746 int n; | 5746 int n; |
5747 n = jsproto->NumberOfOwnProperties(filter); | 5747 n = jsproto->NumberOfOwnProperties(filter); |
5748 own_property_count[i] = n; | 5748 own_property_count[i] = n; |
5749 total_property_count += n; | 5749 total_property_count += n; |
5750 iter.Advance(); | 5750 iter.Advance(); |
5751 } | 5751 } |
5752 } | 5752 } |
5753 | 5753 |
5754 // Allocate an array with storage for all the property names. | 5754 // Allocate an array with storage for all the property names. |
5755 Handle<FixedArray> names = | 5755 Handle<FixedArray> names = |
5756 isolate->factory()->NewFixedArray(total_property_count); | 5756 isolate->factory()->NewFixedArray(total_property_count); |
5757 | 5757 |
5758 // Get the property names. | 5758 // Get the property names. |
5759 int next_copy_index = 0; | 5759 int next_copy_index = 0; |
5760 int hidden_strings = 0; | 5760 int hidden_strings = 0; |
5761 { | 5761 { |
5762 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 5762 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
5763 for (int i = 0; i < length; i++) { | 5763 for (int i = 0; i < length; i++) { |
5764 ASSERT(!iter.IsAtEnd()); | 5764 DCHECK(!iter.IsAtEnd()); |
5765 Handle<JSObject> jsproto = | 5765 Handle<JSObject> jsproto = |
5766 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | 5766 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
5767 jsproto->GetOwnPropertyNames(*names, next_copy_index, filter); | 5767 jsproto->GetOwnPropertyNames(*names, next_copy_index, filter); |
5768 if (i > 0) { | 5768 if (i > 0) { |
5769 // Names from hidden prototypes may already have been added | 5769 // Names from hidden prototypes may already have been added |
5770 // for inherited function template instances. Count the duplicates | 5770 // for inherited function template instances. Count the duplicates |
5771 // and stub them out; the final copy pass at the end ignores holes. | 5771 // and stub them out; the final copy pass at the end ignores holes. |
5772 for (int j = next_copy_index; | 5772 for (int j = next_copy_index; |
5773 j < next_copy_index + own_property_count[i]; j++) { | 5773 j < next_copy_index + own_property_count[i]; j++) { |
5774 Object* name_from_hidden_proto = names->get(j); | 5774 Object* name_from_hidden_proto = names->get(j); |
(...skipping 27 matching lines...) Expand all Loading... |
5802 names->length() - hidden_strings); | 5802 names->length() - hidden_strings); |
5803 int dest_pos = 0; | 5803 int dest_pos = 0; |
5804 for (int i = 0; i < total_property_count; i++) { | 5804 for (int i = 0; i < total_property_count; i++) { |
5805 Object* name = old_names->get(i); | 5805 Object* name = old_names->get(i); |
5806 if (name == isolate->heap()->hidden_string()) { | 5806 if (name == isolate->heap()->hidden_string()) { |
5807 hidden_strings--; | 5807 hidden_strings--; |
5808 continue; | 5808 continue; |
5809 } | 5809 } |
5810 names->set(dest_pos++, name); | 5810 names->set(dest_pos++, name); |
5811 } | 5811 } |
5812 ASSERT_EQ(0, hidden_strings); | 5812 DCHECK_EQ(0, hidden_strings); |
5813 } | 5813 } |
5814 | 5814 |
5815 return *isolate->factory()->NewJSArrayWithElements(names); | 5815 return *isolate->factory()->NewJSArrayWithElements(names); |
5816 } | 5816 } |
5817 | 5817 |
5818 | 5818 |
5819 // Return the names of the own indexed properties. | 5819 // Return the names of the own indexed properties. |
5820 // args[0]: object | 5820 // args[0]: object |
5821 RUNTIME_FUNCTION(Runtime_GetOwnElementNames) { | 5821 RUNTIME_FUNCTION(Runtime_GetOwnElementNames) { |
5822 HandleScope scope(isolate); | 5822 HandleScope scope(isolate); |
5823 ASSERT(args.length() == 1); | 5823 DCHECK(args.length() == 1); |
5824 if (!args[0]->IsJSObject()) { | 5824 if (!args[0]->IsJSObject()) { |
5825 return isolate->heap()->undefined_value(); | 5825 return isolate->heap()->undefined_value(); |
5826 } | 5826 } |
5827 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5827 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5828 | 5828 |
5829 int n = obj->NumberOfOwnElements(static_cast<PropertyAttributes>(NONE)); | 5829 int n = obj->NumberOfOwnElements(static_cast<PropertyAttributes>(NONE)); |
5830 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); | 5830 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); |
5831 obj->GetOwnElementKeys(*names, static_cast<PropertyAttributes>(NONE)); | 5831 obj->GetOwnElementKeys(*names, static_cast<PropertyAttributes>(NONE)); |
5832 return *isolate->factory()->NewJSArrayWithElements(names); | 5832 return *isolate->factory()->NewJSArrayWithElements(names); |
5833 } | 5833 } |
5834 | 5834 |
5835 | 5835 |
5836 // Return information on whether an object has a named or indexed interceptor. | 5836 // Return information on whether an object has a named or indexed interceptor. |
5837 // args[0]: object | 5837 // args[0]: object |
5838 RUNTIME_FUNCTION(Runtime_GetInterceptorInfo) { | 5838 RUNTIME_FUNCTION(Runtime_GetInterceptorInfo) { |
5839 HandleScope scope(isolate); | 5839 HandleScope scope(isolate); |
5840 ASSERT(args.length() == 1); | 5840 DCHECK(args.length() == 1); |
5841 if (!args[0]->IsJSObject()) { | 5841 if (!args[0]->IsJSObject()) { |
5842 return Smi::FromInt(0); | 5842 return Smi::FromInt(0); |
5843 } | 5843 } |
5844 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5844 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5845 | 5845 |
5846 int result = 0; | 5846 int result = 0; |
5847 if (obj->HasNamedInterceptor()) result |= 2; | 5847 if (obj->HasNamedInterceptor()) result |= 2; |
5848 if (obj->HasIndexedInterceptor()) result |= 1; | 5848 if (obj->HasIndexedInterceptor()) result |= 1; |
5849 | 5849 |
5850 return Smi::FromInt(result); | 5850 return Smi::FromInt(result); |
5851 } | 5851 } |
5852 | 5852 |
5853 | 5853 |
5854 // Return property names from named interceptor. | 5854 // Return property names from named interceptor. |
5855 // args[0]: object | 5855 // args[0]: object |
5856 RUNTIME_FUNCTION(Runtime_GetNamedInterceptorPropertyNames) { | 5856 RUNTIME_FUNCTION(Runtime_GetNamedInterceptorPropertyNames) { |
5857 HandleScope scope(isolate); | 5857 HandleScope scope(isolate); |
5858 ASSERT(args.length() == 1); | 5858 DCHECK(args.length() == 1); |
5859 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5859 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5860 | 5860 |
5861 if (obj->HasNamedInterceptor()) { | 5861 if (obj->HasNamedInterceptor()) { |
5862 Handle<JSObject> result; | 5862 Handle<JSObject> result; |
5863 if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) { | 5863 if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) { |
5864 return *result; | 5864 return *result; |
5865 } | 5865 } |
5866 } | 5866 } |
5867 return isolate->heap()->undefined_value(); | 5867 return isolate->heap()->undefined_value(); |
5868 } | 5868 } |
5869 | 5869 |
5870 | 5870 |
5871 // Return element names from indexed interceptor. | 5871 // Return element names from indexed interceptor. |
5872 // args[0]: object | 5872 // args[0]: object |
5873 RUNTIME_FUNCTION(Runtime_GetIndexedInterceptorElementNames) { | 5873 RUNTIME_FUNCTION(Runtime_GetIndexedInterceptorElementNames) { |
5874 HandleScope scope(isolate); | 5874 HandleScope scope(isolate); |
5875 ASSERT(args.length() == 1); | 5875 DCHECK(args.length() == 1); |
5876 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5876 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5877 | 5877 |
5878 if (obj->HasIndexedInterceptor()) { | 5878 if (obj->HasIndexedInterceptor()) { |
5879 Handle<JSObject> result; | 5879 Handle<JSObject> result; |
5880 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { | 5880 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { |
5881 return *result; | 5881 return *result; |
5882 } | 5882 } |
5883 } | 5883 } |
5884 return isolate->heap()->undefined_value(); | 5884 return isolate->heap()->undefined_value(); |
5885 } | 5885 } |
5886 | 5886 |
5887 | 5887 |
5888 RUNTIME_FUNCTION(Runtime_OwnKeys) { | 5888 RUNTIME_FUNCTION(Runtime_OwnKeys) { |
5889 HandleScope scope(isolate); | 5889 HandleScope scope(isolate); |
5890 ASSERT(args.length() == 1); | 5890 DCHECK(args.length() == 1); |
5891 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); | 5891 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); |
5892 Handle<JSObject> object(raw_object); | 5892 Handle<JSObject> object(raw_object); |
5893 | 5893 |
5894 if (object->IsJSGlobalProxy()) { | 5894 if (object->IsJSGlobalProxy()) { |
5895 // Do access checks before going to the global object. | 5895 // Do access checks before going to the global object. |
5896 if (object->IsAccessCheckNeeded() && | 5896 if (object->IsAccessCheckNeeded() && |
5897 !isolate->MayNamedAccess( | 5897 !isolate->MayNamedAccess( |
5898 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 5898 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
5899 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); | 5899 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); |
5900 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5900 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
(...skipping 14 matching lines...) Expand all Loading... |
5915 // Some fast paths through GetKeysInFixedArrayFor reuse a cached | 5915 // Some fast paths through GetKeysInFixedArrayFor reuse a cached |
5916 // property array and since the result is mutable we have to create | 5916 // property array and since the result is mutable we have to create |
5917 // a fresh clone on each invocation. | 5917 // a fresh clone on each invocation. |
5918 int length = contents->length(); | 5918 int length = contents->length(); |
5919 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); | 5919 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); |
5920 for (int i = 0; i < length; i++) { | 5920 for (int i = 0; i < length; i++) { |
5921 Object* entry = contents->get(i); | 5921 Object* entry = contents->get(i); |
5922 if (entry->IsString()) { | 5922 if (entry->IsString()) { |
5923 copy->set(i, entry); | 5923 copy->set(i, entry); |
5924 } else { | 5924 } else { |
5925 ASSERT(entry->IsNumber()); | 5925 DCHECK(entry->IsNumber()); |
5926 HandleScope scope(isolate); | 5926 HandleScope scope(isolate); |
5927 Handle<Object> entry_handle(entry, isolate); | 5927 Handle<Object> entry_handle(entry, isolate); |
5928 Handle<Object> entry_str = | 5928 Handle<Object> entry_str = |
5929 isolate->factory()->NumberToString(entry_handle); | 5929 isolate->factory()->NumberToString(entry_handle); |
5930 copy->set(i, *entry_str); | 5930 copy->set(i, *entry_str); |
5931 } | 5931 } |
5932 } | 5932 } |
5933 return *isolate->factory()->NewJSArrayWithElements(copy); | 5933 return *isolate->factory()->NewJSArrayWithElements(copy); |
5934 } | 5934 } |
5935 | 5935 |
5936 | 5936 |
5937 RUNTIME_FUNCTION(Runtime_GetArgumentsProperty) { | 5937 RUNTIME_FUNCTION(Runtime_GetArgumentsProperty) { |
5938 SealHandleScope shs(isolate); | 5938 SealHandleScope shs(isolate); |
5939 ASSERT(args.length() == 1); | 5939 DCHECK(args.length() == 1); |
5940 CONVERT_ARG_HANDLE_CHECKED(Object, raw_key, 0); | 5940 CONVERT_ARG_HANDLE_CHECKED(Object, raw_key, 0); |
5941 | 5941 |
5942 // Compute the frame holding the arguments. | 5942 // Compute the frame holding the arguments. |
5943 JavaScriptFrameIterator it(isolate); | 5943 JavaScriptFrameIterator it(isolate); |
5944 it.AdvanceToArgumentsFrame(); | 5944 it.AdvanceToArgumentsFrame(); |
5945 JavaScriptFrame* frame = it.frame(); | 5945 JavaScriptFrame* frame = it.frame(); |
5946 | 5946 |
5947 // Get the actual number of provided arguments. | 5947 // Get the actual number of provided arguments. |
5948 const uint32_t n = frame->ComputeParametersCount(); | 5948 const uint32_t n = frame->ComputeParametersCount(); |
5949 | 5949 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6002 Handle<Object> result; | 6002 Handle<Object> result; |
6003 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6003 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6004 isolate, result, | 6004 isolate, result, |
6005 Object::GetProperty(isolate->initial_object_prototype(), key)); | 6005 Object::GetProperty(isolate->initial_object_prototype(), key)); |
6006 return *result; | 6006 return *result; |
6007 } | 6007 } |
6008 | 6008 |
6009 | 6009 |
6010 RUNTIME_FUNCTION(Runtime_ToFastProperties) { | 6010 RUNTIME_FUNCTION(Runtime_ToFastProperties) { |
6011 HandleScope scope(isolate); | 6011 HandleScope scope(isolate); |
6012 ASSERT(args.length() == 1); | 6012 DCHECK(args.length() == 1); |
6013 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 6013 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
6014 if (object->IsJSObject() && !object->IsGlobalObject()) { | 6014 if (object->IsJSObject() && !object->IsGlobalObject()) { |
6015 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0); | 6015 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0); |
6016 } | 6016 } |
6017 return *object; | 6017 return *object; |
6018 } | 6018 } |
6019 | 6019 |
6020 | 6020 |
6021 RUNTIME_FUNCTION(Runtime_ToBool) { | 6021 RUNTIME_FUNCTION(Runtime_ToBool) { |
6022 SealHandleScope shs(isolate); | 6022 SealHandleScope shs(isolate); |
6023 ASSERT(args.length() == 1); | 6023 DCHECK(args.length() == 1); |
6024 CONVERT_ARG_CHECKED(Object, object, 0); | 6024 CONVERT_ARG_CHECKED(Object, object, 0); |
6025 | 6025 |
6026 return isolate->heap()->ToBoolean(object->BooleanValue()); | 6026 return isolate->heap()->ToBoolean(object->BooleanValue()); |
6027 } | 6027 } |
6028 | 6028 |
6029 | 6029 |
6030 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 6030 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
6031 // Possible optimizations: put the type string into the oddballs. | 6031 // Possible optimizations: put the type string into the oddballs. |
6032 RUNTIME_FUNCTION(Runtime_Typeof) { | 6032 RUNTIME_FUNCTION(Runtime_Typeof) { |
6033 SealHandleScope shs(isolate); | 6033 SealHandleScope shs(isolate); |
6034 ASSERT(args.length() == 1); | 6034 DCHECK(args.length() == 1); |
6035 CONVERT_ARG_CHECKED(Object, obj, 0); | 6035 CONVERT_ARG_CHECKED(Object, obj, 0); |
6036 if (obj->IsNumber()) return isolate->heap()->number_string(); | 6036 if (obj->IsNumber()) return isolate->heap()->number_string(); |
6037 HeapObject* heap_obj = HeapObject::cast(obj); | 6037 HeapObject* heap_obj = HeapObject::cast(obj); |
6038 | 6038 |
6039 // typeof an undetectable object is 'undefined' | 6039 // typeof an undetectable object is 'undefined' |
6040 if (heap_obj->map()->is_undetectable()) { | 6040 if (heap_obj->map()->is_undetectable()) { |
6041 return isolate->heap()->undefined_string(); | 6041 return isolate->heap()->undefined_string(); |
6042 } | 6042 } |
6043 | 6043 |
6044 InstanceType instance_type = heap_obj->map()->instance_type(); | 6044 InstanceType instance_type = heap_obj->map()->instance_type(); |
6045 if (instance_type < FIRST_NONSTRING_TYPE) { | 6045 if (instance_type < FIRST_NONSTRING_TYPE) { |
6046 return isolate->heap()->string_string(); | 6046 return isolate->heap()->string_string(); |
6047 } | 6047 } |
6048 | 6048 |
6049 switch (instance_type) { | 6049 switch (instance_type) { |
6050 case ODDBALL_TYPE: | 6050 case ODDBALL_TYPE: |
6051 if (heap_obj->IsTrue() || heap_obj->IsFalse()) { | 6051 if (heap_obj->IsTrue() || heap_obj->IsFalse()) { |
6052 return isolate->heap()->boolean_string(); | 6052 return isolate->heap()->boolean_string(); |
6053 } | 6053 } |
6054 if (heap_obj->IsNull()) { | 6054 if (heap_obj->IsNull()) { |
6055 return isolate->heap()->object_string(); | 6055 return isolate->heap()->object_string(); |
6056 } | 6056 } |
6057 ASSERT(heap_obj->IsUndefined()); | 6057 DCHECK(heap_obj->IsUndefined()); |
6058 return isolate->heap()->undefined_string(); | 6058 return isolate->heap()->undefined_string(); |
6059 case SYMBOL_TYPE: | 6059 case SYMBOL_TYPE: |
6060 return isolate->heap()->symbol_string(); | 6060 return isolate->heap()->symbol_string(); |
6061 case JS_FUNCTION_TYPE: | 6061 case JS_FUNCTION_TYPE: |
6062 case JS_FUNCTION_PROXY_TYPE: | 6062 case JS_FUNCTION_PROXY_TYPE: |
6063 return isolate->heap()->function_string(); | 6063 return isolate->heap()->function_string(); |
6064 default: | 6064 default: |
6065 // For any kind of object not handled above, the spec rule for | 6065 // For any kind of object not handled above, the spec rule for |
6066 // host objects gives that it is okay to return "object" | 6066 // host objects gives that it is okay to return "object" |
6067 return isolate->heap()->object_string(); | 6067 return isolate->heap()->object_string(); |
6068 } | 6068 } |
6069 } | 6069 } |
6070 | 6070 |
6071 | 6071 |
6072 RUNTIME_FUNCTION(Runtime_Booleanize) { | 6072 RUNTIME_FUNCTION(Runtime_Booleanize) { |
6073 SealHandleScope shs(isolate); | 6073 SealHandleScope shs(isolate); |
6074 ASSERT(args.length() == 2); | 6074 DCHECK(args.length() == 2); |
6075 CONVERT_ARG_CHECKED(Object, value_raw, 0); | 6075 CONVERT_ARG_CHECKED(Object, value_raw, 0); |
6076 CONVERT_SMI_ARG_CHECKED(token_raw, 1); | 6076 CONVERT_SMI_ARG_CHECKED(token_raw, 1); |
6077 intptr_t value = reinterpret_cast<intptr_t>(value_raw); | 6077 intptr_t value = reinterpret_cast<intptr_t>(value_raw); |
6078 Token::Value token = static_cast<Token::Value>(token_raw); | 6078 Token::Value token = static_cast<Token::Value>(token_raw); |
6079 switch (token) { | 6079 switch (token) { |
6080 case Token::EQ: | 6080 case Token::EQ: |
6081 case Token::EQ_STRICT: | 6081 case Token::EQ_STRICT: |
6082 return isolate->heap()->ToBoolean(value == 0); | 6082 return isolate->heap()->ToBoolean(value == 0); |
6083 case Token::NE: | 6083 case Token::NE: |
6084 case Token::NE_STRICT: | 6084 case Token::NE_STRICT: |
(...skipping 16 matching lines...) Expand all Loading... |
6101 static bool AreDigits(const uint8_t*s, int from, int to) { | 6101 static bool AreDigits(const uint8_t*s, int from, int to) { |
6102 for (int i = from; i < to; i++) { | 6102 for (int i = from; i < to; i++) { |
6103 if (s[i] < '0' || s[i] > '9') return false; | 6103 if (s[i] < '0' || s[i] > '9') return false; |
6104 } | 6104 } |
6105 | 6105 |
6106 return true; | 6106 return true; |
6107 } | 6107 } |
6108 | 6108 |
6109 | 6109 |
6110 static int ParseDecimalInteger(const uint8_t*s, int from, int to) { | 6110 static int ParseDecimalInteger(const uint8_t*s, int from, int to) { |
6111 ASSERT(to - from < 10); // Overflow is not possible. | 6111 DCHECK(to - from < 10); // Overflow is not possible. |
6112 ASSERT(from < to); | 6112 DCHECK(from < to); |
6113 int d = s[from] - '0'; | 6113 int d = s[from] - '0'; |
6114 | 6114 |
6115 for (int i = from + 1; i < to; i++) { | 6115 for (int i = from + 1; i < to; i++) { |
6116 d = 10 * d + (s[i] - '0'); | 6116 d = 10 * d + (s[i] - '0'); |
6117 } | 6117 } |
6118 | 6118 |
6119 return d; | 6119 return d; |
6120 } | 6120 } |
6121 | 6121 |
6122 | 6122 |
6123 RUNTIME_FUNCTION(Runtime_StringToNumber) { | 6123 RUNTIME_FUNCTION(Runtime_StringToNumber) { |
6124 HandleScope handle_scope(isolate); | 6124 HandleScope handle_scope(isolate); |
6125 ASSERT(args.length() == 1); | 6125 DCHECK(args.length() == 1); |
6126 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6126 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6127 subject = String::Flatten(subject); | 6127 subject = String::Flatten(subject); |
6128 | 6128 |
6129 // Fast case: short integer or some sorts of junk values. | 6129 // Fast case: short integer or some sorts of junk values. |
6130 if (subject->IsSeqOneByteString()) { | 6130 if (subject->IsSeqOneByteString()) { |
6131 int len = subject->length(); | 6131 int len = subject->length(); |
6132 if (len == 0) return Smi::FromInt(0); | 6132 if (len == 0) return Smi::FromInt(0); |
6133 | 6133 |
6134 DisallowHeapAllocation no_gc; | 6134 DisallowHeapAllocation no_gc; |
6135 uint8_t const* data = Handle<SeqOneByteString>::cast(subject)->GetChars(); | 6135 uint8_t const* data = Handle<SeqOneByteString>::cast(subject)->GetChars(); |
(...skipping 18 matching lines...) Expand all Loading... |
6154 if (d == 0) return isolate->heap()->minus_zero_value(); | 6154 if (d == 0) return isolate->heap()->minus_zero_value(); |
6155 d = -d; | 6155 d = -d; |
6156 } else if (!subject->HasHashCode() && | 6156 } else if (!subject->HasHashCode() && |
6157 len <= String::kMaxArrayIndexSize && | 6157 len <= String::kMaxArrayIndexSize && |
6158 (len == 1 || data[0] != '0')) { | 6158 (len == 1 || data[0] != '0')) { |
6159 // String hash is not calculated yet but all the data are present. | 6159 // String hash is not calculated yet but all the data are present. |
6160 // Update the hash field to speed up sequential convertions. | 6160 // Update the hash field to speed up sequential convertions. |
6161 uint32_t hash = StringHasher::MakeArrayIndexHash(d, len); | 6161 uint32_t hash = StringHasher::MakeArrayIndexHash(d, len); |
6162 #ifdef DEBUG | 6162 #ifdef DEBUG |
6163 subject->Hash(); // Force hash calculation. | 6163 subject->Hash(); // Force hash calculation. |
6164 ASSERT_EQ(static_cast<int>(subject->hash_field()), | 6164 DCHECK_EQ(static_cast<int>(subject->hash_field()), |
6165 static_cast<int>(hash)); | 6165 static_cast<int>(hash)); |
6166 #endif | 6166 #endif |
6167 subject->set_hash_field(hash); | 6167 subject->set_hash_field(hash); |
6168 } | 6168 } |
6169 return Smi::FromInt(d); | 6169 return Smi::FromInt(d); |
6170 } | 6170 } |
6171 } | 6171 } |
6172 | 6172 |
6173 // Slower case. | 6173 // Slower case. |
6174 int flags = ALLOW_HEX; | 6174 int flags = ALLOW_HEX; |
6175 if (FLAG_harmony_numeric_literals) { | 6175 if (FLAG_harmony_numeric_literals) { |
6176 // The current spec draft has not updated "ToNumber Applied to the String | 6176 // The current spec draft has not updated "ToNumber Applied to the String |
6177 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584 | 6177 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584 |
6178 flags |= ALLOW_OCTAL | ALLOW_BINARY; | 6178 flags |= ALLOW_OCTAL | ALLOW_BINARY; |
6179 } | 6179 } |
6180 | 6180 |
6181 return *isolate->factory()->NewNumber(StringToDouble( | 6181 return *isolate->factory()->NewNumber(StringToDouble( |
6182 isolate->unicode_cache(), *subject, flags)); | 6182 isolate->unicode_cache(), *subject, flags)); |
6183 } | 6183 } |
6184 | 6184 |
6185 | 6185 |
6186 RUNTIME_FUNCTION(Runtime_NewString) { | 6186 RUNTIME_FUNCTION(Runtime_NewString) { |
6187 HandleScope scope(isolate); | 6187 HandleScope scope(isolate); |
6188 ASSERT(args.length() == 2); | 6188 DCHECK(args.length() == 2); |
6189 CONVERT_SMI_ARG_CHECKED(length, 0); | 6189 CONVERT_SMI_ARG_CHECKED(length, 0); |
6190 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); | 6190 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); |
6191 if (length == 0) return isolate->heap()->empty_string(); | 6191 if (length == 0) return isolate->heap()->empty_string(); |
6192 Handle<String> result; | 6192 Handle<String> result; |
6193 if (is_one_byte) { | 6193 if (is_one_byte) { |
6194 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6194 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6195 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 6195 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
6196 } else { | 6196 } else { |
6197 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6197 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6198 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 6198 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
6199 } | 6199 } |
6200 return *result; | 6200 return *result; |
6201 } | 6201 } |
6202 | 6202 |
6203 | 6203 |
6204 RUNTIME_FUNCTION(Runtime_TruncateString) { | 6204 RUNTIME_FUNCTION(Runtime_TruncateString) { |
6205 HandleScope scope(isolate); | 6205 HandleScope scope(isolate); |
6206 ASSERT(args.length() == 2); | 6206 DCHECK(args.length() == 2); |
6207 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0); | 6207 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0); |
6208 CONVERT_SMI_ARG_CHECKED(new_length, 1); | 6208 CONVERT_SMI_ARG_CHECKED(new_length, 1); |
6209 RUNTIME_ASSERT(new_length >= 0); | 6209 RUNTIME_ASSERT(new_length >= 0); |
6210 return *SeqString::Truncate(string, new_length); | 6210 return *SeqString::Truncate(string, new_length); |
6211 } | 6211 } |
6212 | 6212 |
6213 | 6213 |
6214 RUNTIME_FUNCTION(Runtime_URIEscape) { | 6214 RUNTIME_FUNCTION(Runtime_URIEscape) { |
6215 HandleScope scope(isolate); | 6215 HandleScope scope(isolate); |
6216 ASSERT(args.length() == 1); | 6216 DCHECK(args.length() == 1); |
6217 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 6217 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
6218 Handle<String> string = String::Flatten(source); | 6218 Handle<String> string = String::Flatten(source); |
6219 ASSERT(string->IsFlat()); | 6219 DCHECK(string->IsFlat()); |
6220 Handle<String> result; | 6220 Handle<String> result; |
6221 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6221 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6222 isolate, result, | 6222 isolate, result, |
6223 string->IsOneByteRepresentationUnderneath() | 6223 string->IsOneByteRepresentationUnderneath() |
6224 ? URIEscape::Escape<uint8_t>(isolate, source) | 6224 ? URIEscape::Escape<uint8_t>(isolate, source) |
6225 : URIEscape::Escape<uc16>(isolate, source)); | 6225 : URIEscape::Escape<uc16>(isolate, source)); |
6226 return *result; | 6226 return *result; |
6227 } | 6227 } |
6228 | 6228 |
6229 | 6229 |
6230 RUNTIME_FUNCTION(Runtime_URIUnescape) { | 6230 RUNTIME_FUNCTION(Runtime_URIUnescape) { |
6231 HandleScope scope(isolate); | 6231 HandleScope scope(isolate); |
6232 ASSERT(args.length() == 1); | 6232 DCHECK(args.length() == 1); |
6233 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 6233 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
6234 Handle<String> string = String::Flatten(source); | 6234 Handle<String> string = String::Flatten(source); |
6235 ASSERT(string->IsFlat()); | 6235 DCHECK(string->IsFlat()); |
6236 Handle<String> result; | 6236 Handle<String> result; |
6237 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6237 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6238 isolate, result, | 6238 isolate, result, |
6239 string->IsOneByteRepresentationUnderneath() | 6239 string->IsOneByteRepresentationUnderneath() |
6240 ? URIUnescape::Unescape<uint8_t>(isolate, source) | 6240 ? URIUnescape::Unescape<uint8_t>(isolate, source) |
6241 : URIUnescape::Unescape<uc16>(isolate, source)); | 6241 : URIUnescape::Unescape<uc16>(isolate, source)); |
6242 return *result; | 6242 return *result; |
6243 } | 6243 } |
6244 | 6244 |
6245 | 6245 |
6246 RUNTIME_FUNCTION(Runtime_QuoteJSONString) { | 6246 RUNTIME_FUNCTION(Runtime_QuoteJSONString) { |
6247 HandleScope scope(isolate); | 6247 HandleScope scope(isolate); |
6248 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 6248 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
6249 ASSERT(args.length() == 1); | 6249 DCHECK(args.length() == 1); |
6250 Handle<Object> result; | 6250 Handle<Object> result; |
6251 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6251 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6252 isolate, result, BasicJsonStringifier::StringifyString(isolate, string)); | 6252 isolate, result, BasicJsonStringifier::StringifyString(isolate, string)); |
6253 return *result; | 6253 return *result; |
6254 } | 6254 } |
6255 | 6255 |
6256 | 6256 |
6257 RUNTIME_FUNCTION(Runtime_BasicJSONStringify) { | 6257 RUNTIME_FUNCTION(Runtime_BasicJSONStringify) { |
6258 HandleScope scope(isolate); | 6258 HandleScope scope(isolate); |
6259 ASSERT(args.length() == 1); | 6259 DCHECK(args.length() == 1); |
6260 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 6260 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
6261 BasicJsonStringifier stringifier(isolate); | 6261 BasicJsonStringifier stringifier(isolate); |
6262 Handle<Object> result; | 6262 Handle<Object> result; |
6263 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6263 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6264 isolate, result, stringifier.Stringify(object)); | 6264 isolate, result, stringifier.Stringify(object)); |
6265 return *result; | 6265 return *result; |
6266 } | 6266 } |
6267 | 6267 |
6268 | 6268 |
6269 RUNTIME_FUNCTION(Runtime_StringParseInt) { | 6269 RUNTIME_FUNCTION(Runtime_StringParseInt) { |
6270 HandleScope handle_scope(isolate); | 6270 HandleScope handle_scope(isolate); |
6271 ASSERT(args.length() == 2); | 6271 DCHECK(args.length() == 2); |
6272 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6272 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6273 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); | 6273 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); |
6274 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 6274 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
6275 | 6275 |
6276 subject = String::Flatten(subject); | 6276 subject = String::Flatten(subject); |
6277 double value; | 6277 double value; |
6278 | 6278 |
6279 { DisallowHeapAllocation no_gc; | 6279 { DisallowHeapAllocation no_gc; |
6280 String::FlatContent flat = subject->GetFlatContent(); | 6280 String::FlatContent flat = subject->GetFlatContent(); |
6281 | 6281 |
6282 // ECMA-262 section 15.1.2.3, empty string is NaN | 6282 // ECMA-262 section 15.1.2.3, empty string is NaN |
6283 if (flat.IsAscii()) { | 6283 if (flat.IsAscii()) { |
6284 value = StringToInt( | 6284 value = StringToInt( |
6285 isolate->unicode_cache(), flat.ToOneByteVector(), radix); | 6285 isolate->unicode_cache(), flat.ToOneByteVector(), radix); |
6286 } else { | 6286 } else { |
6287 value = StringToInt( | 6287 value = StringToInt( |
6288 isolate->unicode_cache(), flat.ToUC16Vector(), radix); | 6288 isolate->unicode_cache(), flat.ToUC16Vector(), radix); |
6289 } | 6289 } |
6290 } | 6290 } |
6291 | 6291 |
6292 return *isolate->factory()->NewNumber(value); | 6292 return *isolate->factory()->NewNumber(value); |
6293 } | 6293 } |
6294 | 6294 |
6295 | 6295 |
6296 RUNTIME_FUNCTION(Runtime_StringParseFloat) { | 6296 RUNTIME_FUNCTION(Runtime_StringParseFloat) { |
6297 HandleScope shs(isolate); | 6297 HandleScope shs(isolate); |
6298 ASSERT(args.length() == 1); | 6298 DCHECK(args.length() == 1); |
6299 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6299 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6300 | 6300 |
6301 subject = String::Flatten(subject); | 6301 subject = String::Flatten(subject); |
6302 double value = StringToDouble(isolate->unicode_cache(), *subject, | 6302 double value = StringToDouble(isolate->unicode_cache(), *subject, |
6303 ALLOW_TRAILING_JUNK, base::OS::nan_value()); | 6303 ALLOW_TRAILING_JUNK, base::OS::nan_value()); |
6304 | 6304 |
6305 return *isolate->factory()->NewNumber(value); | 6305 return *isolate->factory()->NewNumber(value); |
6306 } | 6306 } |
6307 | 6307 |
6308 | 6308 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6347 bool has_next = stream.HasMore(); | 6347 bool has_next = stream.HasMore(); |
6348 uc32 next = has_next ? stream.GetNext() : 0; | 6348 uc32 next = has_next ? stream.GetNext() : 0; |
6349 int char_length = mapping->get(current, next, chars); | 6349 int char_length = mapping->get(current, next, chars); |
6350 if (char_length == 0) { | 6350 if (char_length == 0) { |
6351 // The case conversion of this character is the character itself. | 6351 // The case conversion of this character is the character itself. |
6352 result->Set(i, current); | 6352 result->Set(i, current); |
6353 i++; | 6353 i++; |
6354 } else if (char_length == 1 && | 6354 } else if (char_length == 1 && |
6355 (ignore_overflow || !ToUpperOverflows(current))) { | 6355 (ignore_overflow || !ToUpperOverflows(current))) { |
6356 // Common case: converting the letter resulted in one character. | 6356 // Common case: converting the letter resulted in one character. |
6357 ASSERT(static_cast<uc32>(chars[0]) != current); | 6357 DCHECK(static_cast<uc32>(chars[0]) != current); |
6358 result->Set(i, chars[0]); | 6358 result->Set(i, chars[0]); |
6359 has_changed_character = true; | 6359 has_changed_character = true; |
6360 i++; | 6360 i++; |
6361 } else if (result_length == string->length()) { | 6361 } else if (result_length == string->length()) { |
6362 bool overflows = ToUpperOverflows(current); | 6362 bool overflows = ToUpperOverflows(current); |
6363 // We've assumed that the result would be as long as the | 6363 // We've assumed that the result would be as long as the |
6364 // input but here is a character that converts to several | 6364 // input but here is a character that converts to several |
6365 // characters. No matter, we calculate the exact length | 6365 // characters. No matter, we calculate the exact length |
6366 // of the result and try the whole thing again. | 6366 // of the result and try the whole thing again. |
6367 // | 6367 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6425 // Given a word and two range boundaries returns a word with high bit | 6425 // Given a word and two range boundaries returns a word with high bit |
6426 // set in every byte iff the corresponding input byte was strictly in | 6426 // set in every byte iff the corresponding input byte was strictly in |
6427 // the range (m, n). All the other bits in the result are cleared. | 6427 // the range (m, n). All the other bits in the result are cleared. |
6428 // This function is only useful when it can be inlined and the | 6428 // This function is only useful when it can be inlined and the |
6429 // boundaries are statically known. | 6429 // boundaries are statically known. |
6430 // Requires: all bytes in the input word and the boundaries must be | 6430 // Requires: all bytes in the input word and the boundaries must be |
6431 // ASCII (less than 0x7F). | 6431 // ASCII (less than 0x7F). |
6432 static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) { | 6432 static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) { |
6433 // Use strict inequalities since in edge cases the function could be | 6433 // Use strict inequalities since in edge cases the function could be |
6434 // further simplified. | 6434 // further simplified. |
6435 ASSERT(0 < m && m < n); | 6435 DCHECK(0 < m && m < n); |
6436 // Has high bit set in every w byte less than n. | 6436 // Has high bit set in every w byte less than n. |
6437 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; | 6437 uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w; |
6438 // Has high bit set in every w byte greater than m. | 6438 // Has high bit set in every w byte greater than m. |
6439 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); | 6439 uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m); |
6440 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); | 6440 return (tmp1 & tmp2 & (kOneInEveryByte * 0x80)); |
6441 } | 6441 } |
6442 | 6442 |
6443 | 6443 |
6444 #ifdef DEBUG | 6444 #ifdef DEBUG |
6445 static bool CheckFastAsciiConvert(char* dst, | 6445 static bool CheckFastAsciiConvert(char* dst, |
6446 const char* src, | 6446 const char* src, |
6447 int length, | 6447 int length, |
6448 bool changed, | 6448 bool changed, |
6449 bool is_to_lower) { | 6449 bool is_to_lower) { |
6450 bool expected_changed = false; | 6450 bool expected_changed = false; |
6451 for (int i = 0; i < length; i++) { | 6451 for (int i = 0; i < length; i++) { |
6452 if (dst[i] == src[i]) continue; | 6452 if (dst[i] == src[i]) continue; |
6453 expected_changed = true; | 6453 expected_changed = true; |
6454 if (is_to_lower) { | 6454 if (is_to_lower) { |
6455 ASSERT('A' <= src[i] && src[i] <= 'Z'); | 6455 DCHECK('A' <= src[i] && src[i] <= 'Z'); |
6456 ASSERT(dst[i] == src[i] + ('a' - 'A')); | 6456 DCHECK(dst[i] == src[i] + ('a' - 'A')); |
6457 } else { | 6457 } else { |
6458 ASSERT('a' <= src[i] && src[i] <= 'z'); | 6458 DCHECK('a' <= src[i] && src[i] <= 'z'); |
6459 ASSERT(dst[i] == src[i] - ('a' - 'A')); | 6459 DCHECK(dst[i] == src[i] - ('a' - 'A')); |
6460 } | 6460 } |
6461 } | 6461 } |
6462 return (expected_changed == changed); | 6462 return (expected_changed == changed); |
6463 } | 6463 } |
6464 #endif | 6464 #endif |
6465 | 6465 |
6466 | 6466 |
6467 template<class Converter> | 6467 template<class Converter> |
6468 static bool FastAsciiConvert(char* dst, | 6468 static bool FastAsciiConvert(char* dst, |
6469 const char* src, | 6469 const char* src, |
6470 int length, | 6470 int length, |
6471 bool* changed_out) { | 6471 bool* changed_out) { |
6472 #ifdef DEBUG | 6472 #ifdef DEBUG |
6473 char* saved_dst = dst; | 6473 char* saved_dst = dst; |
6474 const char* saved_src = src; | 6474 const char* saved_src = src; |
6475 #endif | 6475 #endif |
6476 DisallowHeapAllocation no_gc; | 6476 DisallowHeapAllocation no_gc; |
6477 // We rely on the distance between upper and lower case letters | 6477 // We rely on the distance between upper and lower case letters |
6478 // being a known power of 2. | 6478 // being a known power of 2. |
6479 ASSERT('a' - 'A' == (1 << 5)); | 6479 DCHECK('a' - 'A' == (1 << 5)); |
6480 // Boundaries for the range of input characters than require conversion. | 6480 // Boundaries for the range of input characters than require conversion. |
6481 static const char lo = Converter::kIsToLower ? 'A' - 1 : 'a' - 1; | 6481 static const char lo = Converter::kIsToLower ? 'A' - 1 : 'a' - 1; |
6482 static const char hi = Converter::kIsToLower ? 'Z' + 1 : 'z' + 1; | 6482 static const char hi = Converter::kIsToLower ? 'Z' + 1 : 'z' + 1; |
6483 bool changed = false; | 6483 bool changed = false; |
6484 uintptr_t or_acc = 0; | 6484 uintptr_t or_acc = 0; |
6485 const char* const limit = src + length; | 6485 const char* const limit = src + length; |
6486 #ifdef V8_HOST_CAN_READ_UNALIGNED | 6486 #ifdef V8_HOST_CAN_READ_UNALIGNED |
6487 // Process the prefix of the input that requires no conversion one | 6487 // Process the prefix of the input that requires no conversion one |
6488 // (machine) word at a time. | 6488 // (machine) word at a time. |
6489 while (src <= limit - sizeof(uintptr_t)) { | 6489 while (src <= limit - sizeof(uintptr_t)) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6521 changed = true; | 6521 changed = true; |
6522 } | 6522 } |
6523 *dst = c; | 6523 *dst = c; |
6524 ++src; | 6524 ++src; |
6525 ++dst; | 6525 ++dst; |
6526 } | 6526 } |
6527 if ((or_acc & kAsciiMask) != 0) { | 6527 if ((or_acc & kAsciiMask) != 0) { |
6528 return false; | 6528 return false; |
6529 } | 6529 } |
6530 | 6530 |
6531 ASSERT(CheckFastAsciiConvert( | 6531 DCHECK(CheckFastAsciiConvert( |
6532 saved_dst, saved_src, length, changed, Converter::kIsToLower)); | 6532 saved_dst, saved_src, length, changed, Converter::kIsToLower)); |
6533 | 6533 |
6534 *changed_out = changed; | 6534 *changed_out = changed; |
6535 return true; | 6535 return true; |
6536 } | 6536 } |
6537 | 6537 |
6538 } // namespace | 6538 } // namespace |
6539 | 6539 |
6540 | 6540 |
6541 template <class Converter> | 6541 template <class Converter> |
(...skipping 11 matching lines...) Expand all Loading... |
6553 // NOTE: This assumes that the upper/lower case of an ASCII | 6553 // NOTE: This assumes that the upper/lower case of an ASCII |
6554 // character is also ASCII. This is currently the case, but it | 6554 // character is also ASCII. This is currently the case, but it |
6555 // might break in the future if we implement more context and locale | 6555 // might break in the future if we implement more context and locale |
6556 // dependent upper/lower conversions. | 6556 // dependent upper/lower conversions. |
6557 if (s->IsOneByteRepresentationUnderneath()) { | 6557 if (s->IsOneByteRepresentationUnderneath()) { |
6558 // Same length as input. | 6558 // Same length as input. |
6559 Handle<SeqOneByteString> result = | 6559 Handle<SeqOneByteString> result = |
6560 isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); | 6560 isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); |
6561 DisallowHeapAllocation no_gc; | 6561 DisallowHeapAllocation no_gc; |
6562 String::FlatContent flat_content = s->GetFlatContent(); | 6562 String::FlatContent flat_content = s->GetFlatContent(); |
6563 ASSERT(flat_content.IsFlat()); | 6563 DCHECK(flat_content.IsFlat()); |
6564 bool has_changed_character = false; | 6564 bool has_changed_character = false; |
6565 bool is_ascii = FastAsciiConvert<Converter>( | 6565 bool is_ascii = FastAsciiConvert<Converter>( |
6566 reinterpret_cast<char*>(result->GetChars()), | 6566 reinterpret_cast<char*>(result->GetChars()), |
6567 reinterpret_cast<const char*>(flat_content.ToOneByteVector().start()), | 6567 reinterpret_cast<const char*>(flat_content.ToOneByteVector().start()), |
6568 length, | 6568 length, |
6569 &has_changed_character); | 6569 &has_changed_character); |
6570 // If not ASCII, we discard the result and take the 2 byte path. | 6570 // If not ASCII, we discard the result and take the 2 byte path. |
6571 if (is_ascii) return has_changed_character ? *result : *s; | 6571 if (is_ascii) return has_changed_character ? *result : *s; |
6572 } | 6572 } |
6573 | 6573 |
6574 Handle<SeqString> result; // Same length as input. | 6574 Handle<SeqString> result; // Same length as input. |
6575 if (s->IsOneByteRepresentation()) { | 6575 if (s->IsOneByteRepresentation()) { |
6576 result = isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); | 6576 result = isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); |
6577 } else { | 6577 } else { |
6578 result = isolate->factory()->NewRawTwoByteString(length).ToHandleChecked(); | 6578 result = isolate->factory()->NewRawTwoByteString(length).ToHandleChecked(); |
6579 } | 6579 } |
6580 | 6580 |
6581 Object* answer = ConvertCaseHelper(isolate, *s, *result, length, mapping); | 6581 Object* answer = ConvertCaseHelper(isolate, *s, *result, length, mapping); |
6582 if (answer->IsException() || answer->IsString()) return answer; | 6582 if (answer->IsException() || answer->IsString()) return answer; |
6583 | 6583 |
6584 ASSERT(answer->IsSmi()); | 6584 DCHECK(answer->IsSmi()); |
6585 length = Smi::cast(answer)->value(); | 6585 length = Smi::cast(answer)->value(); |
6586 if (s->IsOneByteRepresentation() && length > 0) { | 6586 if (s->IsOneByteRepresentation() && length > 0) { |
6587 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6587 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6588 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 6588 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
6589 } else { | 6589 } else { |
6590 if (length < 0) length = -length; | 6590 if (length < 0) length = -length; |
6591 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6591 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6592 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 6592 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
6593 } | 6593 } |
6594 return ConvertCaseHelper(isolate, *s, *result, length, mapping); | 6594 return ConvertCaseHelper(isolate, *s, *result, length, mapping); |
6595 } | 6595 } |
6596 | 6596 |
6597 | 6597 |
6598 RUNTIME_FUNCTION(Runtime_StringToLowerCase) { | 6598 RUNTIME_FUNCTION(Runtime_StringToLowerCase) { |
6599 HandleScope scope(isolate); | 6599 HandleScope scope(isolate); |
6600 ASSERT(args.length() == 1); | 6600 DCHECK(args.length() == 1); |
6601 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6601 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
6602 return ConvertCase( | 6602 return ConvertCase( |
6603 s, isolate, isolate->runtime_state()->to_lower_mapping()); | 6603 s, isolate, isolate->runtime_state()->to_lower_mapping()); |
6604 } | 6604 } |
6605 | 6605 |
6606 | 6606 |
6607 RUNTIME_FUNCTION(Runtime_StringToUpperCase) { | 6607 RUNTIME_FUNCTION(Runtime_StringToUpperCase) { |
6608 HandleScope scope(isolate); | 6608 HandleScope scope(isolate); |
6609 ASSERT(args.length() == 1); | 6609 DCHECK(args.length() == 1); |
6610 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6610 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
6611 return ConvertCase( | 6611 return ConvertCase( |
6612 s, isolate, isolate->runtime_state()->to_upper_mapping()); | 6612 s, isolate, isolate->runtime_state()->to_upper_mapping()); |
6613 } | 6613 } |
6614 | 6614 |
6615 | 6615 |
6616 RUNTIME_FUNCTION(Runtime_StringTrim) { | 6616 RUNTIME_FUNCTION(Runtime_StringTrim) { |
6617 HandleScope scope(isolate); | 6617 HandleScope scope(isolate); |
6618 ASSERT(args.length() == 3); | 6618 DCHECK(args.length() == 3); |
6619 | 6619 |
6620 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 6620 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
6621 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); | 6621 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); |
6622 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); | 6622 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); |
6623 | 6623 |
6624 string = String::Flatten(string); | 6624 string = String::Flatten(string); |
6625 int length = string->length(); | 6625 int length = string->length(); |
6626 | 6626 |
6627 int left = 0; | 6627 int left = 0; |
6628 UnicodeCache* unicode_cache = isolate->unicode_cache(); | 6628 UnicodeCache* unicode_cache = isolate->unicode_cache(); |
(...skipping 12 matching lines...) Expand all Loading... |
6641 right--; | 6641 right--; |
6642 } | 6642 } |
6643 } | 6643 } |
6644 | 6644 |
6645 return *isolate->factory()->NewSubString(string, left, right); | 6645 return *isolate->factory()->NewSubString(string, left, right); |
6646 } | 6646 } |
6647 | 6647 |
6648 | 6648 |
6649 RUNTIME_FUNCTION(Runtime_StringSplit) { | 6649 RUNTIME_FUNCTION(Runtime_StringSplit) { |
6650 HandleScope handle_scope(isolate); | 6650 HandleScope handle_scope(isolate); |
6651 ASSERT(args.length() == 3); | 6651 DCHECK(args.length() == 3); |
6652 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6652 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6653 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 6653 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
6654 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); | 6654 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); |
6655 RUNTIME_ASSERT(limit > 0); | 6655 RUNTIME_ASSERT(limit > 0); |
6656 | 6656 |
6657 int subject_length = subject->length(); | 6657 int subject_length = subject->length(); |
6658 int pattern_length = pattern->length(); | 6658 int pattern_length = pattern->length(); |
6659 RUNTIME_ASSERT(pattern_length > 0); | 6659 RUNTIME_ASSERT(pattern_length > 0); |
6660 | 6660 |
6661 if (limit == 0xffffffffu) { | 6661 if (limit == 0xffffffffu) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6698 | 6698 |
6699 // The list indices now contains the end of each part to create. | 6699 // The list indices now contains the end of each part to create. |
6700 | 6700 |
6701 // Create JSArray of substrings separated by separator. | 6701 // Create JSArray of substrings separated by separator. |
6702 int part_count = indices.length(); | 6702 int part_count = indices.length(); |
6703 | 6703 |
6704 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count); | 6704 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count); |
6705 JSObject::EnsureCanContainHeapObjectElements(result); | 6705 JSObject::EnsureCanContainHeapObjectElements(result); |
6706 result->set_length(Smi::FromInt(part_count)); | 6706 result->set_length(Smi::FromInt(part_count)); |
6707 | 6707 |
6708 ASSERT(result->HasFastObjectElements()); | 6708 DCHECK(result->HasFastObjectElements()); |
6709 | 6709 |
6710 if (part_count == 1 && indices.at(0) == subject_length) { | 6710 if (part_count == 1 && indices.at(0) == subject_length) { |
6711 FixedArray::cast(result->elements())->set(0, *subject); | 6711 FixedArray::cast(result->elements())->set(0, *subject); |
6712 return *result; | 6712 return *result; |
6713 } | 6713 } |
6714 | 6714 |
6715 Handle<FixedArray> elements(FixedArray::cast(result->elements())); | 6715 Handle<FixedArray> elements(FixedArray::cast(result->elements())); |
6716 int part_start = 0; | 6716 int part_start = 0; |
6717 for (int i = 0; i < part_count; i++) { | 6717 for (int i = 0; i < part_count; i++) { |
6718 HandleScope local_loop_handle(isolate); | 6718 HandleScope local_loop_handle(isolate); |
(...skipping 30 matching lines...) Expand all Loading... |
6749 FixedArray* ascii_cache = heap->single_character_string_cache(); | 6749 FixedArray* ascii_cache = heap->single_character_string_cache(); |
6750 Object* undefined = heap->undefined_value(); | 6750 Object* undefined = heap->undefined_value(); |
6751 int i; | 6751 int i; |
6752 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); | 6752 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); |
6753 for (i = 0; i < length; ++i) { | 6753 for (i = 0; i < length; ++i) { |
6754 Object* value = ascii_cache->get(chars[i]); | 6754 Object* value = ascii_cache->get(chars[i]); |
6755 if (value == undefined) break; | 6755 if (value == undefined) break; |
6756 elements->set(i, value, mode); | 6756 elements->set(i, value, mode); |
6757 } | 6757 } |
6758 if (i < length) { | 6758 if (i < length) { |
6759 ASSERT(Smi::FromInt(0) == 0); | 6759 DCHECK(Smi::FromInt(0) == 0); |
6760 memset(elements->data_start() + i, 0, kPointerSize * (length - i)); | 6760 memset(elements->data_start() + i, 0, kPointerSize * (length - i)); |
6761 } | 6761 } |
6762 #ifdef DEBUG | 6762 #ifdef DEBUG |
6763 for (int j = 0; j < length; ++j) { | 6763 for (int j = 0; j < length; ++j) { |
6764 Object* element = elements->get(j); | 6764 Object* element = elements->get(j); |
6765 ASSERT(element == Smi::FromInt(0) || | 6765 DCHECK(element == Smi::FromInt(0) || |
6766 (element->IsString() && String::cast(element)->LooksValid())); | 6766 (element->IsString() && String::cast(element)->LooksValid())); |
6767 } | 6767 } |
6768 #endif | 6768 #endif |
6769 return i; | 6769 return i; |
6770 } | 6770 } |
6771 | 6771 |
6772 | 6772 |
6773 // Converts a String to JSArray. | 6773 // Converts a String to JSArray. |
6774 // For example, "foo" => ["f", "o", "o"]. | 6774 // For example, "foo" => ["f", "o", "o"]. |
6775 RUNTIME_FUNCTION(Runtime_StringToArray) { | 6775 RUNTIME_FUNCTION(Runtime_StringToArray) { |
6776 HandleScope scope(isolate); | 6776 HandleScope scope(isolate); |
6777 ASSERT(args.length() == 2); | 6777 DCHECK(args.length() == 2); |
6778 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6778 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
6779 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 6779 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
6780 | 6780 |
6781 s = String::Flatten(s); | 6781 s = String::Flatten(s); |
6782 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); | 6782 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); |
6783 | 6783 |
6784 Handle<FixedArray> elements; | 6784 Handle<FixedArray> elements; |
6785 int position = 0; | 6785 int position = 0; |
6786 if (s->IsFlat() && s->IsOneByteRepresentation()) { | 6786 if (s->IsFlat() && s->IsOneByteRepresentation()) { |
6787 // Try using cached chars where possible. | 6787 // Try using cached chars where possible. |
(...skipping 18 matching lines...) Expand all Loading... |
6806 elements = isolate->factory()->NewFixedArray(length); | 6806 elements = isolate->factory()->NewFixedArray(length); |
6807 } | 6807 } |
6808 for (int i = position; i < length; ++i) { | 6808 for (int i = position; i < length; ++i) { |
6809 Handle<Object> str = | 6809 Handle<Object> str = |
6810 isolate->factory()->LookupSingleCharacterStringFromCode(s->Get(i)); | 6810 isolate->factory()->LookupSingleCharacterStringFromCode(s->Get(i)); |
6811 elements->set(i, *str); | 6811 elements->set(i, *str); |
6812 } | 6812 } |
6813 | 6813 |
6814 #ifdef DEBUG | 6814 #ifdef DEBUG |
6815 for (int i = 0; i < length; ++i) { | 6815 for (int i = 0; i < length; ++i) { |
6816 ASSERT(String::cast(elements->get(i))->length() == 1); | 6816 DCHECK(String::cast(elements->get(i))->length() == 1); |
6817 } | 6817 } |
6818 #endif | 6818 #endif |
6819 | 6819 |
6820 return *isolate->factory()->NewJSArrayWithElements(elements); | 6820 return *isolate->factory()->NewJSArrayWithElements(elements); |
6821 } | 6821 } |
6822 | 6822 |
6823 | 6823 |
6824 RUNTIME_FUNCTION(Runtime_NewStringWrapper) { | 6824 RUNTIME_FUNCTION(Runtime_NewStringWrapper) { |
6825 HandleScope scope(isolate); | 6825 HandleScope scope(isolate); |
6826 ASSERT(args.length() == 1); | 6826 DCHECK(args.length() == 1); |
6827 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); | 6827 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); |
6828 return *Object::ToObject(isolate, value).ToHandleChecked(); | 6828 return *Object::ToObject(isolate, value).ToHandleChecked(); |
6829 } | 6829 } |
6830 | 6830 |
6831 | 6831 |
6832 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6832 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
6833 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6833 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
6834 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6834 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
6835 return char_length == 0; | 6835 return char_length == 0; |
6836 } | 6836 } |
6837 | 6837 |
6838 | 6838 |
6839 RUNTIME_FUNCTION(Runtime_NumberToStringRT) { | 6839 RUNTIME_FUNCTION(Runtime_NumberToStringRT) { |
6840 HandleScope scope(isolate); | 6840 HandleScope scope(isolate); |
6841 ASSERT(args.length() == 1); | 6841 DCHECK(args.length() == 1); |
6842 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6842 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
6843 | 6843 |
6844 return *isolate->factory()->NumberToString(number); | 6844 return *isolate->factory()->NumberToString(number); |
6845 } | 6845 } |
6846 | 6846 |
6847 | 6847 |
6848 RUNTIME_FUNCTION(Runtime_NumberToStringSkipCache) { | 6848 RUNTIME_FUNCTION(Runtime_NumberToStringSkipCache) { |
6849 HandleScope scope(isolate); | 6849 HandleScope scope(isolate); |
6850 ASSERT(args.length() == 1); | 6850 DCHECK(args.length() == 1); |
6851 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6851 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
6852 | 6852 |
6853 return *isolate->factory()->NumberToString(number, false); | 6853 return *isolate->factory()->NumberToString(number, false); |
6854 } | 6854 } |
6855 | 6855 |
6856 | 6856 |
6857 RUNTIME_FUNCTION(Runtime_NumberToInteger) { | 6857 RUNTIME_FUNCTION(Runtime_NumberToInteger) { |
6858 HandleScope scope(isolate); | 6858 HandleScope scope(isolate); |
6859 ASSERT(args.length() == 1); | 6859 DCHECK(args.length() == 1); |
6860 | 6860 |
6861 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6861 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6862 return *isolate->factory()->NewNumber(DoubleToInteger(number)); | 6862 return *isolate->factory()->NewNumber(DoubleToInteger(number)); |
6863 } | 6863 } |
6864 | 6864 |
6865 | 6865 |
6866 RUNTIME_FUNCTION(Runtime_NumberToIntegerMapMinusZero) { | 6866 RUNTIME_FUNCTION(Runtime_NumberToIntegerMapMinusZero) { |
6867 HandleScope scope(isolate); | 6867 HandleScope scope(isolate); |
6868 ASSERT(args.length() == 1); | 6868 DCHECK(args.length() == 1); |
6869 | 6869 |
6870 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6870 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6871 double double_value = DoubleToInteger(number); | 6871 double double_value = DoubleToInteger(number); |
6872 // Map both -0 and +0 to +0. | 6872 // Map both -0 and +0 to +0. |
6873 if (double_value == 0) double_value = 0; | 6873 if (double_value == 0) double_value = 0; |
6874 | 6874 |
6875 return *isolate->factory()->NewNumber(double_value); | 6875 return *isolate->factory()->NewNumber(double_value); |
6876 } | 6876 } |
6877 | 6877 |
6878 | 6878 |
6879 RUNTIME_FUNCTION(Runtime_NumberToJSUint32) { | 6879 RUNTIME_FUNCTION(Runtime_NumberToJSUint32) { |
6880 HandleScope scope(isolate); | 6880 HandleScope scope(isolate); |
6881 ASSERT(args.length() == 1); | 6881 DCHECK(args.length() == 1); |
6882 | 6882 |
6883 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 6883 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
6884 return *isolate->factory()->NewNumberFromUint(number); | 6884 return *isolate->factory()->NewNumberFromUint(number); |
6885 } | 6885 } |
6886 | 6886 |
6887 | 6887 |
6888 RUNTIME_FUNCTION(Runtime_NumberToJSInt32) { | 6888 RUNTIME_FUNCTION(Runtime_NumberToJSInt32) { |
6889 HandleScope scope(isolate); | 6889 HandleScope scope(isolate); |
6890 ASSERT(args.length() == 1); | 6890 DCHECK(args.length() == 1); |
6891 | 6891 |
6892 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6892 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6893 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); | 6893 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); |
6894 } | 6894 } |
6895 | 6895 |
6896 | 6896 |
6897 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 6897 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
6898 // a small integer. | 6898 // a small integer. |
6899 RUNTIME_FUNCTION(Runtime_NumberToSmi) { | 6899 RUNTIME_FUNCTION(Runtime_NumberToSmi) { |
6900 SealHandleScope shs(isolate); | 6900 SealHandleScope shs(isolate); |
6901 ASSERT(args.length() == 1); | 6901 DCHECK(args.length() == 1); |
6902 CONVERT_ARG_CHECKED(Object, obj, 0); | 6902 CONVERT_ARG_CHECKED(Object, obj, 0); |
6903 if (obj->IsSmi()) { | 6903 if (obj->IsSmi()) { |
6904 return obj; | 6904 return obj; |
6905 } | 6905 } |
6906 if (obj->IsHeapNumber()) { | 6906 if (obj->IsHeapNumber()) { |
6907 double value = HeapNumber::cast(obj)->value(); | 6907 double value = HeapNumber::cast(obj)->value(); |
6908 int int_value = FastD2I(value); | 6908 int int_value = FastD2I(value); |
6909 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 6909 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
6910 return Smi::FromInt(int_value); | 6910 return Smi::FromInt(int_value); |
6911 } | 6911 } |
6912 } | 6912 } |
6913 return isolate->heap()->nan_value(); | 6913 return isolate->heap()->nan_value(); |
6914 } | 6914 } |
6915 | 6915 |
6916 | 6916 |
6917 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { | 6917 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { |
6918 HandleScope scope(isolate); | 6918 HandleScope scope(isolate); |
6919 ASSERT(args.length() == 0); | 6919 DCHECK(args.length() == 0); |
6920 return *isolate->factory()->NewHeapNumber(0); | 6920 return *isolate->factory()->NewHeapNumber(0); |
6921 } | 6921 } |
6922 | 6922 |
6923 | 6923 |
6924 RUNTIME_FUNCTION(Runtime_NumberAdd) { | 6924 RUNTIME_FUNCTION(Runtime_NumberAdd) { |
6925 HandleScope scope(isolate); | 6925 HandleScope scope(isolate); |
6926 ASSERT(args.length() == 2); | 6926 DCHECK(args.length() == 2); |
6927 | 6927 |
6928 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6928 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6929 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6929 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6930 return *isolate->factory()->NewNumber(x + y); | 6930 return *isolate->factory()->NewNumber(x + y); |
6931 } | 6931 } |
6932 | 6932 |
6933 | 6933 |
6934 RUNTIME_FUNCTION(Runtime_NumberSub) { | 6934 RUNTIME_FUNCTION(Runtime_NumberSub) { |
6935 HandleScope scope(isolate); | 6935 HandleScope scope(isolate); |
6936 ASSERT(args.length() == 2); | 6936 DCHECK(args.length() == 2); |
6937 | 6937 |
6938 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6938 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6939 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6939 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6940 return *isolate->factory()->NewNumber(x - y); | 6940 return *isolate->factory()->NewNumber(x - y); |
6941 } | 6941 } |
6942 | 6942 |
6943 | 6943 |
6944 RUNTIME_FUNCTION(Runtime_NumberMul) { | 6944 RUNTIME_FUNCTION(Runtime_NumberMul) { |
6945 HandleScope scope(isolate); | 6945 HandleScope scope(isolate); |
6946 ASSERT(args.length() == 2); | 6946 DCHECK(args.length() == 2); |
6947 | 6947 |
6948 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6948 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6949 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6949 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6950 return *isolate->factory()->NewNumber(x * y); | 6950 return *isolate->factory()->NewNumber(x * y); |
6951 } | 6951 } |
6952 | 6952 |
6953 | 6953 |
6954 RUNTIME_FUNCTION(Runtime_NumberUnaryMinus) { | 6954 RUNTIME_FUNCTION(Runtime_NumberUnaryMinus) { |
6955 HandleScope scope(isolate); | 6955 HandleScope scope(isolate); |
6956 ASSERT(args.length() == 1); | 6956 DCHECK(args.length() == 1); |
6957 | 6957 |
6958 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6958 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6959 return *isolate->factory()->NewNumber(-x); | 6959 return *isolate->factory()->NewNumber(-x); |
6960 } | 6960 } |
6961 | 6961 |
6962 | 6962 |
6963 RUNTIME_FUNCTION(Runtime_NumberDiv) { | 6963 RUNTIME_FUNCTION(Runtime_NumberDiv) { |
6964 HandleScope scope(isolate); | 6964 HandleScope scope(isolate); |
6965 ASSERT(args.length() == 2); | 6965 DCHECK(args.length() == 2); |
6966 | 6966 |
6967 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6967 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6968 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6968 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6969 return *isolate->factory()->NewNumber(x / y); | 6969 return *isolate->factory()->NewNumber(x / y); |
6970 } | 6970 } |
6971 | 6971 |
6972 | 6972 |
6973 RUNTIME_FUNCTION(Runtime_NumberMod) { | 6973 RUNTIME_FUNCTION(Runtime_NumberMod) { |
6974 HandleScope scope(isolate); | 6974 HandleScope scope(isolate); |
6975 ASSERT(args.length() == 2); | 6975 DCHECK(args.length() == 2); |
6976 | 6976 |
6977 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6977 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6978 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6978 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6979 return *isolate->factory()->NewNumber(modulo(x, y)); | 6979 return *isolate->factory()->NewNumber(modulo(x, y)); |
6980 } | 6980 } |
6981 | 6981 |
6982 | 6982 |
6983 RUNTIME_FUNCTION(Runtime_NumberImul) { | 6983 RUNTIME_FUNCTION(Runtime_NumberImul) { |
6984 HandleScope scope(isolate); | 6984 HandleScope scope(isolate); |
6985 ASSERT(args.length() == 2); | 6985 DCHECK(args.length() == 2); |
6986 | 6986 |
6987 // We rely on implementation-defined behavior below, but at least not on | 6987 // We rely on implementation-defined behavior below, but at least not on |
6988 // undefined behavior. | 6988 // undefined behavior. |
6989 CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]); | 6989 CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]); |
6990 CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]); | 6990 CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]); |
6991 int32_t product = static_cast<int32_t>(x * y); | 6991 int32_t product = static_cast<int32_t>(x * y); |
6992 return *isolate->factory()->NewNumberFromInt(product); | 6992 return *isolate->factory()->NewNumberFromInt(product); |
6993 } | 6993 } |
6994 | 6994 |
6995 | 6995 |
6996 RUNTIME_FUNCTION(Runtime_StringAdd) { | 6996 RUNTIME_FUNCTION(Runtime_StringAdd) { |
6997 HandleScope scope(isolate); | 6997 HandleScope scope(isolate); |
6998 ASSERT(args.length() == 2); | 6998 DCHECK(args.length() == 2); |
6999 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 6999 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
7000 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 7000 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
7001 isolate->counters()->string_add_runtime()->Increment(); | 7001 isolate->counters()->string_add_runtime()->Increment(); |
7002 Handle<String> result; | 7002 Handle<String> result; |
7003 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 7003 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
7004 isolate, result, isolate->factory()->NewConsString(str1, str2)); | 7004 isolate, result, isolate->factory()->NewConsString(str1, str2)); |
7005 return *result; | 7005 return *result; |
7006 } | 7006 } |
7007 | 7007 |
7008 | 7008 |
(...skipping 11 matching lines...) Expand all Loading... |
7020 int encoded_slice = Smi::cast(element)->value(); | 7020 int encoded_slice = Smi::cast(element)->value(); |
7021 int pos; | 7021 int pos; |
7022 int len; | 7022 int len; |
7023 if (encoded_slice > 0) { | 7023 if (encoded_slice > 0) { |
7024 // Position and length encoded in one smi. | 7024 // Position and length encoded in one smi. |
7025 pos = StringBuilderSubstringPosition::decode(encoded_slice); | 7025 pos = StringBuilderSubstringPosition::decode(encoded_slice); |
7026 len = StringBuilderSubstringLength::decode(encoded_slice); | 7026 len = StringBuilderSubstringLength::decode(encoded_slice); |
7027 } else { | 7027 } else { |
7028 // Position and length encoded in two smis. | 7028 // Position and length encoded in two smis. |
7029 Object* obj = fixed_array->get(++i); | 7029 Object* obj = fixed_array->get(++i); |
7030 ASSERT(obj->IsSmi()); | 7030 DCHECK(obj->IsSmi()); |
7031 pos = Smi::cast(obj)->value(); | 7031 pos = Smi::cast(obj)->value(); |
7032 len = -encoded_slice; | 7032 len = -encoded_slice; |
7033 } | 7033 } |
7034 String::WriteToFlat(special, | 7034 String::WriteToFlat(special, |
7035 sink + position, | 7035 sink + position, |
7036 pos, | 7036 pos, |
7037 pos + len); | 7037 pos + len); |
7038 position += len; | 7038 position += len; |
7039 } else { | 7039 } else { |
7040 String* string = String::cast(element); | 7040 String* string = String::cast(element); |
(...skipping 29 matching lines...) Expand all Loading... |
7070 // Position and length encoded in two smis. | 7070 // Position and length encoded in two smis. |
7071 len = -smi_value; | 7071 len = -smi_value; |
7072 // Get the position and check that it is a positive smi. | 7072 // Get the position and check that it is a positive smi. |
7073 i++; | 7073 i++; |
7074 if (i >= array_length) return -1; | 7074 if (i >= array_length) return -1; |
7075 Object* next_smi = fixed_array->get(i); | 7075 Object* next_smi = fixed_array->get(i); |
7076 if (!next_smi->IsSmi()) return -1; | 7076 if (!next_smi->IsSmi()) return -1; |
7077 pos = Smi::cast(next_smi)->value(); | 7077 pos = Smi::cast(next_smi)->value(); |
7078 if (pos < 0) return -1; | 7078 if (pos < 0) return -1; |
7079 } | 7079 } |
7080 ASSERT(pos >= 0); | 7080 DCHECK(pos >= 0); |
7081 ASSERT(len >= 0); | 7081 DCHECK(len >= 0); |
7082 if (pos > special_length || len > special_length - pos) return -1; | 7082 if (pos > special_length || len > special_length - pos) return -1; |
7083 increment = len; | 7083 increment = len; |
7084 } else if (elt->IsString()) { | 7084 } else if (elt->IsString()) { |
7085 String* element = String::cast(elt); | 7085 String* element = String::cast(elt); |
7086 int element_length = element->length(); | 7086 int element_length = element->length(); |
7087 increment = element_length; | 7087 increment = element_length; |
7088 if (*one_byte && !element->HasOnlyOneByteChars()) { | 7088 if (*one_byte && !element->HasOnlyOneByteChars()) { |
7089 *one_byte = false; | 7089 *one_byte = false; |
7090 } | 7090 } |
7091 } else { | 7091 } else { |
7092 return -1; | 7092 return -1; |
7093 } | 7093 } |
7094 if (increment > String::kMaxLength - position) { | 7094 if (increment > String::kMaxLength - position) { |
7095 return kMaxInt; // Provoke throw on allocation. | 7095 return kMaxInt; // Provoke throw on allocation. |
7096 } | 7096 } |
7097 position += increment; | 7097 position += increment; |
7098 } | 7098 } |
7099 return position; | 7099 return position; |
7100 } | 7100 } |
7101 | 7101 |
7102 | 7102 |
7103 RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { | 7103 RUNTIME_FUNCTION(Runtime_StringBuilderConcat) { |
7104 HandleScope scope(isolate); | 7104 HandleScope scope(isolate); |
7105 ASSERT(args.length() == 3); | 7105 DCHECK(args.length() == 3); |
7106 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7106 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7107 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7107 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); |
7108 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7108 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
7109 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); | 7109 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); |
7110 | 7110 |
7111 size_t actual_array_length = 0; | 7111 size_t actual_array_length = 0; |
7112 RUNTIME_ASSERT( | 7112 RUNTIME_ASSERT( |
7113 TryNumberToSize(isolate, array->length(), &actual_array_length)); | 7113 TryNumberToSize(isolate, array->length(), &actual_array_length)); |
7114 RUNTIME_ASSERT(array_length >= 0); | 7114 RUNTIME_ASSERT(array_length >= 0); |
7115 RUNTIME_ASSERT(static_cast<size_t>(array_length) <= actual_array_length); | 7115 RUNTIME_ASSERT(static_cast<size_t>(array_length) <= actual_array_length); |
7116 | 7116 |
7117 // This assumption is used by the slice encoding in one or two smis. | 7117 // This assumption is used by the slice encoding in one or two smis. |
7118 ASSERT(Smi::kMaxValue >= String::kMaxLength); | 7118 DCHECK(Smi::kMaxValue >= String::kMaxLength); |
7119 | 7119 |
7120 RUNTIME_ASSERT(array->HasFastElements()); | 7120 RUNTIME_ASSERT(array->HasFastElements()); |
7121 JSObject::EnsureCanContainHeapObjectElements(array); | 7121 JSObject::EnsureCanContainHeapObjectElements(array); |
7122 | 7122 |
7123 int special_length = special->length(); | 7123 int special_length = special->length(); |
7124 if (!array->HasFastObjectElements()) { | 7124 if (!array->HasFastObjectElements()) { |
7125 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 7125 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
7126 } | 7126 } |
7127 | 7127 |
7128 int length; | 7128 int length; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7167 answer->GetChars(), | 7167 answer->GetChars(), |
7168 FixedArray::cast(array->elements()), | 7168 FixedArray::cast(array->elements()), |
7169 array_length); | 7169 array_length); |
7170 return *answer; | 7170 return *answer; |
7171 } | 7171 } |
7172 } | 7172 } |
7173 | 7173 |
7174 | 7174 |
7175 RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { | 7175 RUNTIME_FUNCTION(Runtime_StringBuilderJoin) { |
7176 HandleScope scope(isolate); | 7176 HandleScope scope(isolate); |
7177 ASSERT(args.length() == 3); | 7177 DCHECK(args.length() == 3); |
7178 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7178 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7179 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7179 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); |
7180 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7180 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
7181 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7181 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
7182 RUNTIME_ASSERT(array->HasFastObjectElements()); | 7182 RUNTIME_ASSERT(array->HasFastObjectElements()); |
7183 RUNTIME_ASSERT(array_length >= 0); | 7183 RUNTIME_ASSERT(array_length >= 0); |
7184 | 7184 |
7185 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); | 7185 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); |
7186 if (fixed_array->length() < array_length) { | 7186 if (fixed_array->length() < array_length) { |
7187 array_length = fixed_array->length(); | 7187 array_length = fixed_array->length(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7229 #endif | 7229 #endif |
7230 | 7230 |
7231 RUNTIME_ASSERT(fixed_array->get(0)->IsString()); | 7231 RUNTIME_ASSERT(fixed_array->get(0)->IsString()); |
7232 String* first = String::cast(fixed_array->get(0)); | 7232 String* first = String::cast(fixed_array->get(0)); |
7233 String* separator_raw = *separator; | 7233 String* separator_raw = *separator; |
7234 int first_length = first->length(); | 7234 int first_length = first->length(); |
7235 String::WriteToFlat(first, sink, 0, first_length); | 7235 String::WriteToFlat(first, sink, 0, first_length); |
7236 sink += first_length; | 7236 sink += first_length; |
7237 | 7237 |
7238 for (int i = 1; i < array_length; i++) { | 7238 for (int i = 1; i < array_length; i++) { |
7239 ASSERT(sink + separator_length <= end); | 7239 DCHECK(sink + separator_length <= end); |
7240 String::WriteToFlat(separator_raw, sink, 0, separator_length); | 7240 String::WriteToFlat(separator_raw, sink, 0, separator_length); |
7241 sink += separator_length; | 7241 sink += separator_length; |
7242 | 7242 |
7243 RUNTIME_ASSERT(fixed_array->get(i)->IsString()); | 7243 RUNTIME_ASSERT(fixed_array->get(i)->IsString()); |
7244 String* element = String::cast(fixed_array->get(i)); | 7244 String* element = String::cast(fixed_array->get(i)); |
7245 int element_length = element->length(); | 7245 int element_length = element->length(); |
7246 ASSERT(sink + element_length <= end); | 7246 DCHECK(sink + element_length <= end); |
7247 String::WriteToFlat(element, sink, 0, element_length); | 7247 String::WriteToFlat(element, sink, 0, element_length); |
7248 sink += element_length; | 7248 sink += element_length; |
7249 } | 7249 } |
7250 ASSERT(sink == end); | 7250 DCHECK(sink == end); |
7251 | 7251 |
7252 // Use %_FastAsciiArrayJoin instead. | 7252 // Use %_FastAsciiArrayJoin instead. |
7253 ASSERT(!answer->IsOneByteRepresentation()); | 7253 DCHECK(!answer->IsOneByteRepresentation()); |
7254 return *answer; | 7254 return *answer; |
7255 } | 7255 } |
7256 | 7256 |
7257 template <typename Char> | 7257 template <typename Char> |
7258 static void JoinSparseArrayWithSeparator(FixedArray* elements, | 7258 static void JoinSparseArrayWithSeparator(FixedArray* elements, |
7259 int elements_length, | 7259 int elements_length, |
7260 uint32_t array_length, | 7260 uint32_t array_length, |
7261 String* separator, | 7261 String* separator, |
7262 Vector<Char> buffer) { | 7262 Vector<Char> buffer) { |
7263 DisallowHeapAllocation no_gc; | 7263 DisallowHeapAllocation no_gc; |
(...skipping 12 matching lines...) Expand all Loading... |
7276 previous_separator_position++; | 7276 previous_separator_position++; |
7277 } | 7277 } |
7278 String::WriteToFlat<Char>(string, &buffer[cursor], | 7278 String::WriteToFlat<Char>(string, &buffer[cursor], |
7279 0, string_length); | 7279 0, string_length); |
7280 cursor += string->length(); | 7280 cursor += string->length(); |
7281 } | 7281 } |
7282 } | 7282 } |
7283 if (separator_length > 0) { | 7283 if (separator_length > 0) { |
7284 // Array length must be representable as a signed 32-bit number, | 7284 // Array length must be representable as a signed 32-bit number, |
7285 // otherwise the total string length would have been too large. | 7285 // otherwise the total string length would have been too large. |
7286 ASSERT(array_length <= 0x7fffffff); // Is int32_t. | 7286 DCHECK(array_length <= 0x7fffffff); // Is int32_t. |
7287 int last_array_index = static_cast<int>(array_length - 1); | 7287 int last_array_index = static_cast<int>(array_length - 1); |
7288 while (previous_separator_position < last_array_index) { | 7288 while (previous_separator_position < last_array_index) { |
7289 String::WriteToFlat<Char>(separator, &buffer[cursor], | 7289 String::WriteToFlat<Char>(separator, &buffer[cursor], |
7290 0, separator_length); | 7290 0, separator_length); |
7291 cursor += separator_length; | 7291 cursor += separator_length; |
7292 previous_separator_position++; | 7292 previous_separator_position++; |
7293 } | 7293 } |
7294 } | 7294 } |
7295 ASSERT(cursor <= buffer.length()); | 7295 DCHECK(cursor <= buffer.length()); |
7296 } | 7296 } |
7297 | 7297 |
7298 | 7298 |
7299 RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) { | 7299 RUNTIME_FUNCTION(Runtime_SparseJoinWithSeparator) { |
7300 HandleScope scope(isolate); | 7300 HandleScope scope(isolate); |
7301 ASSERT(args.length() == 3); | 7301 DCHECK(args.length() == 3); |
7302 CONVERT_ARG_HANDLE_CHECKED(JSArray, elements_array, 0); | 7302 CONVERT_ARG_HANDLE_CHECKED(JSArray, elements_array, 0); |
7303 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 7303 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
7304 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7304 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
7305 // elements_array is fast-mode JSarray of alternating positions | 7305 // elements_array is fast-mode JSarray of alternating positions |
7306 // (increasing order) and strings. | 7306 // (increasing order) and strings. |
7307 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); | 7307 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); |
7308 // array_length is length of original array (used to add separators); | 7308 // array_length is length of original array (used to add separators); |
7309 // separator is string to put between elements. Assumed to be non-empty. | 7309 // separator is string to put between elements. Assumed to be non-empty. |
7310 RUNTIME_ASSERT(array_length > 0); | 7310 RUNTIME_ASSERT(array_length > 0); |
7311 | 7311 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7384 array_length, | 7384 array_length, |
7385 *separator, | 7385 *separator, |
7386 Vector<uc16>(result->GetChars(), string_length)); | 7386 Vector<uc16>(result->GetChars(), string_length)); |
7387 return *result; | 7387 return *result; |
7388 } | 7388 } |
7389 } | 7389 } |
7390 | 7390 |
7391 | 7391 |
7392 RUNTIME_FUNCTION(Runtime_NumberOr) { | 7392 RUNTIME_FUNCTION(Runtime_NumberOr) { |
7393 HandleScope scope(isolate); | 7393 HandleScope scope(isolate); |
7394 ASSERT(args.length() == 2); | 7394 DCHECK(args.length() == 2); |
7395 | 7395 |
7396 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7396 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7397 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7397 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7398 return *isolate->factory()->NewNumberFromInt(x | y); | 7398 return *isolate->factory()->NewNumberFromInt(x | y); |
7399 } | 7399 } |
7400 | 7400 |
7401 | 7401 |
7402 RUNTIME_FUNCTION(Runtime_NumberAnd) { | 7402 RUNTIME_FUNCTION(Runtime_NumberAnd) { |
7403 HandleScope scope(isolate); | 7403 HandleScope scope(isolate); |
7404 ASSERT(args.length() == 2); | 7404 DCHECK(args.length() == 2); |
7405 | 7405 |
7406 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7406 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7407 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7407 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7408 return *isolate->factory()->NewNumberFromInt(x & y); | 7408 return *isolate->factory()->NewNumberFromInt(x & y); |
7409 } | 7409 } |
7410 | 7410 |
7411 | 7411 |
7412 RUNTIME_FUNCTION(Runtime_NumberXor) { | 7412 RUNTIME_FUNCTION(Runtime_NumberXor) { |
7413 HandleScope scope(isolate); | 7413 HandleScope scope(isolate); |
7414 ASSERT(args.length() == 2); | 7414 DCHECK(args.length() == 2); |
7415 | 7415 |
7416 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7416 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7417 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7417 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7418 return *isolate->factory()->NewNumberFromInt(x ^ y); | 7418 return *isolate->factory()->NewNumberFromInt(x ^ y); |
7419 } | 7419 } |
7420 | 7420 |
7421 | 7421 |
7422 RUNTIME_FUNCTION(Runtime_NumberShl) { | 7422 RUNTIME_FUNCTION(Runtime_NumberShl) { |
7423 HandleScope scope(isolate); | 7423 HandleScope scope(isolate); |
7424 ASSERT(args.length() == 2); | 7424 DCHECK(args.length() == 2); |
7425 | 7425 |
7426 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7426 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7427 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7427 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7428 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f)); | 7428 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f)); |
7429 } | 7429 } |
7430 | 7430 |
7431 | 7431 |
7432 RUNTIME_FUNCTION(Runtime_NumberShr) { | 7432 RUNTIME_FUNCTION(Runtime_NumberShr) { |
7433 HandleScope scope(isolate); | 7433 HandleScope scope(isolate); |
7434 ASSERT(args.length() == 2); | 7434 DCHECK(args.length() == 2); |
7435 | 7435 |
7436 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 7436 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
7437 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7437 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7438 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f)); | 7438 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f)); |
7439 } | 7439 } |
7440 | 7440 |
7441 | 7441 |
7442 RUNTIME_FUNCTION(Runtime_NumberSar) { | 7442 RUNTIME_FUNCTION(Runtime_NumberSar) { |
7443 HandleScope scope(isolate); | 7443 HandleScope scope(isolate); |
7444 ASSERT(args.length() == 2); | 7444 DCHECK(args.length() == 2); |
7445 | 7445 |
7446 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7446 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7447 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7447 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7448 return *isolate->factory()->NewNumberFromInt( | 7448 return *isolate->factory()->NewNumberFromInt( |
7449 ArithmeticShiftRight(x, y & 0x1f)); | 7449 ArithmeticShiftRight(x, y & 0x1f)); |
7450 } | 7450 } |
7451 | 7451 |
7452 | 7452 |
7453 RUNTIME_FUNCTION(Runtime_NumberEquals) { | 7453 RUNTIME_FUNCTION(Runtime_NumberEquals) { |
7454 SealHandleScope shs(isolate); | 7454 SealHandleScope shs(isolate); |
7455 ASSERT(args.length() == 2); | 7455 DCHECK(args.length() == 2); |
7456 | 7456 |
7457 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7457 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7458 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7458 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7459 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); | 7459 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); |
7460 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); | 7460 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); |
7461 if (x == y) return Smi::FromInt(EQUAL); | 7461 if (x == y) return Smi::FromInt(EQUAL); |
7462 Object* result; | 7462 Object* result; |
7463 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | 7463 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { |
7464 result = Smi::FromInt(EQUAL); | 7464 result = Smi::FromInt(EQUAL); |
7465 } else { | 7465 } else { |
7466 result = Smi::FromInt(NOT_EQUAL); | 7466 result = Smi::FromInt(NOT_EQUAL); |
7467 } | 7467 } |
7468 return result; | 7468 return result; |
7469 } | 7469 } |
7470 | 7470 |
7471 | 7471 |
7472 RUNTIME_FUNCTION(Runtime_StringEquals) { | 7472 RUNTIME_FUNCTION(Runtime_StringEquals) { |
7473 HandleScope handle_scope(isolate); | 7473 HandleScope handle_scope(isolate); |
7474 ASSERT(args.length() == 2); | 7474 DCHECK(args.length() == 2); |
7475 | 7475 |
7476 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 7476 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
7477 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 7477 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
7478 | 7478 |
7479 bool not_equal = !String::Equals(x, y); | 7479 bool not_equal = !String::Equals(x, y); |
7480 // This is slightly convoluted because the value that signifies | 7480 // This is slightly convoluted because the value that signifies |
7481 // equality is 0 and inequality is 1 so we have to negate the result | 7481 // equality is 0 and inequality is 1 so we have to negate the result |
7482 // from String::Equals. | 7482 // from String::Equals. |
7483 ASSERT(not_equal == 0 || not_equal == 1); | 7483 DCHECK(not_equal == 0 || not_equal == 1); |
7484 STATIC_ASSERT(EQUAL == 0); | 7484 STATIC_ASSERT(EQUAL == 0); |
7485 STATIC_ASSERT(NOT_EQUAL == 1); | 7485 STATIC_ASSERT(NOT_EQUAL == 1); |
7486 return Smi::FromInt(not_equal); | 7486 return Smi::FromInt(not_equal); |
7487 } | 7487 } |
7488 | 7488 |
7489 | 7489 |
7490 RUNTIME_FUNCTION(Runtime_NumberCompare) { | 7490 RUNTIME_FUNCTION(Runtime_NumberCompare) { |
7491 SealHandleScope shs(isolate); | 7491 SealHandleScope shs(isolate); |
7492 ASSERT(args.length() == 3); | 7492 DCHECK(args.length() == 3); |
7493 | 7493 |
7494 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7494 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7495 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7495 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7496 CONVERT_ARG_HANDLE_CHECKED(Object, uncomparable_result, 2) | 7496 CONVERT_ARG_HANDLE_CHECKED(Object, uncomparable_result, 2) |
7497 if (std::isnan(x) || std::isnan(y)) return *uncomparable_result; | 7497 if (std::isnan(x) || std::isnan(y)) return *uncomparable_result; |
7498 if (x == y) return Smi::FromInt(EQUAL); | 7498 if (x == y) return Smi::FromInt(EQUAL); |
7499 if (isless(x, y)) return Smi::FromInt(LESS); | 7499 if (isless(x, y)) return Smi::FromInt(LESS); |
7500 return Smi::FromInt(GREATER); | 7500 return Smi::FromInt(GREATER); |
7501 } | 7501 } |
7502 | 7502 |
7503 | 7503 |
7504 // Compare two Smis as if they were converted to strings and then | 7504 // Compare two Smis as if they were converted to strings and then |
7505 // compared lexicographically. | 7505 // compared lexicographically. |
7506 RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) { | 7506 RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) { |
7507 SealHandleScope shs(isolate); | 7507 SealHandleScope shs(isolate); |
7508 ASSERT(args.length() == 2); | 7508 DCHECK(args.length() == 2); |
7509 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 7509 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
7510 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 7510 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
7511 | 7511 |
7512 // If the integers are equal so are the string representations. | 7512 // If the integers are equal so are the string representations. |
7513 if (x_value == y_value) return Smi::FromInt(EQUAL); | 7513 if (x_value == y_value) return Smi::FromInt(EQUAL); |
7514 | 7514 |
7515 // If one of the integers is zero the normal integer order is the | 7515 // If one of the integers is zero the normal integer order is the |
7516 // same as the lexicographic order of the string representations. | 7516 // same as the lexicographic order of the string representations. |
7517 if (x_value == 0 || y_value == 0) | 7517 if (x_value == 0 || y_value == 0) |
7518 return Smi::FromInt(x_value < y_value ? LESS : GREATER); | 7518 return Smi::FromInt(x_value < y_value ? LESS : GREATER); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7573 } | 7573 } |
7574 | 7574 |
7575 if (x_scaled < y_scaled) return Smi::FromInt(LESS); | 7575 if (x_scaled < y_scaled) return Smi::FromInt(LESS); |
7576 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); | 7576 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); |
7577 return Smi::FromInt(tie); | 7577 return Smi::FromInt(tie); |
7578 } | 7578 } |
7579 | 7579 |
7580 | 7580 |
7581 RUNTIME_FUNCTION(Runtime_StringCompare) { | 7581 RUNTIME_FUNCTION(Runtime_StringCompare) { |
7582 HandleScope handle_scope(isolate); | 7582 HandleScope handle_scope(isolate); |
7583 ASSERT(args.length() == 2); | 7583 DCHECK(args.length() == 2); |
7584 | 7584 |
7585 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 7585 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
7586 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 7586 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
7587 | 7587 |
7588 isolate->counters()->string_compare_runtime()->Increment(); | 7588 isolate->counters()->string_compare_runtime()->Increment(); |
7589 | 7589 |
7590 // A few fast case tests before we flatten. | 7590 // A few fast case tests before we flatten. |
7591 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); | 7591 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); |
7592 if (y->length() == 0) { | 7592 if (y->length() == 0) { |
7593 if (x->length() == 0) return Smi::FromInt(EQUAL); | 7593 if (x->length() == 0) return Smi::FromInt(EQUAL); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7641 } else { | 7641 } else { |
7642 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 7642 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
7643 } | 7643 } |
7644 return result; | 7644 return result; |
7645 } | 7645 } |
7646 | 7646 |
7647 | 7647 |
7648 #define RUNTIME_UNARY_MATH(Name, name) \ | 7648 #define RUNTIME_UNARY_MATH(Name, name) \ |
7649 RUNTIME_FUNCTION(Runtime_Math##Name) { \ | 7649 RUNTIME_FUNCTION(Runtime_Math##Name) { \ |
7650 HandleScope scope(isolate); \ | 7650 HandleScope scope(isolate); \ |
7651 ASSERT(args.length() == 1); \ | 7651 DCHECK(args.length() == 1); \ |
7652 isolate->counters()->math_##name()->Increment(); \ | 7652 isolate->counters()->math_##name()->Increment(); \ |
7653 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ | 7653 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ |
7654 return *isolate->factory()->NewHeapNumber(std::name(x)); \ | 7654 return *isolate->factory()->NewHeapNumber(std::name(x)); \ |
7655 } | 7655 } |
7656 | 7656 |
7657 RUNTIME_UNARY_MATH(Acos, acos) | 7657 RUNTIME_UNARY_MATH(Acos, acos) |
7658 RUNTIME_UNARY_MATH(Asin, asin) | 7658 RUNTIME_UNARY_MATH(Asin, asin) |
7659 RUNTIME_UNARY_MATH(Atan, atan) | 7659 RUNTIME_UNARY_MATH(Atan, atan) |
7660 RUNTIME_UNARY_MATH(LogRT, log) | 7660 RUNTIME_UNARY_MATH(LogRT, log) |
7661 #undef RUNTIME_UNARY_MATH | 7661 #undef RUNTIME_UNARY_MATH |
7662 | 7662 |
7663 | 7663 |
7664 RUNTIME_FUNCTION(Runtime_DoubleHi) { | 7664 RUNTIME_FUNCTION(Runtime_DoubleHi) { |
7665 HandleScope scope(isolate); | 7665 HandleScope scope(isolate); |
7666 ASSERT(args.length() == 1); | 7666 DCHECK(args.length() == 1); |
7667 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7667 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7668 uint64_t integer = double_to_uint64(x); | 7668 uint64_t integer = double_to_uint64(x); |
7669 integer = (integer >> 32) & 0xFFFFFFFFu; | 7669 integer = (integer >> 32) & 0xFFFFFFFFu; |
7670 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); | 7670 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); |
7671 } | 7671 } |
7672 | 7672 |
7673 | 7673 |
7674 RUNTIME_FUNCTION(Runtime_DoubleLo) { | 7674 RUNTIME_FUNCTION(Runtime_DoubleLo) { |
7675 HandleScope scope(isolate); | 7675 HandleScope scope(isolate); |
7676 ASSERT(args.length() == 1); | 7676 DCHECK(args.length() == 1); |
7677 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7677 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7678 return *isolate->factory()->NewNumber( | 7678 return *isolate->factory()->NewNumber( |
7679 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); | 7679 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); |
7680 } | 7680 } |
7681 | 7681 |
7682 | 7682 |
7683 RUNTIME_FUNCTION(Runtime_ConstructDouble) { | 7683 RUNTIME_FUNCTION(Runtime_ConstructDouble) { |
7684 HandleScope scope(isolate); | 7684 HandleScope scope(isolate); |
7685 ASSERT(args.length() == 2); | 7685 DCHECK(args.length() == 2); |
7686 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 7686 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
7687 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 7687 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
7688 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; | 7688 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; |
7689 return *isolate->factory()->NewNumber(uint64_to_double(result)); | 7689 return *isolate->factory()->NewNumber(uint64_to_double(result)); |
7690 } | 7690 } |
7691 | 7691 |
7692 | 7692 |
7693 static const double kPiDividedBy4 = 0.78539816339744830962; | 7693 static const double kPiDividedBy4 = 0.78539816339744830962; |
7694 | 7694 |
7695 | 7695 |
7696 RUNTIME_FUNCTION(Runtime_MathAtan2) { | 7696 RUNTIME_FUNCTION(Runtime_MathAtan2) { |
7697 HandleScope scope(isolate); | 7697 HandleScope scope(isolate); |
7698 ASSERT(args.length() == 2); | 7698 DCHECK(args.length() == 2); |
7699 isolate->counters()->math_atan2()->Increment(); | 7699 isolate->counters()->math_atan2()->Increment(); |
7700 | 7700 |
7701 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7701 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7702 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7702 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7703 double result; | 7703 double result; |
7704 if (std::isinf(x) && std::isinf(y)) { | 7704 if (std::isinf(x) && std::isinf(y)) { |
7705 // Make sure that the result in case of two infinite arguments | 7705 // Make sure that the result in case of two infinite arguments |
7706 // is a multiple of Pi / 4. The sign of the result is determined | 7706 // is a multiple of Pi / 4. The sign of the result is determined |
7707 // by the first argument (x) and the sign of the second argument | 7707 // by the first argument (x) and the sign of the second argument |
7708 // determines the multiplier: one or three. | 7708 // determines the multiplier: one or three. |
7709 int multiplier = (x < 0) ? -1 : 1; | 7709 int multiplier = (x < 0) ? -1 : 1; |
7710 if (y < 0) multiplier *= 3; | 7710 if (y < 0) multiplier *= 3; |
7711 result = multiplier * kPiDividedBy4; | 7711 result = multiplier * kPiDividedBy4; |
7712 } else { | 7712 } else { |
7713 result = std::atan2(x, y); | 7713 result = std::atan2(x, y); |
7714 } | 7714 } |
7715 return *isolate->factory()->NewNumber(result); | 7715 return *isolate->factory()->NewNumber(result); |
7716 } | 7716 } |
7717 | 7717 |
7718 | 7718 |
7719 RUNTIME_FUNCTION(Runtime_MathExpRT) { | 7719 RUNTIME_FUNCTION(Runtime_MathExpRT) { |
7720 HandleScope scope(isolate); | 7720 HandleScope scope(isolate); |
7721 ASSERT(args.length() == 1); | 7721 DCHECK(args.length() == 1); |
7722 isolate->counters()->math_exp()->Increment(); | 7722 isolate->counters()->math_exp()->Increment(); |
7723 | 7723 |
7724 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7724 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7725 lazily_initialize_fast_exp(); | 7725 lazily_initialize_fast_exp(); |
7726 return *isolate->factory()->NewNumber(fast_exp(x)); | 7726 return *isolate->factory()->NewNumber(fast_exp(x)); |
7727 } | 7727 } |
7728 | 7728 |
7729 | 7729 |
7730 RUNTIME_FUNCTION(Runtime_MathFloorRT) { | 7730 RUNTIME_FUNCTION(Runtime_MathFloorRT) { |
7731 HandleScope scope(isolate); | 7731 HandleScope scope(isolate); |
7732 ASSERT(args.length() == 1); | 7732 DCHECK(args.length() == 1); |
7733 isolate->counters()->math_floor()->Increment(); | 7733 isolate->counters()->math_floor()->Increment(); |
7734 | 7734 |
7735 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7735 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7736 return *isolate->factory()->NewNumber(Floor(x)); | 7736 return *isolate->factory()->NewNumber(Floor(x)); |
7737 } | 7737 } |
7738 | 7738 |
7739 | 7739 |
7740 // Slow version of Math.pow. We check for fast paths for special cases. | 7740 // Slow version of Math.pow. We check for fast paths for special cases. |
7741 // Used if VFP3 is not available. | 7741 // Used if VFP3 is not available. |
7742 RUNTIME_FUNCTION(Runtime_MathPowSlow) { | 7742 RUNTIME_FUNCTION(Runtime_MathPowSlow) { |
7743 HandleScope scope(isolate); | 7743 HandleScope scope(isolate); |
7744 ASSERT(args.length() == 2); | 7744 DCHECK(args.length() == 2); |
7745 isolate->counters()->math_pow()->Increment(); | 7745 isolate->counters()->math_pow()->Increment(); |
7746 | 7746 |
7747 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7747 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7748 | 7748 |
7749 // If the second argument is a smi, it is much faster to call the | 7749 // If the second argument is a smi, it is much faster to call the |
7750 // custom powi() function than the generic pow(). | 7750 // custom powi() function than the generic pow(). |
7751 if (args[1]->IsSmi()) { | 7751 if (args[1]->IsSmi()) { |
7752 int y = args.smi_at(1); | 7752 int y = args.smi_at(1); |
7753 return *isolate->factory()->NewNumber(power_double_int(x, y)); | 7753 return *isolate->factory()->NewNumber(power_double_int(x, y)); |
7754 } | 7754 } |
7755 | 7755 |
7756 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7756 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7757 double result = power_helper(x, y); | 7757 double result = power_helper(x, y); |
7758 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7758 if (std::isnan(result)) return isolate->heap()->nan_value(); |
7759 return *isolate->factory()->NewNumber(result); | 7759 return *isolate->factory()->NewNumber(result); |
7760 } | 7760 } |
7761 | 7761 |
7762 | 7762 |
7763 // Fast version of Math.pow if we know that y is not an integer and y is not | 7763 // Fast version of Math.pow if we know that y is not an integer and y is not |
7764 // -0.5 or 0.5. Used as slow case from full codegen. | 7764 // -0.5 or 0.5. Used as slow case from full codegen. |
7765 RUNTIME_FUNCTION(Runtime_MathPowRT) { | 7765 RUNTIME_FUNCTION(Runtime_MathPowRT) { |
7766 HandleScope scope(isolate); | 7766 HandleScope scope(isolate); |
7767 ASSERT(args.length() == 2); | 7767 DCHECK(args.length() == 2); |
7768 isolate->counters()->math_pow()->Increment(); | 7768 isolate->counters()->math_pow()->Increment(); |
7769 | 7769 |
7770 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7770 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7771 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7771 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7772 if (y == 0) { | 7772 if (y == 0) { |
7773 return Smi::FromInt(1); | 7773 return Smi::FromInt(1); |
7774 } else { | 7774 } else { |
7775 double result = power_double_double(x, y); | 7775 double result = power_double_double(x, y); |
7776 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7776 if (std::isnan(result)) return isolate->heap()->nan_value(); |
7777 return *isolate->factory()->NewNumber(result); | 7777 return *isolate->factory()->NewNumber(result); |
7778 } | 7778 } |
7779 } | 7779 } |
7780 | 7780 |
7781 | 7781 |
7782 RUNTIME_FUNCTION(Runtime_RoundNumber) { | 7782 RUNTIME_FUNCTION(Runtime_RoundNumber) { |
7783 HandleScope scope(isolate); | 7783 HandleScope scope(isolate); |
7784 ASSERT(args.length() == 1); | 7784 DCHECK(args.length() == 1); |
7785 CONVERT_NUMBER_ARG_HANDLE_CHECKED(input, 0); | 7785 CONVERT_NUMBER_ARG_HANDLE_CHECKED(input, 0); |
7786 isolate->counters()->math_round()->Increment(); | 7786 isolate->counters()->math_round()->Increment(); |
7787 | 7787 |
7788 if (!input->IsHeapNumber()) { | 7788 if (!input->IsHeapNumber()) { |
7789 ASSERT(input->IsSmi()); | 7789 DCHECK(input->IsSmi()); |
7790 return *input; | 7790 return *input; |
7791 } | 7791 } |
7792 | 7792 |
7793 Handle<HeapNumber> number = Handle<HeapNumber>::cast(input); | 7793 Handle<HeapNumber> number = Handle<HeapNumber>::cast(input); |
7794 | 7794 |
7795 double value = number->value(); | 7795 double value = number->value(); |
7796 int exponent = number->get_exponent(); | 7796 int exponent = number->get_exponent(); |
7797 int sign = number->get_sign(); | 7797 int sign = number->get_sign(); |
7798 | 7798 |
7799 if (exponent < -1) { | 7799 if (exponent < -1) { |
(...skipping 17 matching lines...) Expand all Loading... |
7817 | 7817 |
7818 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7818 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
7819 | 7819 |
7820 // Do not call NumberFromDouble() to avoid extra checks. | 7820 // Do not call NumberFromDouble() to avoid extra checks. |
7821 return *isolate->factory()->NewNumber(Floor(value + 0.5)); | 7821 return *isolate->factory()->NewNumber(Floor(value + 0.5)); |
7822 } | 7822 } |
7823 | 7823 |
7824 | 7824 |
7825 RUNTIME_FUNCTION(Runtime_MathSqrtRT) { | 7825 RUNTIME_FUNCTION(Runtime_MathSqrtRT) { |
7826 HandleScope scope(isolate); | 7826 HandleScope scope(isolate); |
7827 ASSERT(args.length() == 1); | 7827 DCHECK(args.length() == 1); |
7828 isolate->counters()->math_sqrt()->Increment(); | 7828 isolate->counters()->math_sqrt()->Increment(); |
7829 | 7829 |
7830 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7830 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7831 return *isolate->factory()->NewNumber(fast_sqrt(x)); | 7831 return *isolate->factory()->NewNumber(fast_sqrt(x)); |
7832 } | 7832 } |
7833 | 7833 |
7834 | 7834 |
7835 RUNTIME_FUNCTION(Runtime_MathFround) { | 7835 RUNTIME_FUNCTION(Runtime_MathFround) { |
7836 HandleScope scope(isolate); | 7836 HandleScope scope(isolate); |
7837 ASSERT(args.length() == 1); | 7837 DCHECK(args.length() == 1); |
7838 | 7838 |
7839 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7839 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7840 float xf = static_cast<float>(x); | 7840 float xf = static_cast<float>(x); |
7841 return *isolate->factory()->NewNumber(xf); | 7841 return *isolate->factory()->NewNumber(xf); |
7842 } | 7842 } |
7843 | 7843 |
7844 | 7844 |
7845 RUNTIME_FUNCTION(Runtime_DateMakeDay) { | 7845 RUNTIME_FUNCTION(Runtime_DateMakeDay) { |
7846 SealHandleScope shs(isolate); | 7846 SealHandleScope shs(isolate); |
7847 ASSERT(args.length() == 2); | 7847 DCHECK(args.length() == 2); |
7848 | 7848 |
7849 CONVERT_SMI_ARG_CHECKED(year, 0); | 7849 CONVERT_SMI_ARG_CHECKED(year, 0); |
7850 CONVERT_SMI_ARG_CHECKED(month, 1); | 7850 CONVERT_SMI_ARG_CHECKED(month, 1); |
7851 | 7851 |
7852 int days = isolate->date_cache()->DaysFromYearMonth(year, month); | 7852 int days = isolate->date_cache()->DaysFromYearMonth(year, month); |
7853 RUNTIME_ASSERT(Smi::IsValid(days)); | 7853 RUNTIME_ASSERT(Smi::IsValid(days)); |
7854 return Smi::FromInt(days); | 7854 return Smi::FromInt(days); |
7855 } | 7855 } |
7856 | 7856 |
7857 | 7857 |
7858 RUNTIME_FUNCTION(Runtime_DateSetValue) { | 7858 RUNTIME_FUNCTION(Runtime_DateSetValue) { |
7859 HandleScope scope(isolate); | 7859 HandleScope scope(isolate); |
7860 ASSERT(args.length() == 3); | 7860 DCHECK(args.length() == 3); |
7861 | 7861 |
7862 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); | 7862 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); |
7863 CONVERT_DOUBLE_ARG_CHECKED(time, 1); | 7863 CONVERT_DOUBLE_ARG_CHECKED(time, 1); |
7864 CONVERT_SMI_ARG_CHECKED(is_utc, 2); | 7864 CONVERT_SMI_ARG_CHECKED(is_utc, 2); |
7865 | 7865 |
7866 DateCache* date_cache = isolate->date_cache(); | 7866 DateCache* date_cache = isolate->date_cache(); |
7867 | 7867 |
7868 Handle<Object> value;; | 7868 Handle<Object> value;; |
7869 bool is_value_nan = false; | 7869 bool is_value_nan = false; |
7870 if (std::isnan(time)) { | 7870 if (std::isnan(time)) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7951 } else { | 7951 } else { |
7952 // The context index goes in the parameter map with a hole in the | 7952 // The context index goes in the parameter map with a hole in the |
7953 // arguments array. | 7953 // arguments array. |
7954 int context_index = -1; | 7954 int context_index = -1; |
7955 for (int j = 0; j < context_local_count; ++j) { | 7955 for (int j = 0; j < context_local_count; ++j) { |
7956 if (scope_info->ContextLocalName(j) == *name) { | 7956 if (scope_info->ContextLocalName(j) == *name) { |
7957 context_index = j; | 7957 context_index = j; |
7958 break; | 7958 break; |
7959 } | 7959 } |
7960 } | 7960 } |
7961 ASSERT(context_index >= 0); | 7961 DCHECK(context_index >= 0); |
7962 arguments->set_the_hole(index); | 7962 arguments->set_the_hole(index); |
7963 parameter_map->set(index + 2, Smi::FromInt( | 7963 parameter_map->set(index + 2, Smi::FromInt( |
7964 Context::MIN_CONTEXT_SLOTS + context_index)); | 7964 Context::MIN_CONTEXT_SLOTS + context_index)); |
7965 } | 7965 } |
7966 | 7966 |
7967 --index; | 7967 --index; |
7968 } | 7968 } |
7969 } else { | 7969 } else { |
7970 // If there is no aliasing, the arguments object elements are not | 7970 // If there is no aliasing, the arguments object elements are not |
7971 // special in any way. | 7971 // special in any way. |
(...skipping 25 matching lines...) Expand all Loading... |
7997 array->set(i, *--parameters, mode); | 7997 array->set(i, *--parameters, mode); |
7998 } | 7998 } |
7999 result->set_elements(*array); | 7999 result->set_elements(*array); |
8000 } | 8000 } |
8001 return result; | 8001 return result; |
8002 } | 8002 } |
8003 | 8003 |
8004 | 8004 |
8005 RUNTIME_FUNCTION(Runtime_NewArguments) { | 8005 RUNTIME_FUNCTION(Runtime_NewArguments) { |
8006 HandleScope scope(isolate); | 8006 HandleScope scope(isolate); |
8007 ASSERT(args.length() == 1); | 8007 DCHECK(args.length() == 1); |
8008 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); | 8008 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
8009 JavaScriptFrameIterator it(isolate); | 8009 JavaScriptFrameIterator it(isolate); |
8010 | 8010 |
8011 // Find the frame that holds the actual arguments passed to the function. | 8011 // Find the frame that holds the actual arguments passed to the function. |
8012 it.AdvanceToArgumentsFrame(); | 8012 it.AdvanceToArgumentsFrame(); |
8013 JavaScriptFrame* frame = it.frame(); | 8013 JavaScriptFrame* frame = it.frame(); |
8014 | 8014 |
8015 // Determine parameter location on the stack and dispatch on language mode. | 8015 // Determine parameter location on the stack and dispatch on language mode. |
8016 int argument_count = frame->GetArgumentsLength(); | 8016 int argument_count = frame->GetArgumentsLength(); |
8017 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); | 8017 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); |
8018 return callee->shared()->strict_mode() == STRICT | 8018 return callee->shared()->strict_mode() == STRICT |
8019 ? *NewStrictArguments(isolate, callee, parameters, argument_count) | 8019 ? *NewStrictArguments(isolate, callee, parameters, argument_count) |
8020 : *NewSloppyArguments(isolate, callee, parameters, argument_count); | 8020 : *NewSloppyArguments(isolate, callee, parameters, argument_count); |
8021 } | 8021 } |
8022 | 8022 |
8023 | 8023 |
8024 RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { | 8024 RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { |
8025 HandleScope scope(isolate); | 8025 HandleScope scope(isolate); |
8026 ASSERT(args.length() == 3); | 8026 DCHECK(args.length() == 3); |
8027 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); | 8027 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
8028 Object** parameters = reinterpret_cast<Object**>(args[1]); | 8028 Object** parameters = reinterpret_cast<Object**>(args[1]); |
8029 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 8029 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
8030 return *NewSloppyArguments(isolate, callee, parameters, argument_count); | 8030 return *NewSloppyArguments(isolate, callee, parameters, argument_count); |
8031 } | 8031 } |
8032 | 8032 |
8033 | 8033 |
8034 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { | 8034 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { |
8035 HandleScope scope(isolate); | 8035 HandleScope scope(isolate); |
8036 ASSERT(args.length() == 3); | 8036 DCHECK(args.length() == 3); |
8037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 8037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
8038 Object** parameters = reinterpret_cast<Object**>(args[1]); | 8038 Object** parameters = reinterpret_cast<Object**>(args[1]); |
8039 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 8039 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
8040 return *NewStrictArguments(isolate, callee, parameters, argument_count); | 8040 return *NewStrictArguments(isolate, callee, parameters, argument_count); |
8041 } | 8041 } |
8042 | 8042 |
8043 | 8043 |
8044 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { | 8044 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { |
8045 HandleScope scope(isolate); | 8045 HandleScope scope(isolate); |
8046 ASSERT(args.length() == 1); | 8046 DCHECK(args.length() == 1); |
8047 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 8047 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
8048 Handle<Context> context(isolate->context()); | 8048 Handle<Context> context(isolate->context()); |
8049 PretenureFlag pretenure_flag = NOT_TENURED; | 8049 PretenureFlag pretenure_flag = NOT_TENURED; |
8050 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8050 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
8051 shared, context, pretenure_flag); | 8051 shared, context, pretenure_flag); |
8052 } | 8052 } |
8053 | 8053 |
8054 | 8054 |
8055 RUNTIME_FUNCTION(Runtime_NewClosure) { | 8055 RUNTIME_FUNCTION(Runtime_NewClosure) { |
8056 HandleScope scope(isolate); | 8056 HandleScope scope(isolate); |
8057 ASSERT(args.length() == 3); | 8057 DCHECK(args.length() == 3); |
8058 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 8058 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
8059 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); | 8059 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); |
8060 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); | 8060 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); |
8061 | 8061 |
8062 // The caller ensures that we pretenure closures that are assigned | 8062 // The caller ensures that we pretenure closures that are assigned |
8063 // directly to properties. | 8063 // directly to properties. |
8064 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 8064 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
8065 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8065 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
8066 shared, context, pretenure_flag); | 8066 shared, context, pretenure_flag); |
8067 } | 8067 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8112 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); | 8112 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); |
8113 param_data[prefix_argc + i] = val; | 8113 param_data[prefix_argc + i] = val; |
8114 } | 8114 } |
8115 return param_data; | 8115 return param_data; |
8116 } | 8116 } |
8117 } | 8117 } |
8118 | 8118 |
8119 | 8119 |
8120 RUNTIME_FUNCTION(Runtime_FunctionBindArguments) { | 8120 RUNTIME_FUNCTION(Runtime_FunctionBindArguments) { |
8121 HandleScope scope(isolate); | 8121 HandleScope scope(isolate); |
8122 ASSERT(args.length() == 4); | 8122 DCHECK(args.length() == 4); |
8123 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0); | 8123 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0); |
8124 CONVERT_ARG_HANDLE_CHECKED(Object, bindee, 1); | 8124 CONVERT_ARG_HANDLE_CHECKED(Object, bindee, 1); |
8125 CONVERT_ARG_HANDLE_CHECKED(Object, this_object, 2); | 8125 CONVERT_ARG_HANDLE_CHECKED(Object, this_object, 2); |
8126 CONVERT_NUMBER_ARG_HANDLE_CHECKED(new_length, 3); | 8126 CONVERT_NUMBER_ARG_HANDLE_CHECKED(new_length, 3); |
8127 | 8127 |
8128 // TODO(lrn): Create bound function in C++ code from premade shared info. | 8128 // TODO(lrn): Create bound function in C++ code from premade shared info. |
8129 bound_function->shared()->set_bound(true); | 8129 bound_function->shared()->set_bound(true); |
8130 // Get all arguments of calling function (Function.prototype.bind). | 8130 // Get all arguments of calling function (Function.prototype.bind). |
8131 int argc = 0; | 8131 int argc = 0; |
8132 SmartArrayPointer<Handle<Object> > arguments = | 8132 SmartArrayPointer<Handle<Object> > arguments = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8181 RETURN_FAILURE_ON_EXCEPTION( | 8181 RETURN_FAILURE_ON_EXCEPTION( |
8182 isolate, | 8182 isolate, |
8183 JSObject::SetOwnPropertyIgnoreAttributes( | 8183 JSObject::SetOwnPropertyIgnoreAttributes( |
8184 bound_function, length_string, new_length, attr)); | 8184 bound_function, length_string, new_length, attr)); |
8185 return *bound_function; | 8185 return *bound_function; |
8186 } | 8186 } |
8187 | 8187 |
8188 | 8188 |
8189 RUNTIME_FUNCTION(Runtime_BoundFunctionGetBindings) { | 8189 RUNTIME_FUNCTION(Runtime_BoundFunctionGetBindings) { |
8190 HandleScope handles(isolate); | 8190 HandleScope handles(isolate); |
8191 ASSERT(args.length() == 1); | 8191 DCHECK(args.length() == 1); |
8192 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); | 8192 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); |
8193 if (callable->IsJSFunction()) { | 8193 if (callable->IsJSFunction()) { |
8194 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); | 8194 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); |
8195 if (function->shared()->bound()) { | 8195 if (function->shared()->bound()) { |
8196 Handle<FixedArray> bindings(function->function_bindings()); | 8196 Handle<FixedArray> bindings(function->function_bindings()); |
8197 RUNTIME_ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map()); | 8197 RUNTIME_ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map()); |
8198 return *isolate->factory()->NewJSArrayWithElements(bindings); | 8198 return *isolate->factory()->NewJSArrayWithElements(bindings); |
8199 } | 8199 } |
8200 } | 8200 } |
8201 return isolate->heap()->undefined_value(); | 8201 return isolate->heap()->undefined_value(); |
8202 } | 8202 } |
8203 | 8203 |
8204 | 8204 |
8205 RUNTIME_FUNCTION(Runtime_NewObjectFromBound) { | 8205 RUNTIME_FUNCTION(Runtime_NewObjectFromBound) { |
8206 HandleScope scope(isolate); | 8206 HandleScope scope(isolate); |
8207 ASSERT(args.length() == 1); | 8207 DCHECK(args.length() == 1); |
8208 // First argument is a function to use as a constructor. | 8208 // First argument is a function to use as a constructor. |
8209 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8209 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8210 RUNTIME_ASSERT(function->shared()->bound()); | 8210 RUNTIME_ASSERT(function->shared()->bound()); |
8211 | 8211 |
8212 // The argument is a bound function. Extract its bound arguments | 8212 // The argument is a bound function. Extract its bound arguments |
8213 // and callable. | 8213 // and callable. |
8214 Handle<FixedArray> bound_args = | 8214 Handle<FixedArray> bound_args = |
8215 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); | 8215 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); |
8216 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; | 8216 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; |
8217 Handle<Object> bound_function( | 8217 Handle<Object> bound_function( |
8218 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex)), | 8218 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex)), |
8219 isolate); | 8219 isolate); |
8220 ASSERT(!bound_function->IsJSFunction() || | 8220 DCHECK(!bound_function->IsJSFunction() || |
8221 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); | 8221 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); |
8222 | 8222 |
8223 int total_argc = 0; | 8223 int total_argc = 0; |
8224 SmartArrayPointer<Handle<Object> > param_data = | 8224 SmartArrayPointer<Handle<Object> > param_data = |
8225 GetCallerArguments(isolate, bound_argc, &total_argc); | 8225 GetCallerArguments(isolate, bound_argc, &total_argc); |
8226 for (int i = 0; i < bound_argc; i++) { | 8226 for (int i = 0; i < bound_argc; i++) { |
8227 param_data[i] = Handle<Object>(bound_args->get( | 8227 param_data[i] = Handle<Object>(bound_args->get( |
8228 JSFunction::kBoundArgumentsStartIndex + i), isolate); | 8228 JSFunction::kBoundArgumentsStartIndex + i), isolate); |
8229 } | 8229 } |
8230 | 8230 |
8231 if (!bound_function->IsJSFunction()) { | 8231 if (!bound_function->IsJSFunction()) { |
8232 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8232 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
8233 isolate, bound_function, | 8233 isolate, bound_function, |
8234 Execution::TryGetConstructorDelegate(isolate, bound_function)); | 8234 Execution::TryGetConstructorDelegate(isolate, bound_function)); |
8235 } | 8235 } |
8236 ASSERT(bound_function->IsJSFunction()); | 8236 DCHECK(bound_function->IsJSFunction()); |
8237 | 8237 |
8238 Handle<Object> result; | 8238 Handle<Object> result; |
8239 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8239 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
8240 isolate, result, | 8240 isolate, result, |
8241 Execution::New(Handle<JSFunction>::cast(bound_function), | 8241 Execution::New(Handle<JSFunction>::cast(bound_function), |
8242 total_argc, param_data.get())); | 8242 total_argc, param_data.get())); |
8243 return *result; | 8243 return *result; |
8244 } | 8244 } |
8245 | 8245 |
8246 | 8246 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8302 | 8302 |
8303 isolate->counters()->constructed_objects()->Increment(); | 8303 isolate->counters()->constructed_objects()->Increment(); |
8304 isolate->counters()->constructed_objects_runtime()->Increment(); | 8304 isolate->counters()->constructed_objects_runtime()->Increment(); |
8305 | 8305 |
8306 return *result; | 8306 return *result; |
8307 } | 8307 } |
8308 | 8308 |
8309 | 8309 |
8310 RUNTIME_FUNCTION(Runtime_NewObject) { | 8310 RUNTIME_FUNCTION(Runtime_NewObject) { |
8311 HandleScope scope(isolate); | 8311 HandleScope scope(isolate); |
8312 ASSERT(args.length() == 1); | 8312 DCHECK(args.length() == 1); |
8313 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); | 8313 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); |
8314 return Runtime_NewObjectHelper(isolate, | 8314 return Runtime_NewObjectHelper(isolate, |
8315 constructor, | 8315 constructor, |
8316 Handle<AllocationSite>::null()); | 8316 Handle<AllocationSite>::null()); |
8317 } | 8317 } |
8318 | 8318 |
8319 | 8319 |
8320 RUNTIME_FUNCTION(Runtime_NewObjectWithAllocationSite) { | 8320 RUNTIME_FUNCTION(Runtime_NewObjectWithAllocationSite) { |
8321 HandleScope scope(isolate); | 8321 HandleScope scope(isolate); |
8322 ASSERT(args.length() == 2); | 8322 DCHECK(args.length() == 2); |
8323 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); | 8323 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); |
8324 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); | 8324 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); |
8325 Handle<AllocationSite> site; | 8325 Handle<AllocationSite> site; |
8326 if (feedback->IsAllocationSite()) { | 8326 if (feedback->IsAllocationSite()) { |
8327 // The feedback can be an AllocationSite or undefined. | 8327 // The feedback can be an AllocationSite or undefined. |
8328 site = Handle<AllocationSite>::cast(feedback); | 8328 site = Handle<AllocationSite>::cast(feedback); |
8329 } | 8329 } |
8330 return Runtime_NewObjectHelper(isolate, constructor, site); | 8330 return Runtime_NewObjectHelper(isolate, constructor, site); |
8331 } | 8331 } |
8332 | 8332 |
8333 | 8333 |
8334 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { | 8334 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { |
8335 HandleScope scope(isolate); | 8335 HandleScope scope(isolate); |
8336 ASSERT(args.length() == 1); | 8336 DCHECK(args.length() == 1); |
8337 | 8337 |
8338 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8338 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8339 function->CompleteInobjectSlackTracking(); | 8339 function->CompleteInobjectSlackTracking(); |
8340 | 8340 |
8341 return isolate->heap()->undefined_value(); | 8341 return isolate->heap()->undefined_value(); |
8342 } | 8342 } |
8343 | 8343 |
8344 | 8344 |
8345 RUNTIME_FUNCTION(Runtime_CompileUnoptimized) { | 8345 RUNTIME_FUNCTION(Runtime_CompileUnoptimized) { |
8346 HandleScope scope(isolate); | 8346 HandleScope scope(isolate); |
8347 ASSERT(args.length() == 1); | 8347 DCHECK(args.length() == 1); |
8348 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8348 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8349 #ifdef DEBUG | 8349 #ifdef DEBUG |
8350 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 8350 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
8351 PrintF("[unoptimized: "); | 8351 PrintF("[unoptimized: "); |
8352 function->PrintName(); | 8352 function->PrintName(); |
8353 PrintF("]\n"); | 8353 PrintF("]\n"); |
8354 } | 8354 } |
8355 #endif | 8355 #endif |
8356 | 8356 |
8357 // Compile the target function. | 8357 // Compile the target function. |
8358 ASSERT(function->shared()->allows_lazy_compilation()); | 8358 DCHECK(function->shared()->allows_lazy_compilation()); |
8359 | 8359 |
8360 Handle<Code> code; | 8360 Handle<Code> code; |
8361 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, | 8361 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, code, |
8362 Compiler::GetUnoptimizedCode(function)); | 8362 Compiler::GetUnoptimizedCode(function)); |
8363 function->ReplaceCode(*code); | 8363 function->ReplaceCode(*code); |
8364 | 8364 |
8365 // All done. Return the compiled code. | 8365 // All done. Return the compiled code. |
8366 ASSERT(function->is_compiled()); | 8366 DCHECK(function->is_compiled()); |
8367 ASSERT(function->code()->kind() == Code::FUNCTION || | 8367 DCHECK(function->code()->kind() == Code::FUNCTION || |
8368 (FLAG_always_opt && | 8368 (FLAG_always_opt && |
8369 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); | 8369 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); |
8370 return *code; | 8370 return *code; |
8371 } | 8371 } |
8372 | 8372 |
8373 | 8373 |
8374 RUNTIME_FUNCTION(Runtime_CompileOptimized) { | 8374 RUNTIME_FUNCTION(Runtime_CompileOptimized) { |
8375 HandleScope scope(isolate); | 8375 HandleScope scope(isolate); |
8376 ASSERT(args.length() == 2); | 8376 DCHECK(args.length() == 2); |
8377 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8377 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8378 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); | 8378 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); |
8379 | 8379 |
8380 Handle<Code> unoptimized(function->shared()->code()); | 8380 Handle<Code> unoptimized(function->shared()->code()); |
8381 if (!function->shared()->is_compiled()) { | 8381 if (!function->shared()->is_compiled()) { |
8382 // If the function is not compiled, do not optimize. | 8382 // If the function is not compiled, do not optimize. |
8383 // This can happen if the debugger is activated and | 8383 // This can happen if the debugger is activated and |
8384 // the function is returned to the not compiled state. | 8384 // the function is returned to the not compiled state. |
8385 // TODO(yangguo): reconsider this. | 8385 // TODO(yangguo): reconsider this. |
8386 function->ReplaceCode(function->shared()->code()); | 8386 function->ReplaceCode(function->shared()->code()); |
(...skipping 15 matching lines...) Expand all Loading... |
8402 : Compiler::NOT_CONCURRENT; | 8402 : Compiler::NOT_CONCURRENT; |
8403 Handle<Code> code; | 8403 Handle<Code> code; |
8404 if (Compiler::GetOptimizedCode( | 8404 if (Compiler::GetOptimizedCode( |
8405 function, unoptimized, mode).ToHandle(&code)) { | 8405 function, unoptimized, mode).ToHandle(&code)) { |
8406 function->ReplaceCode(*code); | 8406 function->ReplaceCode(*code); |
8407 } else { | 8407 } else { |
8408 function->ReplaceCode(*unoptimized); | 8408 function->ReplaceCode(*unoptimized); |
8409 } | 8409 } |
8410 } | 8410 } |
8411 | 8411 |
8412 ASSERT(function->code()->kind() == Code::FUNCTION || | 8412 DCHECK(function->code()->kind() == Code::FUNCTION || |
8413 function->code()->kind() == Code::OPTIMIZED_FUNCTION || | 8413 function->code()->kind() == Code::OPTIMIZED_FUNCTION || |
8414 function->IsInOptimizationQueue()); | 8414 function->IsInOptimizationQueue()); |
8415 return function->code(); | 8415 return function->code(); |
8416 } | 8416 } |
8417 | 8417 |
8418 | 8418 |
8419 class ActivationsFinder : public ThreadVisitor { | 8419 class ActivationsFinder : public ThreadVisitor { |
8420 public: | 8420 public: |
8421 Code* code_; | 8421 Code* code_; |
8422 bool has_code_activations_; | 8422 bool has_code_activations_; |
(...skipping 11 matching lines...) Expand all Loading... |
8434 for (; !it->done(); it->Advance()) { | 8434 for (; !it->done(); it->Advance()) { |
8435 JavaScriptFrame* frame = it->frame(); | 8435 JavaScriptFrame* frame = it->frame(); |
8436 if (code_->contains(frame->pc())) has_code_activations_ = true; | 8436 if (code_->contains(frame->pc())) has_code_activations_ = true; |
8437 } | 8437 } |
8438 } | 8438 } |
8439 }; | 8439 }; |
8440 | 8440 |
8441 | 8441 |
8442 RUNTIME_FUNCTION(Runtime_NotifyStubFailure) { | 8442 RUNTIME_FUNCTION(Runtime_NotifyStubFailure) { |
8443 HandleScope scope(isolate); | 8443 HandleScope scope(isolate); |
8444 ASSERT(args.length() == 0); | 8444 DCHECK(args.length() == 0); |
8445 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8445 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
8446 ASSERT(AllowHeapAllocation::IsAllowed()); | 8446 DCHECK(AllowHeapAllocation::IsAllowed()); |
8447 delete deoptimizer; | 8447 delete deoptimizer; |
8448 return isolate->heap()->undefined_value(); | 8448 return isolate->heap()->undefined_value(); |
8449 } | 8449 } |
8450 | 8450 |
8451 | 8451 |
8452 RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { | 8452 RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { |
8453 HandleScope scope(isolate); | 8453 HandleScope scope(isolate); |
8454 ASSERT(args.length() == 1); | 8454 DCHECK(args.length() == 1); |
8455 CONVERT_SMI_ARG_CHECKED(type_arg, 0); | 8455 CONVERT_SMI_ARG_CHECKED(type_arg, 0); |
8456 Deoptimizer::BailoutType type = | 8456 Deoptimizer::BailoutType type = |
8457 static_cast<Deoptimizer::BailoutType>(type_arg); | 8457 static_cast<Deoptimizer::BailoutType>(type_arg); |
8458 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8458 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
8459 ASSERT(AllowHeapAllocation::IsAllowed()); | 8459 DCHECK(AllowHeapAllocation::IsAllowed()); |
8460 | 8460 |
8461 Handle<JSFunction> function = deoptimizer->function(); | 8461 Handle<JSFunction> function = deoptimizer->function(); |
8462 Handle<Code> optimized_code = deoptimizer->compiled_code(); | 8462 Handle<Code> optimized_code = deoptimizer->compiled_code(); |
8463 | 8463 |
8464 ASSERT(optimized_code->kind() == Code::OPTIMIZED_FUNCTION); | 8464 DCHECK(optimized_code->kind() == Code::OPTIMIZED_FUNCTION); |
8465 ASSERT(type == deoptimizer->bailout_type()); | 8465 DCHECK(type == deoptimizer->bailout_type()); |
8466 | 8466 |
8467 // Make sure to materialize objects before causing any allocation. | 8467 // Make sure to materialize objects before causing any allocation. |
8468 JavaScriptFrameIterator it(isolate); | 8468 JavaScriptFrameIterator it(isolate); |
8469 deoptimizer->MaterializeHeapObjects(&it); | 8469 deoptimizer->MaterializeHeapObjects(&it); |
8470 delete deoptimizer; | 8470 delete deoptimizer; |
8471 | 8471 |
8472 JavaScriptFrame* frame = it.frame(); | 8472 JavaScriptFrame* frame = it.frame(); |
8473 RUNTIME_ASSERT(frame->function()->IsJSFunction()); | 8473 RUNTIME_ASSERT(frame->function()->IsJSFunction()); |
8474 ASSERT(frame->function() == *function); | 8474 DCHECK(frame->function() == *function); |
8475 | 8475 |
8476 // Avoid doing too much work when running with --always-opt and keep | 8476 // Avoid doing too much work when running with --always-opt and keep |
8477 // the optimized code around. | 8477 // the optimized code around. |
8478 if (FLAG_always_opt || type == Deoptimizer::LAZY) { | 8478 if (FLAG_always_opt || type == Deoptimizer::LAZY) { |
8479 return isolate->heap()->undefined_value(); | 8479 return isolate->heap()->undefined_value(); |
8480 } | 8480 } |
8481 | 8481 |
8482 // Search for other activations of the same function and code. | 8482 // Search for other activations of the same function and code. |
8483 ActivationsFinder activations_finder(*optimized_code); | 8483 ActivationsFinder activations_finder(*optimized_code); |
8484 activations_finder.VisitFrames(&it); | 8484 activations_finder.VisitFrames(&it); |
(...skipping 18 matching lines...) Expand all Loading... |
8503 // If there is an index by shared function info, all the better. | 8503 // If there is an index by shared function info, all the better. |
8504 Deoptimizer::DeoptimizeFunction(*function); | 8504 Deoptimizer::DeoptimizeFunction(*function); |
8505 } | 8505 } |
8506 | 8506 |
8507 return isolate->heap()->undefined_value(); | 8507 return isolate->heap()->undefined_value(); |
8508 } | 8508 } |
8509 | 8509 |
8510 | 8510 |
8511 RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { | 8511 RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { |
8512 HandleScope scope(isolate); | 8512 HandleScope scope(isolate); |
8513 ASSERT(args.length() == 1); | 8513 DCHECK(args.length() == 1); |
8514 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8514 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8515 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); | 8515 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); |
8516 | 8516 |
8517 // TODO(turbofan): Deoptimization is not supported yet. | 8517 // TODO(turbofan): Deoptimization is not supported yet. |
8518 if (function->code()->is_turbofanned() && !FLAG_turbo_deoptimization) { | 8518 if (function->code()->is_turbofanned() && !FLAG_turbo_deoptimization) { |
8519 return isolate->heap()->undefined_value(); | 8519 return isolate->heap()->undefined_value(); |
8520 } | 8520 } |
8521 | 8521 |
8522 Deoptimizer::DeoptimizeFunction(*function); | 8522 Deoptimizer::DeoptimizeFunction(*function); |
8523 | 8523 |
8524 return isolate->heap()->undefined_value(); | 8524 return isolate->heap()->undefined_value(); |
8525 } | 8525 } |
8526 | 8526 |
8527 | 8527 |
8528 RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) { | 8528 RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) { |
8529 HandleScope scope(isolate); | 8529 HandleScope scope(isolate); |
8530 ASSERT(args.length() == 1); | 8530 DCHECK(args.length() == 1); |
8531 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8531 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8532 function->shared()->ClearTypeFeedbackInfo(); | 8532 function->shared()->ClearTypeFeedbackInfo(); |
8533 Code* unoptimized = function->shared()->code(); | 8533 Code* unoptimized = function->shared()->code(); |
8534 if (unoptimized->kind() == Code::FUNCTION) { | 8534 if (unoptimized->kind() == Code::FUNCTION) { |
8535 unoptimized->ClearInlineCaches(); | 8535 unoptimized->ClearInlineCaches(); |
8536 } | 8536 } |
8537 return isolate->heap()->undefined_value(); | 8537 return isolate->heap()->undefined_value(); |
8538 } | 8538 } |
8539 | 8539 |
8540 | 8540 |
8541 RUNTIME_FUNCTION(Runtime_RunningInSimulator) { | 8541 RUNTIME_FUNCTION(Runtime_RunningInSimulator) { |
8542 SealHandleScope shs(isolate); | 8542 SealHandleScope shs(isolate); |
8543 ASSERT(args.length() == 0); | 8543 DCHECK(args.length() == 0); |
8544 #if defined(USE_SIMULATOR) | 8544 #if defined(USE_SIMULATOR) |
8545 return isolate->heap()->true_value(); | 8545 return isolate->heap()->true_value(); |
8546 #else | 8546 #else |
8547 return isolate->heap()->false_value(); | 8547 return isolate->heap()->false_value(); |
8548 #endif | 8548 #endif |
8549 } | 8549 } |
8550 | 8550 |
8551 | 8551 |
8552 RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) { | 8552 RUNTIME_FUNCTION(Runtime_IsConcurrentRecompilationSupported) { |
8553 SealHandleScope shs(isolate); | 8553 SealHandleScope shs(isolate); |
8554 ASSERT(args.length() == 0); | 8554 DCHECK(args.length() == 0); |
8555 return isolate->heap()->ToBoolean( | 8555 return isolate->heap()->ToBoolean( |
8556 isolate->concurrent_recompilation_enabled()); | 8556 isolate->concurrent_recompilation_enabled()); |
8557 } | 8557 } |
8558 | 8558 |
8559 | 8559 |
8560 RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { | 8560 RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { |
8561 HandleScope scope(isolate); | 8561 HandleScope scope(isolate); |
8562 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8562 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
8563 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8563 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8564 | 8564 |
8565 if (!function->IsOptimizable() && | 8565 if (!function->IsOptimizable() && |
8566 !function->IsMarkedForConcurrentOptimization() && | 8566 !function->IsMarkedForConcurrentOptimization() && |
8567 !function->IsInOptimizationQueue()) { | 8567 !function->IsInOptimizationQueue()) { |
8568 return isolate->heap()->undefined_value(); | 8568 return isolate->heap()->undefined_value(); |
8569 } | 8569 } |
8570 | 8570 |
8571 function->MarkForOptimization(); | 8571 function->MarkForOptimization(); |
8572 | 8572 |
8573 Code* unoptimized = function->shared()->code(); | 8573 Code* unoptimized = function->shared()->code(); |
8574 if (args.length() == 2 && | 8574 if (args.length() == 2 && |
8575 unoptimized->kind() == Code::FUNCTION) { | 8575 unoptimized->kind() == Code::FUNCTION) { |
8576 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 8576 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
8577 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr")) && FLAG_use_osr) { | 8577 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr")) && FLAG_use_osr) { |
8578 // Start patching from the currently patched loop nesting level. | 8578 // Start patching from the currently patched loop nesting level. |
8579 ASSERT(BackEdgeTable::Verify(isolate, unoptimized)); | 8579 DCHECK(BackEdgeTable::Verify(isolate, unoptimized)); |
8580 isolate->runtime_profiler()->AttemptOnStackReplacement( | 8580 isolate->runtime_profiler()->AttemptOnStackReplacement( |
8581 *function, Code::kMaxLoopNestingMarker); | 8581 *function, Code::kMaxLoopNestingMarker); |
8582 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) && | 8582 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) && |
8583 isolate->concurrent_recompilation_enabled()) { | 8583 isolate->concurrent_recompilation_enabled()) { |
8584 function->MarkForConcurrentOptimization(); | 8584 function->MarkForConcurrentOptimization(); |
8585 } | 8585 } |
8586 } | 8586 } |
8587 | 8587 |
8588 return isolate->heap()->undefined_value(); | 8588 return isolate->heap()->undefined_value(); |
8589 } | 8589 } |
8590 | 8590 |
8591 | 8591 |
8592 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { | 8592 RUNTIME_FUNCTION(Runtime_NeverOptimizeFunction) { |
8593 HandleScope scope(isolate); | 8593 HandleScope scope(isolate); |
8594 ASSERT(args.length() == 1); | 8594 DCHECK(args.length() == 1); |
8595 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8595 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
8596 function->shared()->set_optimization_disabled(true); | 8596 function->shared()->set_optimization_disabled(true); |
8597 return isolate->heap()->undefined_value(); | 8597 return isolate->heap()->undefined_value(); |
8598 } | 8598 } |
8599 | 8599 |
8600 | 8600 |
8601 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { | 8601 RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { |
8602 HandleScope scope(isolate); | 8602 HandleScope scope(isolate); |
8603 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8603 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
8604 if (!isolate->use_crankshaft()) { | 8604 if (!isolate->use_crankshaft()) { |
(...skipping 25 matching lines...) Expand all Loading... |
8630 } | 8630 } |
8631 if (function->IsOptimized() && function->code()->is_turbofanned()) { | 8631 if (function->IsOptimized() && function->code()->is_turbofanned()) { |
8632 return Smi::FromInt(7); // 7 == "TurboFan compiler". | 8632 return Smi::FromInt(7); // 7 == "TurboFan compiler". |
8633 } | 8633 } |
8634 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". | 8634 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". |
8635 : Smi::FromInt(2); // 2 == "no". | 8635 : Smi::FromInt(2); // 2 == "no". |
8636 } | 8636 } |
8637 | 8637 |
8638 | 8638 |
8639 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { | 8639 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { |
8640 ASSERT(args.length() == 0); | 8640 DCHECK(args.length() == 0); |
8641 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); | 8641 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); |
8642 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); | 8642 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); |
8643 isolate->optimizing_compiler_thread()->Unblock(); | 8643 isolate->optimizing_compiler_thread()->Unblock(); |
8644 return isolate->heap()->undefined_value(); | 8644 return isolate->heap()->undefined_value(); |
8645 } | 8645 } |
8646 | 8646 |
8647 | 8647 |
8648 RUNTIME_FUNCTION(Runtime_GetOptimizationCount) { | 8648 RUNTIME_FUNCTION(Runtime_GetOptimizationCount) { |
8649 HandleScope scope(isolate); | 8649 HandleScope scope(isolate); |
8650 ASSERT(args.length() == 1); | 8650 DCHECK(args.length() == 1); |
8651 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8651 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8652 return Smi::FromInt(function->shared()->opt_count()); | 8652 return Smi::FromInt(function->shared()->opt_count()); |
8653 } | 8653 } |
8654 | 8654 |
8655 | 8655 |
8656 static bool IsSuitableForOnStackReplacement(Isolate* isolate, | 8656 static bool IsSuitableForOnStackReplacement(Isolate* isolate, |
8657 Handle<JSFunction> function, | 8657 Handle<JSFunction> function, |
8658 Handle<Code> current_code) { | 8658 Handle<Code> current_code) { |
8659 // Keep track of whether we've succeeded in optimizing. | 8659 // Keep track of whether we've succeeded in optimizing. |
8660 if (!isolate->use_crankshaft() || !current_code->optimizable()) return false; | 8660 if (!isolate->use_crankshaft() || !current_code->optimizable()) return false; |
8661 // If we are trying to do OSR when there are already optimized | 8661 // If we are trying to do OSR when there are already optimized |
8662 // activations of the function, it means (a) the function is directly or | 8662 // activations of the function, it means (a) the function is directly or |
8663 // indirectly recursive and (b) an optimized invocation has been | 8663 // indirectly recursive and (b) an optimized invocation has been |
8664 // deoptimized so that we are currently in an unoptimized activation. | 8664 // deoptimized so that we are currently in an unoptimized activation. |
8665 // Check for optimized activations of this function. | 8665 // Check for optimized activations of this function. |
8666 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { | 8666 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { |
8667 JavaScriptFrame* frame = it.frame(); | 8667 JavaScriptFrame* frame = it.frame(); |
8668 if (frame->is_optimized() && frame->function() == *function) return false; | 8668 if (frame->is_optimized() && frame->function() == *function) return false; |
8669 } | 8669 } |
8670 | 8670 |
8671 return true; | 8671 return true; |
8672 } | 8672 } |
8673 | 8673 |
8674 | 8674 |
8675 RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { | 8675 RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { |
8676 HandleScope scope(isolate); | 8676 HandleScope scope(isolate); |
8677 ASSERT(args.length() == 1); | 8677 DCHECK(args.length() == 1); |
8678 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8678 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8679 Handle<Code> caller_code(function->shared()->code()); | 8679 Handle<Code> caller_code(function->shared()->code()); |
8680 | 8680 |
8681 // We're not prepared to handle a function with arguments object. | 8681 // We're not prepared to handle a function with arguments object. |
8682 ASSERT(!function->shared()->uses_arguments()); | 8682 DCHECK(!function->shared()->uses_arguments()); |
8683 | 8683 |
8684 RUNTIME_ASSERT(FLAG_use_osr); | 8684 RUNTIME_ASSERT(FLAG_use_osr); |
8685 | 8685 |
8686 // Passing the PC in the javascript frame from the caller directly is | 8686 // Passing the PC in the javascript frame from the caller directly is |
8687 // not GC safe, so we walk the stack to get it. | 8687 // not GC safe, so we walk the stack to get it. |
8688 JavaScriptFrameIterator it(isolate); | 8688 JavaScriptFrameIterator it(isolate); |
8689 JavaScriptFrame* frame = it.frame(); | 8689 JavaScriptFrame* frame = it.frame(); |
8690 if (!caller_code->contains(frame->pc())) { | 8690 if (!caller_code->contains(frame->pc())) { |
8691 // Code on the stack may not be the code object referenced by the shared | 8691 // Code on the stack may not be the code object referenced by the shared |
8692 // function info. It may have been replaced to include deoptimization data. | 8692 // function info. It may have been replaced to include deoptimization data. |
8693 caller_code = Handle<Code>(frame->LookupCode()); | 8693 caller_code = Handle<Code>(frame->LookupCode()); |
8694 } | 8694 } |
8695 | 8695 |
8696 uint32_t pc_offset = static_cast<uint32_t>( | 8696 uint32_t pc_offset = static_cast<uint32_t>( |
8697 frame->pc() - caller_code->instruction_start()); | 8697 frame->pc() - caller_code->instruction_start()); |
8698 | 8698 |
8699 #ifdef DEBUG | 8699 #ifdef DEBUG |
8700 ASSERT_EQ(frame->function(), *function); | 8700 DCHECK_EQ(frame->function(), *function); |
8701 ASSERT_EQ(frame->LookupCode(), *caller_code); | 8701 DCHECK_EQ(frame->LookupCode(), *caller_code); |
8702 ASSERT(caller_code->contains(frame->pc())); | 8702 DCHECK(caller_code->contains(frame->pc())); |
8703 #endif // DEBUG | 8703 #endif // DEBUG |
8704 | 8704 |
8705 | 8705 |
8706 BailoutId ast_id = caller_code->TranslatePcOffsetToAstId(pc_offset); | 8706 BailoutId ast_id = caller_code->TranslatePcOffsetToAstId(pc_offset); |
8707 ASSERT(!ast_id.IsNone()); | 8707 DCHECK(!ast_id.IsNone()); |
8708 | 8708 |
8709 Compiler::ConcurrencyMode mode = | 8709 Compiler::ConcurrencyMode mode = |
8710 isolate->concurrent_osr_enabled() && | 8710 isolate->concurrent_osr_enabled() && |
8711 (function->shared()->ast_node_count() > 512) ? Compiler::CONCURRENT | 8711 (function->shared()->ast_node_count() > 512) ? Compiler::CONCURRENT |
8712 : Compiler::NOT_CONCURRENT; | 8712 : Compiler::NOT_CONCURRENT; |
8713 Handle<Code> result = Handle<Code>::null(); | 8713 Handle<Code> result = Handle<Code>::null(); |
8714 | 8714 |
8715 OptimizedCompileJob* job = NULL; | 8715 OptimizedCompileJob* job = NULL; |
8716 if (mode == Compiler::CONCURRENT) { | 8716 if (mode == Compiler::CONCURRENT) { |
8717 // Gate the OSR entry with a stack check. | 8717 // Gate the OSR entry with a stack check. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8754 | 8754 |
8755 // Revert the patched back edge table, regardless of whether OSR succeeds. | 8755 // Revert the patched back edge table, regardless of whether OSR succeeds. |
8756 BackEdgeTable::Revert(isolate, *caller_code); | 8756 BackEdgeTable::Revert(isolate, *caller_code); |
8757 | 8757 |
8758 // Check whether we ended up with usable optimized code. | 8758 // Check whether we ended up with usable optimized code. |
8759 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) { | 8759 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) { |
8760 DeoptimizationInputData* data = | 8760 DeoptimizationInputData* data = |
8761 DeoptimizationInputData::cast(result->deoptimization_data()); | 8761 DeoptimizationInputData::cast(result->deoptimization_data()); |
8762 | 8762 |
8763 if (data->OsrPcOffset()->value() >= 0) { | 8763 if (data->OsrPcOffset()->value() >= 0) { |
8764 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id); | 8764 DCHECK(BailoutId(data->OsrAstId()->value()) == ast_id); |
8765 if (FLAG_trace_osr) { | 8765 if (FLAG_trace_osr) { |
8766 PrintF("[OSR - Entry at AST id %d, offset %d in optimized code]\n", | 8766 PrintF("[OSR - Entry at AST id %d, offset %d in optimized code]\n", |
8767 ast_id.ToInt(), data->OsrPcOffset()->value()); | 8767 ast_id.ToInt(), data->OsrPcOffset()->value()); |
8768 } | 8768 } |
8769 // TODO(titzer): this is a massive hack to make the deopt counts | 8769 // TODO(titzer): this is a massive hack to make the deopt counts |
8770 // match. Fix heuristics for reenabling optimizations! | 8770 // match. Fix heuristics for reenabling optimizations! |
8771 function->shared()->increment_deopt_count(); | 8771 function->shared()->increment_deopt_count(); |
8772 | 8772 |
8773 // TODO(titzer): Do not install code into the function. | 8773 // TODO(titzer): Do not install code into the function. |
8774 function->ReplaceCode(*result); | 8774 function->ReplaceCode(*result); |
(...skipping 10 matching lines...) Expand all Loading... |
8785 | 8785 |
8786 if (!function->IsOptimized()) { | 8786 if (!function->IsOptimized()) { |
8787 function->ReplaceCode(function->shared()->code()); | 8787 function->ReplaceCode(function->shared()->code()); |
8788 } | 8788 } |
8789 return NULL; | 8789 return NULL; |
8790 } | 8790 } |
8791 | 8791 |
8792 | 8792 |
8793 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { | 8793 RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { |
8794 SealHandleScope shs(isolate); | 8794 SealHandleScope shs(isolate); |
8795 ASSERT(args.length() == 2 || args.length() == 3); | 8795 DCHECK(args.length() == 2 || args.length() == 3); |
8796 #ifdef DEBUG | 8796 #ifdef DEBUG |
8797 CONVERT_SMI_ARG_CHECKED(interval, 0); | 8797 CONVERT_SMI_ARG_CHECKED(interval, 0); |
8798 CONVERT_SMI_ARG_CHECKED(timeout, 1); | 8798 CONVERT_SMI_ARG_CHECKED(timeout, 1); |
8799 isolate->heap()->set_allocation_timeout(timeout); | 8799 isolate->heap()->set_allocation_timeout(timeout); |
8800 FLAG_gc_interval = interval; | 8800 FLAG_gc_interval = interval; |
8801 if (args.length() == 3) { | 8801 if (args.length() == 3) { |
8802 // Enable/disable inline allocation if requested. | 8802 // Enable/disable inline allocation if requested. |
8803 CONVERT_BOOLEAN_ARG_CHECKED(inline_allocation, 2); | 8803 CONVERT_BOOLEAN_ARG_CHECKED(inline_allocation, 2); |
8804 if (inline_allocation) { | 8804 if (inline_allocation) { |
8805 isolate->heap()->EnableInlineAllocation(); | 8805 isolate->heap()->EnableInlineAllocation(); |
8806 } else { | 8806 } else { |
8807 isolate->heap()->DisableInlineAllocation(); | 8807 isolate->heap()->DisableInlineAllocation(); |
8808 } | 8808 } |
8809 } | 8809 } |
8810 #endif | 8810 #endif |
8811 return isolate->heap()->undefined_value(); | 8811 return isolate->heap()->undefined_value(); |
8812 } | 8812 } |
8813 | 8813 |
8814 | 8814 |
8815 RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) { | 8815 RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) { |
8816 SealHandleScope shs(isolate); | 8816 SealHandleScope shs(isolate); |
8817 ASSERT(args.length() == 0); | 8817 DCHECK(args.length() == 0); |
8818 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8818 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
8819 return isolate->heap()->undefined_value(); | 8819 return isolate->heap()->undefined_value(); |
8820 } | 8820 } |
8821 | 8821 |
8822 | 8822 |
8823 RUNTIME_FUNCTION(Runtime_GetRootNaN) { | 8823 RUNTIME_FUNCTION(Runtime_GetRootNaN) { |
8824 SealHandleScope shs(isolate); | 8824 SealHandleScope shs(isolate); |
8825 ASSERT(args.length() == 0); | 8825 DCHECK(args.length() == 0); |
8826 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8826 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
8827 return isolate->heap()->nan_value(); | 8827 return isolate->heap()->nan_value(); |
8828 } | 8828 } |
8829 | 8829 |
8830 | 8830 |
8831 RUNTIME_FUNCTION(Runtime_Call) { | 8831 RUNTIME_FUNCTION(Runtime_Call) { |
8832 HandleScope scope(isolate); | 8832 HandleScope scope(isolate); |
8833 ASSERT(args.length() >= 2); | 8833 DCHECK(args.length() >= 2); |
8834 int argc = args.length() - 2; | 8834 int argc = args.length() - 2; |
8835 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); | 8835 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); |
8836 Object* receiver = args[0]; | 8836 Object* receiver = args[0]; |
8837 | 8837 |
8838 // If there are too many arguments, allocate argv via malloc. | 8838 // If there are too many arguments, allocate argv via malloc. |
8839 const int argv_small_size = 10; | 8839 const int argv_small_size = 10; |
8840 Handle<Object> argv_small_buffer[argv_small_size]; | 8840 Handle<Object> argv_small_buffer[argv_small_size]; |
8841 SmartArrayPointer<Handle<Object> > argv_large_buffer; | 8841 SmartArrayPointer<Handle<Object> > argv_large_buffer; |
8842 Handle<Object>* argv = argv_small_buffer; | 8842 Handle<Object>* argv = argv_small_buffer; |
8843 if (argc > argv_small_size) { | 8843 if (argc > argv_small_size) { |
(...skipping 11 matching lines...) Expand all Loading... |
8855 Handle<Object> result; | 8855 Handle<Object> result; |
8856 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8856 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
8857 isolate, result, | 8857 isolate, result, |
8858 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); | 8858 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); |
8859 return *result; | 8859 return *result; |
8860 } | 8860 } |
8861 | 8861 |
8862 | 8862 |
8863 RUNTIME_FUNCTION(Runtime_Apply) { | 8863 RUNTIME_FUNCTION(Runtime_Apply) { |
8864 HandleScope scope(isolate); | 8864 HandleScope scope(isolate); |
8865 ASSERT(args.length() == 5); | 8865 DCHECK(args.length() == 5); |
8866 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); | 8866 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); |
8867 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); | 8867 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); |
8868 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); | 8868 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); |
8869 CONVERT_SMI_ARG_CHECKED(offset, 3); | 8869 CONVERT_SMI_ARG_CHECKED(offset, 3); |
8870 CONVERT_SMI_ARG_CHECKED(argc, 4); | 8870 CONVERT_SMI_ARG_CHECKED(argc, 4); |
8871 RUNTIME_ASSERT(offset >= 0); | 8871 RUNTIME_ASSERT(offset >= 0); |
8872 // Loose upper bound to allow fuzzing. We'll most likely run out of | 8872 // Loose upper bound to allow fuzzing. We'll most likely run out of |
8873 // stack space before hitting this limit. | 8873 // stack space before hitting this limit. |
8874 static int kMaxArgc = 1000000; | 8874 static int kMaxArgc = 1000000; |
8875 RUNTIME_ASSERT(argc >= 0 && argc <= kMaxArgc); | 8875 RUNTIME_ASSERT(argc >= 0 && argc <= kMaxArgc); |
(...skipping 18 matching lines...) Expand all Loading... |
8894 Handle<Object> result; | 8894 Handle<Object> result; |
8895 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8895 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
8896 isolate, result, | 8896 isolate, result, |
8897 Execution::Call(isolate, fun, receiver, argc, argv, true)); | 8897 Execution::Call(isolate, fun, receiver, argc, argv, true)); |
8898 return *result; | 8898 return *result; |
8899 } | 8899 } |
8900 | 8900 |
8901 | 8901 |
8902 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { | 8902 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { |
8903 HandleScope scope(isolate); | 8903 HandleScope scope(isolate); |
8904 ASSERT(args.length() == 1); | 8904 DCHECK(args.length() == 1); |
8905 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 8905 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
8906 RUNTIME_ASSERT(!object->IsJSFunction()); | 8906 RUNTIME_ASSERT(!object->IsJSFunction()); |
8907 return *Execution::GetFunctionDelegate(isolate, object); | 8907 return *Execution::GetFunctionDelegate(isolate, object); |
8908 } | 8908 } |
8909 | 8909 |
8910 | 8910 |
8911 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { | 8911 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { |
8912 HandleScope scope(isolate); | 8912 HandleScope scope(isolate); |
8913 ASSERT(args.length() == 1); | 8913 DCHECK(args.length() == 1); |
8914 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 8914 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
8915 RUNTIME_ASSERT(!object->IsJSFunction()); | 8915 RUNTIME_ASSERT(!object->IsJSFunction()); |
8916 return *Execution::GetConstructorDelegate(isolate, object); | 8916 return *Execution::GetConstructorDelegate(isolate, object); |
8917 } | 8917 } |
8918 | 8918 |
8919 | 8919 |
8920 RUNTIME_FUNCTION(Runtime_NewGlobalContext) { | 8920 RUNTIME_FUNCTION(Runtime_NewGlobalContext) { |
8921 HandleScope scope(isolate); | 8921 HandleScope scope(isolate); |
8922 ASSERT(args.length() == 2); | 8922 DCHECK(args.length() == 2); |
8923 | 8923 |
8924 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8924 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8925 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); | 8925 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); |
8926 Handle<Context> result = | 8926 Handle<Context> result = |
8927 isolate->factory()->NewGlobalContext(function, scope_info); | 8927 isolate->factory()->NewGlobalContext(function, scope_info); |
8928 | 8928 |
8929 ASSERT(function->context() == isolate->context()); | 8929 DCHECK(function->context() == isolate->context()); |
8930 ASSERT(function->context()->global_object() == result->global_object()); | 8930 DCHECK(function->context()->global_object() == result->global_object()); |
8931 result->global_object()->set_global_context(*result); | 8931 result->global_object()->set_global_context(*result); |
8932 return *result; | 8932 return *result; |
8933 } | 8933 } |
8934 | 8934 |
8935 | 8935 |
8936 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { | 8936 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { |
8937 HandleScope scope(isolate); | 8937 HandleScope scope(isolate); |
8938 ASSERT(args.length() == 1); | 8938 DCHECK(args.length() == 1); |
8939 | 8939 |
8940 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8940 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8941 | 8941 |
8942 ASSERT(function->context() == isolate->context()); | 8942 DCHECK(function->context() == isolate->context()); |
8943 int length = function->shared()->scope_info()->ContextLength(); | 8943 int length = function->shared()->scope_info()->ContextLength(); |
8944 return *isolate->factory()->NewFunctionContext(length, function); | 8944 return *isolate->factory()->NewFunctionContext(length, function); |
8945 } | 8945 } |
8946 | 8946 |
8947 | 8947 |
8948 RUNTIME_FUNCTION(Runtime_PushWithContext) { | 8948 RUNTIME_FUNCTION(Runtime_PushWithContext) { |
8949 HandleScope scope(isolate); | 8949 HandleScope scope(isolate); |
8950 ASSERT(args.length() == 2); | 8950 DCHECK(args.length() == 2); |
8951 Handle<JSReceiver> extension_object; | 8951 Handle<JSReceiver> extension_object; |
8952 if (args[0]->IsJSReceiver()) { | 8952 if (args[0]->IsJSReceiver()) { |
8953 extension_object = args.at<JSReceiver>(0); | 8953 extension_object = args.at<JSReceiver>(0); |
8954 } else { | 8954 } else { |
8955 // Try to convert the object to a proper JavaScript object. | 8955 // Try to convert the object to a proper JavaScript object. |
8956 MaybeHandle<JSReceiver> maybe_object = | 8956 MaybeHandle<JSReceiver> maybe_object = |
8957 Object::ToObject(isolate, args.at<Object>(0)); | 8957 Object::ToObject(isolate, args.at<Object>(0)); |
8958 if (!maybe_object.ToHandle(&extension_object)) { | 8958 if (!maybe_object.ToHandle(&extension_object)) { |
8959 Handle<Object> handle = args.at<Object>(0); | 8959 Handle<Object> handle = args.at<Object>(0); |
8960 Handle<Object> result = | 8960 Handle<Object> result = |
(...skipping 16 matching lines...) Expand all Loading... |
8977 Handle<Context> current(isolate->context()); | 8977 Handle<Context> current(isolate->context()); |
8978 Handle<Context> context = isolate->factory()->NewWithContext( | 8978 Handle<Context> context = isolate->factory()->NewWithContext( |
8979 function, current, extension_object); | 8979 function, current, extension_object); |
8980 isolate->set_context(*context); | 8980 isolate->set_context(*context); |
8981 return *context; | 8981 return *context; |
8982 } | 8982 } |
8983 | 8983 |
8984 | 8984 |
8985 RUNTIME_FUNCTION(Runtime_PushCatchContext) { | 8985 RUNTIME_FUNCTION(Runtime_PushCatchContext) { |
8986 HandleScope scope(isolate); | 8986 HandleScope scope(isolate); |
8987 ASSERT(args.length() == 3); | 8987 DCHECK(args.length() == 3); |
8988 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 8988 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
8989 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); | 8989 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
8990 Handle<JSFunction> function; | 8990 Handle<JSFunction> function; |
8991 if (args[2]->IsSmi()) { | 8991 if (args[2]->IsSmi()) { |
8992 // A smi sentinel indicates a context nested inside global code rather | 8992 // A smi sentinel indicates a context nested inside global code rather |
8993 // than some function. There is a canonical empty function that can be | 8993 // than some function. There is a canonical empty function that can be |
8994 // gotten from the native context. | 8994 // gotten from the native context. |
8995 function = handle(isolate->native_context()->closure()); | 8995 function = handle(isolate->native_context()->closure()); |
8996 } else { | 8996 } else { |
8997 function = args.at<JSFunction>(2); | 8997 function = args.at<JSFunction>(2); |
8998 } | 8998 } |
8999 Handle<Context> current(isolate->context()); | 8999 Handle<Context> current(isolate->context()); |
9000 Handle<Context> context = isolate->factory()->NewCatchContext( | 9000 Handle<Context> context = isolate->factory()->NewCatchContext( |
9001 function, current, name, thrown_object); | 9001 function, current, name, thrown_object); |
9002 isolate->set_context(*context); | 9002 isolate->set_context(*context); |
9003 return *context; | 9003 return *context; |
9004 } | 9004 } |
9005 | 9005 |
9006 | 9006 |
9007 RUNTIME_FUNCTION(Runtime_PushBlockContext) { | 9007 RUNTIME_FUNCTION(Runtime_PushBlockContext) { |
9008 HandleScope scope(isolate); | 9008 HandleScope scope(isolate); |
9009 ASSERT(args.length() == 2); | 9009 DCHECK(args.length() == 2); |
9010 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); | 9010 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); |
9011 Handle<JSFunction> function; | 9011 Handle<JSFunction> function; |
9012 if (args[1]->IsSmi()) { | 9012 if (args[1]->IsSmi()) { |
9013 // A smi sentinel indicates a context nested inside global code rather | 9013 // A smi sentinel indicates a context nested inside global code rather |
9014 // than some function. There is a canonical empty function that can be | 9014 // than some function. There is a canonical empty function that can be |
9015 // gotten from the native context. | 9015 // gotten from the native context. |
9016 function = handle(isolate->native_context()->closure()); | 9016 function = handle(isolate->native_context()->closure()); |
9017 } else { | 9017 } else { |
9018 function = args.at<JSFunction>(1); | 9018 function = args.at<JSFunction>(1); |
9019 } | 9019 } |
9020 Handle<Context> current(isolate->context()); | 9020 Handle<Context> current(isolate->context()); |
9021 Handle<Context> context = isolate->factory()->NewBlockContext( | 9021 Handle<Context> context = isolate->factory()->NewBlockContext( |
9022 function, current, scope_info); | 9022 function, current, scope_info); |
9023 isolate->set_context(*context); | 9023 isolate->set_context(*context); |
9024 return *context; | 9024 return *context; |
9025 } | 9025 } |
9026 | 9026 |
9027 | 9027 |
9028 RUNTIME_FUNCTION(Runtime_IsJSModule) { | 9028 RUNTIME_FUNCTION(Runtime_IsJSModule) { |
9029 SealHandleScope shs(isolate); | 9029 SealHandleScope shs(isolate); |
9030 ASSERT(args.length() == 1); | 9030 DCHECK(args.length() == 1); |
9031 CONVERT_ARG_CHECKED(Object, obj, 0); | 9031 CONVERT_ARG_CHECKED(Object, obj, 0); |
9032 return isolate->heap()->ToBoolean(obj->IsJSModule()); | 9032 return isolate->heap()->ToBoolean(obj->IsJSModule()); |
9033 } | 9033 } |
9034 | 9034 |
9035 | 9035 |
9036 RUNTIME_FUNCTION(Runtime_PushModuleContext) { | 9036 RUNTIME_FUNCTION(Runtime_PushModuleContext) { |
9037 SealHandleScope shs(isolate); | 9037 SealHandleScope shs(isolate); |
9038 ASSERT(args.length() == 2); | 9038 DCHECK(args.length() == 2); |
9039 CONVERT_SMI_ARG_CHECKED(index, 0); | 9039 CONVERT_SMI_ARG_CHECKED(index, 0); |
9040 | 9040 |
9041 if (!args[1]->IsScopeInfo()) { | 9041 if (!args[1]->IsScopeInfo()) { |
9042 // Module already initialized. Find hosting context and retrieve context. | 9042 // Module already initialized. Find hosting context and retrieve context. |
9043 Context* host = Context::cast(isolate->context())->global_context(); | 9043 Context* host = Context::cast(isolate->context())->global_context(); |
9044 Context* context = Context::cast(host->get(index)); | 9044 Context* context = Context::cast(host->get(index)); |
9045 ASSERT(context->previous() == isolate->context()); | 9045 DCHECK(context->previous() == isolate->context()); |
9046 isolate->set_context(context); | 9046 isolate->set_context(context); |
9047 return context; | 9047 return context; |
9048 } | 9048 } |
9049 | 9049 |
9050 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); | 9050 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); |
9051 | 9051 |
9052 // Allocate module context. | 9052 // Allocate module context. |
9053 HandleScope scope(isolate); | 9053 HandleScope scope(isolate); |
9054 Factory* factory = isolate->factory(); | 9054 Factory* factory = isolate->factory(); |
9055 Handle<Context> context = factory->NewModuleContext(scope_info); | 9055 Handle<Context> context = factory->NewModuleContext(scope_info); |
9056 Handle<JSModule> module = factory->NewJSModule(context, scope_info); | 9056 Handle<JSModule> module = factory->NewJSModule(context, scope_info); |
9057 context->set_module(*module); | 9057 context->set_module(*module); |
9058 Context* previous = isolate->context(); | 9058 Context* previous = isolate->context(); |
9059 context->set_previous(previous); | 9059 context->set_previous(previous); |
9060 context->set_closure(previous->closure()); | 9060 context->set_closure(previous->closure()); |
9061 context->set_global_object(previous->global_object()); | 9061 context->set_global_object(previous->global_object()); |
9062 isolate->set_context(*context); | 9062 isolate->set_context(*context); |
9063 | 9063 |
9064 // Find hosting scope and initialize internal variable holding module there. | 9064 // Find hosting scope and initialize internal variable holding module there. |
9065 previous->global_context()->set(index, *context); | 9065 previous->global_context()->set(index, *context); |
9066 | 9066 |
9067 return *context; | 9067 return *context; |
9068 } | 9068 } |
9069 | 9069 |
9070 | 9070 |
9071 RUNTIME_FUNCTION(Runtime_DeclareModules) { | 9071 RUNTIME_FUNCTION(Runtime_DeclareModules) { |
9072 HandleScope scope(isolate); | 9072 HandleScope scope(isolate); |
9073 ASSERT(args.length() == 1); | 9073 DCHECK(args.length() == 1); |
9074 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); | 9074 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); |
9075 Context* host_context = isolate->context(); | 9075 Context* host_context = isolate->context(); |
9076 | 9076 |
9077 for (int i = 0; i < descriptions->length(); ++i) { | 9077 for (int i = 0; i < descriptions->length(); ++i) { |
9078 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); | 9078 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); |
9079 int host_index = description->host_index(); | 9079 int host_index = description->host_index(); |
9080 Handle<Context> context(Context::cast(host_context->get(host_index))); | 9080 Handle<Context> context(Context::cast(host_context->get(host_index))); |
9081 Handle<JSModule> module(context->module()); | 9081 Handle<JSModule> module(context->module()); |
9082 | 9082 |
9083 for (int j = 0; j < description->length(); ++j) { | 9083 for (int j = 0; j < description->length(); ++j) { |
9084 Handle<String> name(description->name(j)); | 9084 Handle<String> name(description->name(j)); |
9085 VariableMode mode = description->mode(j); | 9085 VariableMode mode = description->mode(j); |
9086 int index = description->index(j); | 9086 int index = description->index(j); |
9087 switch (mode) { | 9087 switch (mode) { |
9088 case VAR: | 9088 case VAR: |
9089 case LET: | 9089 case LET: |
9090 case CONST: | 9090 case CONST: |
9091 case CONST_LEGACY: { | 9091 case CONST_LEGACY: { |
9092 PropertyAttributes attr = | 9092 PropertyAttributes attr = |
9093 IsImmutableVariableMode(mode) ? FROZEN : SEALED; | 9093 IsImmutableVariableMode(mode) ? FROZEN : SEALED; |
9094 Handle<AccessorInfo> info = | 9094 Handle<AccessorInfo> info = |
9095 Accessors::MakeModuleExport(name, index, attr); | 9095 Accessors::MakeModuleExport(name, index, attr); |
9096 Handle<Object> result = | 9096 Handle<Object> result = |
9097 JSObject::SetAccessor(module, info).ToHandleChecked(); | 9097 JSObject::SetAccessor(module, info).ToHandleChecked(); |
9098 ASSERT(!result->IsUndefined()); | 9098 DCHECK(!result->IsUndefined()); |
9099 USE(result); | 9099 USE(result); |
9100 break; | 9100 break; |
9101 } | 9101 } |
9102 case MODULE: { | 9102 case MODULE: { |
9103 Object* referenced_context = Context::cast(host_context)->get(index); | 9103 Object* referenced_context = Context::cast(host_context)->get(index); |
9104 Handle<JSModule> value(Context::cast(referenced_context)->module()); | 9104 Handle<JSModule> value(Context::cast(referenced_context)->module()); |
9105 JSObject::SetOwnPropertyIgnoreAttributes(module, name, value, FROZEN) | 9105 JSObject::SetOwnPropertyIgnoreAttributes(module, name, value, FROZEN) |
9106 .Assert(); | 9106 .Assert(); |
9107 break; | 9107 break; |
9108 } | 9108 } |
9109 case INTERNAL: | 9109 case INTERNAL: |
9110 case TEMPORARY: | 9110 case TEMPORARY: |
9111 case DYNAMIC: | 9111 case DYNAMIC: |
9112 case DYNAMIC_GLOBAL: | 9112 case DYNAMIC_GLOBAL: |
9113 case DYNAMIC_LOCAL: | 9113 case DYNAMIC_LOCAL: |
9114 UNREACHABLE(); | 9114 UNREACHABLE(); |
9115 } | 9115 } |
9116 } | 9116 } |
9117 | 9117 |
9118 JSObject::PreventExtensions(module).Assert(); | 9118 JSObject::PreventExtensions(module).Assert(); |
9119 } | 9119 } |
9120 | 9120 |
9121 ASSERT(!isolate->has_pending_exception()); | 9121 DCHECK(!isolate->has_pending_exception()); |
9122 return isolate->heap()->undefined_value(); | 9122 return isolate->heap()->undefined_value(); |
9123 } | 9123 } |
9124 | 9124 |
9125 | 9125 |
9126 RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) { | 9126 RUNTIME_FUNCTION(Runtime_DeleteLookupSlot) { |
9127 HandleScope scope(isolate); | 9127 HandleScope scope(isolate); |
9128 ASSERT(args.length() == 2); | 9128 DCHECK(args.length() == 2); |
9129 | 9129 |
9130 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 9130 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
9131 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 9131 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
9132 | 9132 |
9133 int index; | 9133 int index; |
9134 PropertyAttributes attributes; | 9134 PropertyAttributes attributes; |
9135 ContextLookupFlags flags = FOLLOW_CHAINS; | 9135 ContextLookupFlags flags = FOLLOW_CHAINS; |
9136 BindingFlags binding_flags; | 9136 BindingFlags binding_flags; |
9137 Handle<Object> holder = context->Lookup(name, | 9137 Handle<Object> holder = context->Lookup(name, |
9138 flags, | 9138 flags, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9211 (reinterpret_cast<ObjectPair>(x) << 32); | 9211 (reinterpret_cast<ObjectPair>(x) << 32); |
9212 #else | 9212 #else |
9213 #error Unknown endianness | 9213 #error Unknown endianness |
9214 #endif | 9214 #endif |
9215 } | 9215 } |
9216 #endif | 9216 #endif |
9217 | 9217 |
9218 | 9218 |
9219 static Object* ComputeReceiverForNonGlobal(Isolate* isolate, | 9219 static Object* ComputeReceiverForNonGlobal(Isolate* isolate, |
9220 JSObject* holder) { | 9220 JSObject* holder) { |
9221 ASSERT(!holder->IsGlobalObject()); | 9221 DCHECK(!holder->IsGlobalObject()); |
9222 Context* top = isolate->context(); | 9222 Context* top = isolate->context(); |
9223 // Get the context extension function. | 9223 // Get the context extension function. |
9224 JSFunction* context_extension_function = | 9224 JSFunction* context_extension_function = |
9225 top->native_context()->context_extension_function(); | 9225 top->native_context()->context_extension_function(); |
9226 // If the holder isn't a context extension object, we just return it | 9226 // If the holder isn't a context extension object, we just return it |
9227 // as the receiver. This allows arguments objects to be used as | 9227 // as the receiver. This allows arguments objects to be used as |
9228 // receivers, but only if they are put in the context scope chain | 9228 // receivers, but only if they are put in the context scope chain |
9229 // explicitly via a with-statement. | 9229 // explicitly via a with-statement. |
9230 Object* constructor = holder->map()->constructor(); | 9230 Object* constructor = holder->map()->constructor(); |
9231 if (constructor != context_extension_function) return holder; | 9231 if (constructor != context_extension_function) return holder; |
9232 // Fall back to using the global object as the implicit receiver if | 9232 // Fall back to using the global object as the implicit receiver if |
9233 // the property turns out to be a local variable allocated in a | 9233 // the property turns out to be a local variable allocated in a |
9234 // context extension object - introduced via eval. | 9234 // context extension object - introduced via eval. |
9235 return isolate->heap()->undefined_value(); | 9235 return isolate->heap()->undefined_value(); |
9236 } | 9236 } |
9237 | 9237 |
9238 | 9238 |
9239 static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate, | 9239 static ObjectPair LoadLookupSlotHelper(Arguments args, Isolate* isolate, |
9240 bool throw_error) { | 9240 bool throw_error) { |
9241 HandleScope scope(isolate); | 9241 HandleScope scope(isolate); |
9242 ASSERT_EQ(2, args.length()); | 9242 DCHECK_EQ(2, args.length()); |
9243 | 9243 |
9244 if (!args[0]->IsContext() || !args[1]->IsString()) { | 9244 if (!args[0]->IsContext() || !args[1]->IsString()) { |
9245 return MakePair(isolate->ThrowIllegalOperation(), NULL); | 9245 return MakePair(isolate->ThrowIllegalOperation(), NULL); |
9246 } | 9246 } |
9247 Handle<Context> context = args.at<Context>(0); | 9247 Handle<Context> context = args.at<Context>(0); |
9248 Handle<String> name = args.at<String>(1); | 9248 Handle<String> name = args.at<String>(1); |
9249 | 9249 |
9250 int index; | 9250 int index; |
9251 PropertyAttributes attributes; | 9251 PropertyAttributes attributes; |
9252 ContextLookupFlags flags = FOLLOW_CHAINS; | 9252 ContextLookupFlags flags = FOLLOW_CHAINS; |
9253 BindingFlags binding_flags; | 9253 BindingFlags binding_flags; |
9254 Handle<Object> holder = context->Lookup(name, | 9254 Handle<Object> holder = context->Lookup(name, |
9255 flags, | 9255 flags, |
9256 &index, | 9256 &index, |
9257 &attributes, | 9257 &attributes, |
9258 &binding_flags); | 9258 &binding_flags); |
9259 if (isolate->has_pending_exception()) { | 9259 if (isolate->has_pending_exception()) { |
9260 return MakePair(isolate->heap()->exception(), NULL); | 9260 return MakePair(isolate->heap()->exception(), NULL); |
9261 } | 9261 } |
9262 | 9262 |
9263 // If the index is non-negative, the slot has been found in a context. | 9263 // If the index is non-negative, the slot has been found in a context. |
9264 if (index >= 0) { | 9264 if (index >= 0) { |
9265 ASSERT(holder->IsContext()); | 9265 DCHECK(holder->IsContext()); |
9266 // If the "property" we were looking for is a local variable, the | 9266 // If the "property" we were looking for is a local variable, the |
9267 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. | 9267 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. |
9268 Handle<Object> receiver = isolate->factory()->undefined_value(); | 9268 Handle<Object> receiver = isolate->factory()->undefined_value(); |
9269 Object* value = Context::cast(*holder)->get(index); | 9269 Object* value = Context::cast(*holder)->get(index); |
9270 // Check for uninitialized bindings. | 9270 // Check for uninitialized bindings. |
9271 switch (binding_flags) { | 9271 switch (binding_flags) { |
9272 case MUTABLE_CHECK_INITIALIZED: | 9272 case MUTABLE_CHECK_INITIALIZED: |
9273 case IMMUTABLE_CHECK_INITIALIZED_HARMONY: | 9273 case IMMUTABLE_CHECK_INITIALIZED_HARMONY: |
9274 if (value->IsTheHole()) { | 9274 if (value->IsTheHole()) { |
9275 Handle<Object> reference_error = | 9275 Handle<Object> reference_error = |
9276 isolate->factory()->NewReferenceError("not_defined", | 9276 isolate->factory()->NewReferenceError("not_defined", |
9277 HandleVector(&name, 1)); | 9277 HandleVector(&name, 1)); |
9278 return MakePair(isolate->Throw(*reference_error), NULL); | 9278 return MakePair(isolate->Throw(*reference_error), NULL); |
9279 } | 9279 } |
9280 // FALLTHROUGH | 9280 // FALLTHROUGH |
9281 case MUTABLE_IS_INITIALIZED: | 9281 case MUTABLE_IS_INITIALIZED: |
9282 case IMMUTABLE_IS_INITIALIZED: | 9282 case IMMUTABLE_IS_INITIALIZED: |
9283 case IMMUTABLE_IS_INITIALIZED_HARMONY: | 9283 case IMMUTABLE_IS_INITIALIZED_HARMONY: |
9284 ASSERT(!value->IsTheHole()); | 9284 DCHECK(!value->IsTheHole()); |
9285 return MakePair(value, *receiver); | 9285 return MakePair(value, *receiver); |
9286 case IMMUTABLE_CHECK_INITIALIZED: | 9286 case IMMUTABLE_CHECK_INITIALIZED: |
9287 if (value->IsTheHole()) { | 9287 if (value->IsTheHole()) { |
9288 ASSERT((attributes & READ_ONLY) != 0); | 9288 DCHECK((attributes & READ_ONLY) != 0); |
9289 value = isolate->heap()->undefined_value(); | 9289 value = isolate->heap()->undefined_value(); |
9290 } | 9290 } |
9291 return MakePair(value, *receiver); | 9291 return MakePair(value, *receiver); |
9292 case MISSING_BINDING: | 9292 case MISSING_BINDING: |
9293 UNREACHABLE(); | 9293 UNREACHABLE(); |
9294 return MakePair(NULL, NULL); | 9294 return MakePair(NULL, NULL); |
9295 } | 9295 } |
9296 } | 9296 } |
9297 | 9297 |
9298 // Otherwise, if the slot was found the holder is a context extension | 9298 // Otherwise, if the slot was found the holder is a context extension |
9299 // object, subject of a with, or a global object. We read the named | 9299 // object, subject of a with, or a global object. We read the named |
9300 // property from it. | 9300 // property from it. |
9301 if (!holder.is_null()) { | 9301 if (!holder.is_null()) { |
9302 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); | 9302 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); |
9303 #ifdef DEBUG | 9303 #ifdef DEBUG |
9304 if (!object->IsJSProxy()) { | 9304 if (!object->IsJSProxy()) { |
9305 Maybe<bool> maybe = JSReceiver::HasProperty(object, name); | 9305 Maybe<bool> maybe = JSReceiver::HasProperty(object, name); |
9306 ASSERT(maybe.has_value); | 9306 DCHECK(maybe.has_value); |
9307 ASSERT(maybe.value); | 9307 DCHECK(maybe.value); |
9308 } | 9308 } |
9309 #endif | 9309 #endif |
9310 // GetProperty below can cause GC. | 9310 // GetProperty below can cause GC. |
9311 Handle<Object> receiver_handle( | 9311 Handle<Object> receiver_handle( |
9312 object->IsGlobalObject() | 9312 object->IsGlobalObject() |
9313 ? Object::cast(isolate->heap()->undefined_value()) | 9313 ? Object::cast(isolate->heap()->undefined_value()) |
9314 : object->IsJSProxy() ? static_cast<Object*>(*object) | 9314 : object->IsJSProxy() ? static_cast<Object*>(*object) |
9315 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), | 9315 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), |
9316 isolate); | 9316 isolate); |
9317 | 9317 |
(...skipping 26 matching lines...) Expand all Loading... |
9344 } | 9344 } |
9345 | 9345 |
9346 | 9346 |
9347 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlotNoReferenceError) { | 9347 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_LoadLookupSlotNoReferenceError) { |
9348 return LoadLookupSlotHelper(args, isolate, false); | 9348 return LoadLookupSlotHelper(args, isolate, false); |
9349 } | 9349 } |
9350 | 9350 |
9351 | 9351 |
9352 RUNTIME_FUNCTION(Runtime_StoreLookupSlot) { | 9352 RUNTIME_FUNCTION(Runtime_StoreLookupSlot) { |
9353 HandleScope scope(isolate); | 9353 HandleScope scope(isolate); |
9354 ASSERT(args.length() == 4); | 9354 DCHECK(args.length() == 4); |
9355 | 9355 |
9356 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 9356 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
9357 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); | 9357 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); |
9358 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 9358 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
9359 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); | 9359 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); |
9360 | 9360 |
9361 int index; | 9361 int index; |
9362 PropertyAttributes attributes; | 9362 PropertyAttributes attributes; |
9363 ContextLookupFlags flags = FOLLOW_CHAINS; | 9363 ContextLookupFlags flags = FOLLOW_CHAINS; |
9364 BindingFlags binding_flags; | 9364 BindingFlags binding_flags; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9403 | 9403 |
9404 RETURN_FAILURE_ON_EXCEPTION( | 9404 RETURN_FAILURE_ON_EXCEPTION( |
9405 isolate, Object::SetProperty(object, name, value, strict_mode)); | 9405 isolate, Object::SetProperty(object, name, value, strict_mode)); |
9406 | 9406 |
9407 return *value; | 9407 return *value; |
9408 } | 9408 } |
9409 | 9409 |
9410 | 9410 |
9411 RUNTIME_FUNCTION(Runtime_Throw) { | 9411 RUNTIME_FUNCTION(Runtime_Throw) { |
9412 HandleScope scope(isolate); | 9412 HandleScope scope(isolate); |
9413 ASSERT(args.length() == 1); | 9413 DCHECK(args.length() == 1); |
9414 | 9414 |
9415 return isolate->Throw(args[0]); | 9415 return isolate->Throw(args[0]); |
9416 } | 9416 } |
9417 | 9417 |
9418 | 9418 |
9419 RUNTIME_FUNCTION(Runtime_ReThrow) { | 9419 RUNTIME_FUNCTION(Runtime_ReThrow) { |
9420 HandleScope scope(isolate); | 9420 HandleScope scope(isolate); |
9421 ASSERT(args.length() == 1); | 9421 DCHECK(args.length() == 1); |
9422 | 9422 |
9423 return isolate->ReThrow(args[0]); | 9423 return isolate->ReThrow(args[0]); |
9424 } | 9424 } |
9425 | 9425 |
9426 | 9426 |
9427 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { | 9427 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { |
9428 SealHandleScope shs(isolate); | 9428 SealHandleScope shs(isolate); |
9429 ASSERT(args.length() == 0); | 9429 DCHECK(args.length() == 0); |
9430 return isolate->PromoteScheduledException(); | 9430 return isolate->PromoteScheduledException(); |
9431 } | 9431 } |
9432 | 9432 |
9433 | 9433 |
9434 RUNTIME_FUNCTION(Runtime_ThrowReferenceError) { | 9434 RUNTIME_FUNCTION(Runtime_ThrowReferenceError) { |
9435 HandleScope scope(isolate); | 9435 HandleScope scope(isolate); |
9436 ASSERT(args.length() == 1); | 9436 DCHECK(args.length() == 1); |
9437 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 9437 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
9438 Handle<Object> reference_error = | 9438 Handle<Object> reference_error = |
9439 isolate->factory()->NewReferenceError("not_defined", | 9439 isolate->factory()->NewReferenceError("not_defined", |
9440 HandleVector(&name, 1)); | 9440 HandleVector(&name, 1)); |
9441 return isolate->Throw(*reference_error); | 9441 return isolate->Throw(*reference_error); |
9442 } | 9442 } |
9443 | 9443 |
9444 | 9444 |
9445 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { | 9445 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { |
9446 HandleScope scope(isolate); | 9446 HandleScope scope(isolate); |
9447 ASSERT(args.length() == 0); | 9447 DCHECK(args.length() == 0); |
9448 return isolate->Throw(*isolate->factory()->NewTypeError( | 9448 return isolate->Throw(*isolate->factory()->NewTypeError( |
9449 "not_date_object", HandleVector<Object>(NULL, 0))); | 9449 "not_date_object", HandleVector<Object>(NULL, 0))); |
9450 } | 9450 } |
9451 | 9451 |
9452 | 9452 |
9453 RUNTIME_FUNCTION(Runtime_StackGuard) { | 9453 RUNTIME_FUNCTION(Runtime_StackGuard) { |
9454 SealHandleScope shs(isolate); | 9454 SealHandleScope shs(isolate); |
9455 ASSERT(args.length() == 0); | 9455 DCHECK(args.length() == 0); |
9456 | 9456 |
9457 // First check if this is a real stack overflow. | 9457 // First check if this is a real stack overflow. |
9458 StackLimitCheck check(isolate); | 9458 StackLimitCheck check(isolate); |
9459 if (check.JsHasOverflowed()) { | 9459 if (check.JsHasOverflowed()) { |
9460 return isolate->StackOverflow(); | 9460 return isolate->StackOverflow(); |
9461 } | 9461 } |
9462 | 9462 |
9463 return isolate->stack_guard()->HandleInterrupts(); | 9463 return isolate->stack_guard()->HandleInterrupts(); |
9464 } | 9464 } |
9465 | 9465 |
9466 | 9466 |
9467 RUNTIME_FUNCTION(Runtime_TryInstallOptimizedCode) { | 9467 RUNTIME_FUNCTION(Runtime_TryInstallOptimizedCode) { |
9468 HandleScope scope(isolate); | 9468 HandleScope scope(isolate); |
9469 ASSERT(args.length() == 1); | 9469 DCHECK(args.length() == 1); |
9470 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 9470 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
9471 | 9471 |
9472 // First check if this is a real stack overflow. | 9472 // First check if this is a real stack overflow. |
9473 StackLimitCheck check(isolate); | 9473 StackLimitCheck check(isolate); |
9474 if (check.JsHasOverflowed()) { | 9474 if (check.JsHasOverflowed()) { |
9475 SealHandleScope shs(isolate); | 9475 SealHandleScope shs(isolate); |
9476 return isolate->StackOverflow(); | 9476 return isolate->StackOverflow(); |
9477 } | 9477 } |
9478 | 9478 |
9479 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 9479 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
9480 return (function->IsOptimized()) ? function->code() | 9480 return (function->IsOptimized()) ? function->code() |
9481 : function->shared()->code(); | 9481 : function->shared()->code(); |
9482 } | 9482 } |
9483 | 9483 |
9484 | 9484 |
9485 RUNTIME_FUNCTION(Runtime_Interrupt) { | 9485 RUNTIME_FUNCTION(Runtime_Interrupt) { |
9486 SealHandleScope shs(isolate); | 9486 SealHandleScope shs(isolate); |
9487 ASSERT(args.length() == 0); | 9487 DCHECK(args.length() == 0); |
9488 return isolate->stack_guard()->HandleInterrupts(); | 9488 return isolate->stack_guard()->HandleInterrupts(); |
9489 } | 9489 } |
9490 | 9490 |
9491 | 9491 |
9492 static int StackSize(Isolate* isolate) { | 9492 static int StackSize(Isolate* isolate) { |
9493 int n = 0; | 9493 int n = 0; |
9494 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; | 9494 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; |
9495 return n; | 9495 return n; |
9496 } | 9496 } |
9497 | 9497 |
(...skipping 15 matching lines...) Expand all Loading... |
9513 // function result | 9513 // function result |
9514 PrintF("} -> "); | 9514 PrintF("} -> "); |
9515 result->ShortPrint(); | 9515 result->ShortPrint(); |
9516 PrintF("\n"); | 9516 PrintF("\n"); |
9517 } | 9517 } |
9518 } | 9518 } |
9519 | 9519 |
9520 | 9520 |
9521 RUNTIME_FUNCTION(Runtime_TraceEnter) { | 9521 RUNTIME_FUNCTION(Runtime_TraceEnter) { |
9522 SealHandleScope shs(isolate); | 9522 SealHandleScope shs(isolate); |
9523 ASSERT(args.length() == 0); | 9523 DCHECK(args.length() == 0); |
9524 PrintTransition(isolate, NULL); | 9524 PrintTransition(isolate, NULL); |
9525 return isolate->heap()->undefined_value(); | 9525 return isolate->heap()->undefined_value(); |
9526 } | 9526 } |
9527 | 9527 |
9528 | 9528 |
9529 RUNTIME_FUNCTION(Runtime_TraceExit) { | 9529 RUNTIME_FUNCTION(Runtime_TraceExit) { |
9530 SealHandleScope shs(isolate); | 9530 SealHandleScope shs(isolate); |
9531 ASSERT(args.length() == 1); | 9531 DCHECK(args.length() == 1); |
9532 CONVERT_ARG_CHECKED(Object, obj, 0); | 9532 CONVERT_ARG_CHECKED(Object, obj, 0); |
9533 PrintTransition(isolate, obj); | 9533 PrintTransition(isolate, obj); |
9534 return obj; // return TOS | 9534 return obj; // return TOS |
9535 } | 9535 } |
9536 | 9536 |
9537 | 9537 |
9538 RUNTIME_FUNCTION(Runtime_DebugPrint) { | 9538 RUNTIME_FUNCTION(Runtime_DebugPrint) { |
9539 SealHandleScope shs(isolate); | 9539 SealHandleScope shs(isolate); |
9540 ASSERT(args.length() == 1); | 9540 DCHECK(args.length() == 1); |
9541 | 9541 |
9542 OFStream os(stdout); | 9542 OFStream os(stdout); |
9543 #ifdef DEBUG | 9543 #ifdef DEBUG |
9544 if (args[0]->IsString()) { | 9544 if (args[0]->IsString()) { |
9545 // If we have a string, assume it's a code "marker" | 9545 // If we have a string, assume it's a code "marker" |
9546 // and print some interesting cpu debugging info. | 9546 // and print some interesting cpu debugging info. |
9547 JavaScriptFrameIterator it(isolate); | 9547 JavaScriptFrameIterator it(isolate); |
9548 JavaScriptFrame* frame = it.frame(); | 9548 JavaScriptFrame* frame = it.frame(); |
9549 os << "fp = " << frame->fp() << ", sp = " << frame->sp() | 9549 os << "fp = " << frame->fp() << ", sp = " << frame->sp() |
9550 << ", caller_sp = " << frame->caller_sp() << ": "; | 9550 << ", caller_sp = " << frame->caller_sp() << ": "; |
(...skipping 10 matching lines...) Expand all Loading... |
9561 os << Brief(args[0]); | 9561 os << Brief(args[0]); |
9562 #endif | 9562 #endif |
9563 os << endl; | 9563 os << endl; |
9564 | 9564 |
9565 return args[0]; // return TOS | 9565 return args[0]; // return TOS |
9566 } | 9566 } |
9567 | 9567 |
9568 | 9568 |
9569 RUNTIME_FUNCTION(Runtime_DebugTrace) { | 9569 RUNTIME_FUNCTION(Runtime_DebugTrace) { |
9570 SealHandleScope shs(isolate); | 9570 SealHandleScope shs(isolate); |
9571 ASSERT(args.length() == 0); | 9571 DCHECK(args.length() == 0); |
9572 isolate->PrintStack(stdout); | 9572 isolate->PrintStack(stdout); |
9573 return isolate->heap()->undefined_value(); | 9573 return isolate->heap()->undefined_value(); |
9574 } | 9574 } |
9575 | 9575 |
9576 | 9576 |
9577 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { | 9577 RUNTIME_FUNCTION(Runtime_DateCurrentTime) { |
9578 HandleScope scope(isolate); | 9578 HandleScope scope(isolate); |
9579 ASSERT(args.length() == 0); | 9579 DCHECK(args.length() == 0); |
9580 if (FLAG_log_timer_events) LOG(isolate, CurrentTimeEvent()); | 9580 if (FLAG_log_timer_events) LOG(isolate, CurrentTimeEvent()); |
9581 | 9581 |
9582 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9582 // According to ECMA-262, section 15.9.1, page 117, the precision of |
9583 // the number in a Date object representing a particular instant in | 9583 // the number in a Date object representing a particular instant in |
9584 // time is milliseconds. Therefore, we floor the result of getting | 9584 // time is milliseconds. Therefore, we floor the result of getting |
9585 // the OS time. | 9585 // the OS time. |
9586 double millis; | 9586 double millis; |
9587 if (FLAG_verify_predictable) { | 9587 if (FLAG_verify_predictable) { |
9588 millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 | 9588 millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 |
9589 millis += Floor(isolate->heap()->synthetic_time()); | 9589 millis += Floor(isolate->heap()->synthetic_time()); |
9590 } else { | 9590 } else { |
9591 millis = Floor(base::OS::TimeCurrentMillis()); | 9591 millis = Floor(base::OS::TimeCurrentMillis()); |
9592 } | 9592 } |
9593 return *isolate->factory()->NewNumber(millis); | 9593 return *isolate->factory()->NewNumber(millis); |
9594 } | 9594 } |
9595 | 9595 |
9596 | 9596 |
9597 RUNTIME_FUNCTION(Runtime_DateParseString) { | 9597 RUNTIME_FUNCTION(Runtime_DateParseString) { |
9598 HandleScope scope(isolate); | 9598 HandleScope scope(isolate); |
9599 ASSERT(args.length() == 2); | 9599 DCHECK(args.length() == 2); |
9600 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 9600 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
9601 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); | 9601 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); |
9602 | 9602 |
9603 RUNTIME_ASSERT(output->HasFastElements()); | 9603 RUNTIME_ASSERT(output->HasFastElements()); |
9604 JSObject::EnsureCanContainHeapObjectElements(output); | 9604 JSObject::EnsureCanContainHeapObjectElements(output); |
9605 RUNTIME_ASSERT(output->HasFastObjectElements()); | 9605 RUNTIME_ASSERT(output->HasFastObjectElements()); |
9606 Handle<FixedArray> output_array(FixedArray::cast(output->elements())); | 9606 Handle<FixedArray> output_array(FixedArray::cast(output->elements())); |
9607 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); | 9607 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); |
9608 | 9608 |
9609 str = String::Flatten(str); | 9609 str = String::Flatten(str); |
9610 DisallowHeapAllocation no_gc; | 9610 DisallowHeapAllocation no_gc; |
9611 | 9611 |
9612 bool result; | 9612 bool result; |
9613 String::FlatContent str_content = str->GetFlatContent(); | 9613 String::FlatContent str_content = str->GetFlatContent(); |
9614 if (str_content.IsAscii()) { | 9614 if (str_content.IsAscii()) { |
9615 result = DateParser::Parse(str_content.ToOneByteVector(), | 9615 result = DateParser::Parse(str_content.ToOneByteVector(), |
9616 *output_array, | 9616 *output_array, |
9617 isolate->unicode_cache()); | 9617 isolate->unicode_cache()); |
9618 } else { | 9618 } else { |
9619 ASSERT(str_content.IsTwoByte()); | 9619 DCHECK(str_content.IsTwoByte()); |
9620 result = DateParser::Parse(str_content.ToUC16Vector(), | 9620 result = DateParser::Parse(str_content.ToUC16Vector(), |
9621 *output_array, | 9621 *output_array, |
9622 isolate->unicode_cache()); | 9622 isolate->unicode_cache()); |
9623 } | 9623 } |
9624 | 9624 |
9625 if (result) { | 9625 if (result) { |
9626 return *output; | 9626 return *output; |
9627 } else { | 9627 } else { |
9628 return isolate->heap()->null_value(); | 9628 return isolate->heap()->null_value(); |
9629 } | 9629 } |
9630 } | 9630 } |
9631 | 9631 |
9632 | 9632 |
9633 RUNTIME_FUNCTION(Runtime_DateLocalTimezone) { | 9633 RUNTIME_FUNCTION(Runtime_DateLocalTimezone) { |
9634 HandleScope scope(isolate); | 9634 HandleScope scope(isolate); |
9635 ASSERT(args.length() == 1); | 9635 DCHECK(args.length() == 1); |
9636 | 9636 |
9637 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9637 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9638 RUNTIME_ASSERT(x >= -DateCache::kMaxTimeBeforeUTCInMs && | 9638 RUNTIME_ASSERT(x >= -DateCache::kMaxTimeBeforeUTCInMs && |
9639 x <= DateCache::kMaxTimeBeforeUTCInMs); | 9639 x <= DateCache::kMaxTimeBeforeUTCInMs); |
9640 const char* zone = | 9640 const char* zone = |
9641 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); | 9641 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); |
9642 Handle<String> result = isolate->factory()->NewStringFromUtf8( | 9642 Handle<String> result = isolate->factory()->NewStringFromUtf8( |
9643 CStrVector(zone)).ToHandleChecked(); | 9643 CStrVector(zone)).ToHandleChecked(); |
9644 return *result; | 9644 return *result; |
9645 } | 9645 } |
9646 | 9646 |
9647 | 9647 |
9648 RUNTIME_FUNCTION(Runtime_DateToUTC) { | 9648 RUNTIME_FUNCTION(Runtime_DateToUTC) { |
9649 HandleScope scope(isolate); | 9649 HandleScope scope(isolate); |
9650 ASSERT(args.length() == 1); | 9650 DCHECK(args.length() == 1); |
9651 | 9651 |
9652 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9652 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9653 RUNTIME_ASSERT(x >= -DateCache::kMaxTimeBeforeUTCInMs && | 9653 RUNTIME_ASSERT(x >= -DateCache::kMaxTimeBeforeUTCInMs && |
9654 x <= DateCache::kMaxTimeBeforeUTCInMs); | 9654 x <= DateCache::kMaxTimeBeforeUTCInMs); |
9655 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9655 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
9656 | 9656 |
9657 return *isolate->factory()->NewNumber(static_cast<double>(time)); | 9657 return *isolate->factory()->NewNumber(static_cast<double>(time)); |
9658 } | 9658 } |
9659 | 9659 |
9660 | 9660 |
9661 RUNTIME_FUNCTION(Runtime_DateCacheVersion) { | 9661 RUNTIME_FUNCTION(Runtime_DateCacheVersion) { |
9662 HandleScope hs(isolate); | 9662 HandleScope hs(isolate); |
9663 ASSERT(args.length() == 0); | 9663 DCHECK(args.length() == 0); |
9664 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { | 9664 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { |
9665 Handle<FixedArray> date_cache_version = | 9665 Handle<FixedArray> date_cache_version = |
9666 isolate->factory()->NewFixedArray(1, TENURED); | 9666 isolate->factory()->NewFixedArray(1, TENURED); |
9667 date_cache_version->set(0, Smi::FromInt(0)); | 9667 date_cache_version->set(0, Smi::FromInt(0)); |
9668 isolate->eternal_handles()->CreateSingleton( | 9668 isolate->eternal_handles()->CreateSingleton( |
9669 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); | 9669 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); |
9670 } | 9670 } |
9671 Handle<FixedArray> date_cache_version = | 9671 Handle<FixedArray> date_cache_version = |
9672 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 9672 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
9673 EternalHandles::DATE_CACHE_VERSION)); | 9673 EternalHandles::DATE_CACHE_VERSION)); |
9674 // Return result as a JS array. | 9674 // Return result as a JS array. |
9675 Handle<JSObject> result = | 9675 Handle<JSObject> result = |
9676 isolate->factory()->NewJSObject(isolate->array_function()); | 9676 isolate->factory()->NewJSObject(isolate->array_function()); |
9677 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); | 9677 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); |
9678 return *result; | 9678 return *result; |
9679 } | 9679 } |
9680 | 9680 |
9681 | 9681 |
9682 RUNTIME_FUNCTION(Runtime_GlobalProxy) { | 9682 RUNTIME_FUNCTION(Runtime_GlobalProxy) { |
9683 SealHandleScope shs(isolate); | 9683 SealHandleScope shs(isolate); |
9684 ASSERT(args.length() == 1); | 9684 DCHECK(args.length() == 1); |
9685 CONVERT_ARG_CHECKED(Object, global, 0); | 9685 CONVERT_ARG_CHECKED(Object, global, 0); |
9686 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9686 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
9687 return JSGlobalObject::cast(global)->global_proxy(); | 9687 return JSGlobalObject::cast(global)->global_proxy(); |
9688 } | 9688 } |
9689 | 9689 |
9690 | 9690 |
9691 RUNTIME_FUNCTION(Runtime_IsAttachedGlobal) { | 9691 RUNTIME_FUNCTION(Runtime_IsAttachedGlobal) { |
9692 SealHandleScope shs(isolate); | 9692 SealHandleScope shs(isolate); |
9693 ASSERT(args.length() == 1); | 9693 DCHECK(args.length() == 1); |
9694 CONVERT_ARG_CHECKED(Object, global, 0); | 9694 CONVERT_ARG_CHECKED(Object, global, 0); |
9695 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); | 9695 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); |
9696 return isolate->heap()->ToBoolean( | 9696 return isolate->heap()->ToBoolean( |
9697 !JSGlobalObject::cast(global)->IsDetached()); | 9697 !JSGlobalObject::cast(global)->IsDetached()); |
9698 } | 9698 } |
9699 | 9699 |
9700 | 9700 |
9701 RUNTIME_FUNCTION(Runtime_ParseJson) { | 9701 RUNTIME_FUNCTION(Runtime_ParseJson) { |
9702 HandleScope scope(isolate); | 9702 HandleScope scope(isolate); |
9703 ASSERT(args.length() == 1); | 9703 DCHECK(args.length() == 1); |
9704 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9704 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
9705 | 9705 |
9706 source = String::Flatten(source); | 9706 source = String::Flatten(source); |
9707 // Optimized fast case where we only have ASCII characters. | 9707 // Optimized fast case where we only have ASCII characters. |
9708 Handle<Object> result; | 9708 Handle<Object> result; |
9709 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 9709 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
9710 isolate, result, | 9710 isolate, result, |
9711 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source) | 9711 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source) |
9712 : JsonParser<false>::Parse(source)); | 9712 : JsonParser<false>::Parse(source)); |
9713 return *result; | 9713 return *result; |
9714 } | 9714 } |
9715 | 9715 |
9716 | 9716 |
9717 bool CodeGenerationFromStringsAllowed(Isolate* isolate, | 9717 bool CodeGenerationFromStringsAllowed(Isolate* isolate, |
9718 Handle<Context> context) { | 9718 Handle<Context> context) { |
9719 ASSERT(context->allow_code_gen_from_strings()->IsFalse()); | 9719 DCHECK(context->allow_code_gen_from_strings()->IsFalse()); |
9720 // Check with callback if set. | 9720 // Check with callback if set. |
9721 AllowCodeGenerationFromStringsCallback callback = | 9721 AllowCodeGenerationFromStringsCallback callback = |
9722 isolate->allow_code_gen_callback(); | 9722 isolate->allow_code_gen_callback(); |
9723 if (callback == NULL) { | 9723 if (callback == NULL) { |
9724 // No callback set and code generation disallowed. | 9724 // No callback set and code generation disallowed. |
9725 return false; | 9725 return false; |
9726 } else { | 9726 } else { |
9727 // Callback set. Let it decide if code generation is allowed. | 9727 // Callback set. Let it decide if code generation is allowed. |
9728 VMState<EXTERNAL> state(isolate); | 9728 VMState<EXTERNAL> state(isolate); |
9729 return callback(v8::Utils::ToLocal(context)); | 9729 return callback(v8::Utils::ToLocal(context)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9779 } | 9779 } |
9780 done = true; | 9780 done = true; |
9781 } | 9781 } |
9782 } | 9782 } |
9783 return !exit_handled || tokens_match; | 9783 return !exit_handled || tokens_match; |
9784 } | 9784 } |
9785 | 9785 |
9786 | 9786 |
9787 RUNTIME_FUNCTION(Runtime_CompileString) { | 9787 RUNTIME_FUNCTION(Runtime_CompileString) { |
9788 HandleScope scope(isolate); | 9788 HandleScope scope(isolate); |
9789 ASSERT(args.length() == 2); | 9789 DCHECK(args.length() == 2); |
9790 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9790 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
9791 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); | 9791 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); |
9792 | 9792 |
9793 // Extract native context. | 9793 // Extract native context. |
9794 Handle<Context> context(isolate->native_context()); | 9794 Handle<Context> context(isolate->native_context()); |
9795 | 9795 |
9796 // Filter cross security context calls. | 9796 // Filter cross security context calls. |
9797 if (!TokensMatchForCompileString(isolate)) { | 9797 if (!TokensMatchForCompileString(isolate)) { |
9798 return isolate->heap()->undefined_value(); | 9798 return isolate->heap()->undefined_value(); |
9799 } | 9799 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9847 isolate, compiled, | 9847 isolate, compiled, |
9848 Compiler::GetFunctionFromEval( | 9848 Compiler::GetFunctionFromEval( |
9849 source, context, strict_mode, restriction, scope_position), | 9849 source, context, strict_mode, restriction, scope_position), |
9850 MakePair(isolate->heap()->exception(), NULL)); | 9850 MakePair(isolate->heap()->exception(), NULL)); |
9851 return MakePair(*compiled, *receiver); | 9851 return MakePair(*compiled, *receiver); |
9852 } | 9852 } |
9853 | 9853 |
9854 | 9854 |
9855 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ResolvePossiblyDirectEval) { | 9855 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ResolvePossiblyDirectEval) { |
9856 HandleScope scope(isolate); | 9856 HandleScope scope(isolate); |
9857 ASSERT(args.length() == 5); | 9857 DCHECK(args.length() == 5); |
9858 | 9858 |
9859 Handle<Object> callee = args.at<Object>(0); | 9859 Handle<Object> callee = args.at<Object>(0); |
9860 | 9860 |
9861 // If "eval" didn't refer to the original GlobalEval, it's not a | 9861 // If "eval" didn't refer to the original GlobalEval, it's not a |
9862 // direct call to eval. | 9862 // direct call to eval. |
9863 // (And even if it is, but the first argument isn't a string, just let | 9863 // (And even if it is, but the first argument isn't a string, just let |
9864 // execution default to an indirect call to eval, which will also return | 9864 // execution default to an indirect call to eval, which will also return |
9865 // the first argument without doing anything). | 9865 // the first argument without doing anything). |
9866 if (*callee != isolate->native_context()->global_eval_fun() || | 9866 if (*callee != isolate->native_context()->global_eval_fun() || |
9867 !args[1]->IsString()) { | 9867 !args[1]->IsString()) { |
9868 return MakePair(*callee, isolate->heap()->undefined_value()); | 9868 return MakePair(*callee, isolate->heap()->undefined_value()); |
9869 } | 9869 } |
9870 | 9870 |
9871 ASSERT(args[3]->IsSmi()); | 9871 DCHECK(args[3]->IsSmi()); |
9872 ASSERT(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT); | 9872 DCHECK(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT); |
9873 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); | 9873 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); |
9874 ASSERT(args[4]->IsSmi()); | 9874 DCHECK(args[4]->IsSmi()); |
9875 return CompileGlobalEval(isolate, | 9875 return CompileGlobalEval(isolate, |
9876 args.at<String>(1), | 9876 args.at<String>(1), |
9877 args.at<Object>(2), | 9877 args.at<Object>(2), |
9878 strict_mode, | 9878 strict_mode, |
9879 args.smi_at(4)); | 9879 args.smi_at(4)); |
9880 } | 9880 } |
9881 | 9881 |
9882 | 9882 |
9883 RUNTIME_FUNCTION(Runtime_AllocateInNewSpace) { | 9883 RUNTIME_FUNCTION(Runtime_AllocateInNewSpace) { |
9884 HandleScope scope(isolate); | 9884 HandleScope scope(isolate); |
9885 ASSERT(args.length() == 1); | 9885 DCHECK(args.length() == 1); |
9886 CONVERT_SMI_ARG_CHECKED(size, 0); | 9886 CONVERT_SMI_ARG_CHECKED(size, 0); |
9887 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9887 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
9888 RUNTIME_ASSERT(size > 0); | 9888 RUNTIME_ASSERT(size > 0); |
9889 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9889 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
9890 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); | 9890 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); |
9891 } | 9891 } |
9892 | 9892 |
9893 | 9893 |
9894 RUNTIME_FUNCTION(Runtime_AllocateInTargetSpace) { | 9894 RUNTIME_FUNCTION(Runtime_AllocateInTargetSpace) { |
9895 HandleScope scope(isolate); | 9895 HandleScope scope(isolate); |
9896 ASSERT(args.length() == 2); | 9896 DCHECK(args.length() == 2); |
9897 CONVERT_SMI_ARG_CHECKED(size, 0); | 9897 CONVERT_SMI_ARG_CHECKED(size, 0); |
9898 CONVERT_SMI_ARG_CHECKED(flags, 1); | 9898 CONVERT_SMI_ARG_CHECKED(flags, 1); |
9899 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9899 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
9900 RUNTIME_ASSERT(size > 0); | 9900 RUNTIME_ASSERT(size > 0); |
9901 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9901 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
9902 bool double_align = AllocateDoubleAlignFlag::decode(flags); | 9902 bool double_align = AllocateDoubleAlignFlag::decode(flags); |
9903 AllocationSpace space = AllocateTargetSpace::decode(flags); | 9903 AllocationSpace space = AllocateTargetSpace::decode(flags); |
9904 return *isolate->factory()->NewFillerObject(size, double_align, space); | 9904 return *isolate->factory()->NewFillerObject(size, double_align, space); |
9905 } | 9905 } |
9906 | 9906 |
9907 | 9907 |
9908 // Push an object unto an array of objects if it is not already in the | 9908 // Push an object unto an array of objects if it is not already in the |
9909 // array. Returns true if the element was pushed on the stack and | 9909 // array. Returns true if the element was pushed on the stack and |
9910 // false otherwise. | 9910 // false otherwise. |
9911 RUNTIME_FUNCTION(Runtime_PushIfAbsent) { | 9911 RUNTIME_FUNCTION(Runtime_PushIfAbsent) { |
9912 HandleScope scope(isolate); | 9912 HandleScope scope(isolate); |
9913 ASSERT(args.length() == 2); | 9913 DCHECK(args.length() == 2); |
9914 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 9914 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
9915 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); | 9915 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); |
9916 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 9916 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
9917 int length = Smi::cast(array->length())->value(); | 9917 int length = Smi::cast(array->length())->value(); |
9918 FixedArray* elements = FixedArray::cast(array->elements()); | 9918 FixedArray* elements = FixedArray::cast(array->elements()); |
9919 for (int i = 0; i < length; i++) { | 9919 for (int i = 0; i < length; i++) { |
9920 if (elements->get(i) == *element) return isolate->heap()->false_value(); | 9920 if (elements->get(i) == *element) return isolate->heap()->false_value(); |
9921 } | 9921 } |
9922 | 9922 |
9923 // Strict not needed. Used for cycle detection in Array join implementation. | 9923 // Strict not needed. Used for cycle detection in Array join implementation. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9967 storage_->set(index, *elm); | 9967 storage_->set(index, *elm); |
9968 return; | 9968 return; |
9969 } | 9969 } |
9970 // Our initial estimate of length was foiled, possibly by | 9970 // Our initial estimate of length was foiled, possibly by |
9971 // getters on the arrays increasing the length of later arrays | 9971 // getters on the arrays increasing the length of later arrays |
9972 // during iteration. | 9972 // during iteration. |
9973 // This shouldn't happen in anything but pathological cases. | 9973 // This shouldn't happen in anything but pathological cases. |
9974 SetDictionaryMode(); | 9974 SetDictionaryMode(); |
9975 // Fall-through to dictionary mode. | 9975 // Fall-through to dictionary mode. |
9976 } | 9976 } |
9977 ASSERT(!fast_elements_); | 9977 DCHECK(!fast_elements_); |
9978 Handle<SeededNumberDictionary> dict( | 9978 Handle<SeededNumberDictionary> dict( |
9979 SeededNumberDictionary::cast(*storage_)); | 9979 SeededNumberDictionary::cast(*storage_)); |
9980 Handle<SeededNumberDictionary> result = | 9980 Handle<SeededNumberDictionary> result = |
9981 SeededNumberDictionary::AtNumberPut(dict, index, elm); | 9981 SeededNumberDictionary::AtNumberPut(dict, index, elm); |
9982 if (!result.is_identical_to(dict)) { | 9982 if (!result.is_identical_to(dict)) { |
9983 // Dictionary needed to grow. | 9983 // Dictionary needed to grow. |
9984 clear_storage(); | 9984 clear_storage(); |
9985 set_storage(*result); | 9985 set_storage(*result); |
9986 } | 9986 } |
9987 } | 9987 } |
(...skipping 27 matching lines...) Expand all Loading... |
10015 fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS); | 10015 fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS); |
10016 array->set_map(*map); | 10016 array->set_map(*map); |
10017 array->set_length(*length); | 10017 array->set_length(*length); |
10018 array->set_elements(*storage_); | 10018 array->set_elements(*storage_); |
10019 return array; | 10019 return array; |
10020 } | 10020 } |
10021 | 10021 |
10022 private: | 10022 private: |
10023 // Convert storage to dictionary mode. | 10023 // Convert storage to dictionary mode. |
10024 void SetDictionaryMode() { | 10024 void SetDictionaryMode() { |
10025 ASSERT(fast_elements_); | 10025 DCHECK(fast_elements_); |
10026 Handle<FixedArray> current_storage(*storage_); | 10026 Handle<FixedArray> current_storage(*storage_); |
10027 Handle<SeededNumberDictionary> slow_storage( | 10027 Handle<SeededNumberDictionary> slow_storage( |
10028 SeededNumberDictionary::New(isolate_, current_storage->length())); | 10028 SeededNumberDictionary::New(isolate_, current_storage->length())); |
10029 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); | 10029 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); |
10030 for (uint32_t i = 0; i < current_length; i++) { | 10030 for (uint32_t i = 0; i < current_length; i++) { |
10031 HandleScope loop_scope(isolate_); | 10031 HandleScope loop_scope(isolate_); |
10032 Handle<Object> element(current_storage->get(i), isolate_); | 10032 Handle<Object> element(current_storage->get(i), isolate_); |
10033 if (!element->IsTheHole()) { | 10033 if (!element->IsTheHole()) { |
10034 Handle<SeededNumberDictionary> new_storage = | 10034 Handle<SeededNumberDictionary> new_storage = |
10035 SeededNumberDictionary::AtNumberPut(slow_storage, i, element); | 10035 SeededNumberDictionary::AtNumberPut(slow_storage, i, element); |
(...skipping 29 matching lines...) Expand all Loading... |
10065 static uint32_t EstimateElementCount(Handle<JSArray> array) { | 10065 static uint32_t EstimateElementCount(Handle<JSArray> array) { |
10066 uint32_t length = static_cast<uint32_t>(array->length()->Number()); | 10066 uint32_t length = static_cast<uint32_t>(array->length()->Number()); |
10067 int element_count = 0; | 10067 int element_count = 0; |
10068 switch (array->GetElementsKind()) { | 10068 switch (array->GetElementsKind()) { |
10069 case FAST_SMI_ELEMENTS: | 10069 case FAST_SMI_ELEMENTS: |
10070 case FAST_HOLEY_SMI_ELEMENTS: | 10070 case FAST_HOLEY_SMI_ELEMENTS: |
10071 case FAST_ELEMENTS: | 10071 case FAST_ELEMENTS: |
10072 case FAST_HOLEY_ELEMENTS: { | 10072 case FAST_HOLEY_ELEMENTS: { |
10073 // Fast elements can't have lengths that are not representable by | 10073 // Fast elements can't have lengths that are not representable by |
10074 // a 32-bit signed integer. | 10074 // a 32-bit signed integer. |
10075 ASSERT(static_cast<int32_t>(FixedArray::kMaxLength) >= 0); | 10075 DCHECK(static_cast<int32_t>(FixedArray::kMaxLength) >= 0); |
10076 int fast_length = static_cast<int>(length); | 10076 int fast_length = static_cast<int>(length); |
10077 Handle<FixedArray> elements(FixedArray::cast(array->elements())); | 10077 Handle<FixedArray> elements(FixedArray::cast(array->elements())); |
10078 for (int i = 0; i < fast_length; i++) { | 10078 for (int i = 0; i < fast_length; i++) { |
10079 if (!elements->get(i)->IsTheHole()) element_count++; | 10079 if (!elements->get(i)->IsTheHole()) element_count++; |
10080 } | 10080 } |
10081 break; | 10081 break; |
10082 } | 10082 } |
10083 case FAST_DOUBLE_ELEMENTS: | 10083 case FAST_DOUBLE_ELEMENTS: |
10084 case FAST_HOLEY_DOUBLE_ELEMENTS: { | 10084 case FAST_HOLEY_DOUBLE_ELEMENTS: { |
10085 // Fast elements can't have lengths that are not representable by | 10085 // Fast elements can't have lengths that are not representable by |
10086 // a 32-bit signed integer. | 10086 // a 32-bit signed integer. |
10087 ASSERT(static_cast<int32_t>(FixedDoubleArray::kMaxLength) >= 0); | 10087 DCHECK(static_cast<int32_t>(FixedDoubleArray::kMaxLength) >= 0); |
10088 int fast_length = static_cast<int>(length); | 10088 int fast_length = static_cast<int>(length); |
10089 if (array->elements()->IsFixedArray()) { | 10089 if (array->elements()->IsFixedArray()) { |
10090 ASSERT(FixedArray::cast(array->elements())->length() == 0); | 10090 DCHECK(FixedArray::cast(array->elements())->length() == 0); |
10091 break; | 10091 break; |
10092 } | 10092 } |
10093 Handle<FixedDoubleArray> elements( | 10093 Handle<FixedDoubleArray> elements( |
10094 FixedDoubleArray::cast(array->elements())); | 10094 FixedDoubleArray::cast(array->elements())); |
10095 for (int i = 0; i < fast_length; i++) { | 10095 for (int i = 0; i < fast_length; i++) { |
10096 if (!elements->is_the_hole(i)) element_count++; | 10096 if (!elements->is_the_hole(i)) element_count++; |
10097 } | 10097 } |
10098 break; | 10098 break; |
10099 } | 10099 } |
10100 case DICTIONARY_ELEMENTS: { | 10100 case DICTIONARY_ELEMENTS: { |
(...skipping 28 matching lines...) Expand all Loading... |
10129 template<class ExternalArrayClass, class ElementType> | 10129 template<class ExternalArrayClass, class ElementType> |
10130 static void IterateExternalArrayElements(Isolate* isolate, | 10130 static void IterateExternalArrayElements(Isolate* isolate, |
10131 Handle<JSObject> receiver, | 10131 Handle<JSObject> receiver, |
10132 bool elements_are_ints, | 10132 bool elements_are_ints, |
10133 bool elements_are_guaranteed_smis, | 10133 bool elements_are_guaranteed_smis, |
10134 ArrayConcatVisitor* visitor) { | 10134 ArrayConcatVisitor* visitor) { |
10135 Handle<ExternalArrayClass> array( | 10135 Handle<ExternalArrayClass> array( |
10136 ExternalArrayClass::cast(receiver->elements())); | 10136 ExternalArrayClass::cast(receiver->elements())); |
10137 uint32_t len = static_cast<uint32_t>(array->length()); | 10137 uint32_t len = static_cast<uint32_t>(array->length()); |
10138 | 10138 |
10139 ASSERT(visitor != NULL); | 10139 DCHECK(visitor != NULL); |
10140 if (elements_are_ints) { | 10140 if (elements_are_ints) { |
10141 if (elements_are_guaranteed_smis) { | 10141 if (elements_are_guaranteed_smis) { |
10142 for (uint32_t j = 0; j < len; j++) { | 10142 for (uint32_t j = 0; j < len; j++) { |
10143 HandleScope loop_scope(isolate); | 10143 HandleScope loop_scope(isolate); |
10144 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j))), | 10144 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j))), |
10145 isolate); | 10145 isolate); |
10146 visitor->visit(j, e); | 10146 visitor->visit(j, e); |
10147 } | 10147 } |
10148 } else { | 10148 } else { |
10149 for (uint32_t j = 0; j < len; j++) { | 10149 for (uint32_t j = 0; j < len; j++) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10204 break; | 10204 break; |
10205 } | 10205 } |
10206 case DICTIONARY_ELEMENTS: { | 10206 case DICTIONARY_ELEMENTS: { |
10207 Handle<SeededNumberDictionary> dict( | 10207 Handle<SeededNumberDictionary> dict( |
10208 SeededNumberDictionary::cast(object->elements())); | 10208 SeededNumberDictionary::cast(object->elements())); |
10209 uint32_t capacity = dict->Capacity(); | 10209 uint32_t capacity = dict->Capacity(); |
10210 for (uint32_t j = 0; j < capacity; j++) { | 10210 for (uint32_t j = 0; j < capacity; j++) { |
10211 HandleScope loop_scope(isolate); | 10211 HandleScope loop_scope(isolate); |
10212 Handle<Object> k(dict->KeyAt(j), isolate); | 10212 Handle<Object> k(dict->KeyAt(j), isolate); |
10213 if (dict->IsKey(*k)) { | 10213 if (dict->IsKey(*k)) { |
10214 ASSERT(k->IsNumber()); | 10214 DCHECK(k->IsNumber()); |
10215 uint32_t index = static_cast<uint32_t>(k->Number()); | 10215 uint32_t index = static_cast<uint32_t>(k->Number()); |
10216 if (index < range) { | 10216 if (index < range) { |
10217 indices->Add(index); | 10217 indices->Add(index); |
10218 } | 10218 } |
10219 } | 10219 } |
10220 } | 10220 } |
10221 break; | 10221 break; |
10222 } | 10222 } |
10223 default: { | 10223 default: { |
10224 int dense_elements_length; | 10224 int dense_elements_length; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10280 uint32_t length = static_cast<uint32_t>(receiver->length()->Number()); | 10280 uint32_t length = static_cast<uint32_t>(receiver->length()->Number()); |
10281 switch (receiver->GetElementsKind()) { | 10281 switch (receiver->GetElementsKind()) { |
10282 case FAST_SMI_ELEMENTS: | 10282 case FAST_SMI_ELEMENTS: |
10283 case FAST_ELEMENTS: | 10283 case FAST_ELEMENTS: |
10284 case FAST_HOLEY_SMI_ELEMENTS: | 10284 case FAST_HOLEY_SMI_ELEMENTS: |
10285 case FAST_HOLEY_ELEMENTS: { | 10285 case FAST_HOLEY_ELEMENTS: { |
10286 // Run through the elements FixedArray and use HasElement and GetElement | 10286 // Run through the elements FixedArray and use HasElement and GetElement |
10287 // to check the prototype for missing elements. | 10287 // to check the prototype for missing elements. |
10288 Handle<FixedArray> elements(FixedArray::cast(receiver->elements())); | 10288 Handle<FixedArray> elements(FixedArray::cast(receiver->elements())); |
10289 int fast_length = static_cast<int>(length); | 10289 int fast_length = static_cast<int>(length); |
10290 ASSERT(fast_length <= elements->length()); | 10290 DCHECK(fast_length <= elements->length()); |
10291 for (int j = 0; j < fast_length; j++) { | 10291 for (int j = 0; j < fast_length; j++) { |
10292 HandleScope loop_scope(isolate); | 10292 HandleScope loop_scope(isolate); |
10293 Handle<Object> element_value(elements->get(j), isolate); | 10293 Handle<Object> element_value(elements->get(j), isolate); |
10294 if (!element_value->IsTheHole()) { | 10294 if (!element_value->IsTheHole()) { |
10295 visitor->visit(j, element_value); | 10295 visitor->visit(j, element_value); |
10296 } else { | 10296 } else { |
10297 Maybe<bool> maybe = JSReceiver::HasElement(receiver, j); | 10297 Maybe<bool> maybe = JSReceiver::HasElement(receiver, j); |
10298 if (!maybe.has_value) return false; | 10298 if (!maybe.has_value) return false; |
10299 if (maybe.value) { | 10299 if (maybe.value) { |
10300 // Call GetElement on receiver, not its prototype, or getters won't | 10300 // Call GetElement on receiver, not its prototype, or getters won't |
10301 // have the correct receiver. | 10301 // have the correct receiver. |
10302 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 10302 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
10303 isolate, element_value, | 10303 isolate, element_value, |
10304 Object::GetElement(isolate, receiver, j), false); | 10304 Object::GetElement(isolate, receiver, j), false); |
10305 visitor->visit(j, element_value); | 10305 visitor->visit(j, element_value); |
10306 } | 10306 } |
10307 } | 10307 } |
10308 } | 10308 } |
10309 break; | 10309 break; |
10310 } | 10310 } |
10311 case FAST_HOLEY_DOUBLE_ELEMENTS: | 10311 case FAST_HOLEY_DOUBLE_ELEMENTS: |
10312 case FAST_DOUBLE_ELEMENTS: { | 10312 case FAST_DOUBLE_ELEMENTS: { |
10313 // Empty array is FixedArray but not FixedDoubleArray. | 10313 // Empty array is FixedArray but not FixedDoubleArray. |
10314 if (length == 0) break; | 10314 if (length == 0) break; |
10315 // Run through the elements FixedArray and use HasElement and GetElement | 10315 // Run through the elements FixedArray and use HasElement and GetElement |
10316 // to check the prototype for missing elements. | 10316 // to check the prototype for missing elements. |
10317 if (receiver->elements()->IsFixedArray()) { | 10317 if (receiver->elements()->IsFixedArray()) { |
10318 ASSERT(receiver->elements()->length() == 0); | 10318 DCHECK(receiver->elements()->length() == 0); |
10319 break; | 10319 break; |
10320 } | 10320 } |
10321 Handle<FixedDoubleArray> elements( | 10321 Handle<FixedDoubleArray> elements( |
10322 FixedDoubleArray::cast(receiver->elements())); | 10322 FixedDoubleArray::cast(receiver->elements())); |
10323 int fast_length = static_cast<int>(length); | 10323 int fast_length = static_cast<int>(length); |
10324 ASSERT(fast_length <= elements->length()); | 10324 DCHECK(fast_length <= elements->length()); |
10325 for (int j = 0; j < fast_length; j++) { | 10325 for (int j = 0; j < fast_length; j++) { |
10326 HandleScope loop_scope(isolate); | 10326 HandleScope loop_scope(isolate); |
10327 if (!elements->is_the_hole(j)) { | 10327 if (!elements->is_the_hole(j)) { |
10328 double double_value = elements->get_scalar(j); | 10328 double double_value = elements->get_scalar(j); |
10329 Handle<Object> element_value = | 10329 Handle<Object> element_value = |
10330 isolate->factory()->NewNumber(double_value); | 10330 isolate->factory()->NewNumber(double_value); |
10331 visitor->visit(j, element_value); | 10331 visitor->visit(j, element_value); |
10332 } else { | 10332 } else { |
10333 Maybe<bool> maybe = JSReceiver::HasElement(receiver, j); | 10333 Maybe<bool> maybe = JSReceiver::HasElement(receiver, j); |
10334 if (!maybe.has_value) return false; | 10334 if (!maybe.has_value) return false; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10429 | 10429 |
10430 | 10430 |
10431 /** | 10431 /** |
10432 * Array::concat implementation. | 10432 * Array::concat implementation. |
10433 * See ECMAScript 262, 15.4.4.4. | 10433 * See ECMAScript 262, 15.4.4.4. |
10434 * TODO(581): Fix non-compliance for very large concatenations and update to | 10434 * TODO(581): Fix non-compliance for very large concatenations and update to |
10435 * following the ECMAScript 5 specification. | 10435 * following the ECMAScript 5 specification. |
10436 */ | 10436 */ |
10437 RUNTIME_FUNCTION(Runtime_ArrayConcat) { | 10437 RUNTIME_FUNCTION(Runtime_ArrayConcat) { |
10438 HandleScope handle_scope(isolate); | 10438 HandleScope handle_scope(isolate); |
10439 ASSERT(args.length() == 1); | 10439 DCHECK(args.length() == 1); |
10440 | 10440 |
10441 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0); | 10441 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0); |
10442 int argument_count = static_cast<int>(arguments->length()->Number()); | 10442 int argument_count = static_cast<int>(arguments->length()->Number()); |
10443 RUNTIME_ASSERT(arguments->HasFastObjectElements()); | 10443 RUNTIME_ASSERT(arguments->HasFastObjectElements()); |
10444 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); | 10444 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); |
10445 | 10445 |
10446 // Pass 1: estimate the length and number of elements of the result. | 10446 // Pass 1: estimate the length and number of elements of the result. |
10447 // The actual length can be larger if any of the arguments have getters | 10447 // The actual length can be larger if any of the arguments have getters |
10448 // that mutate other arguments (but will otherwise be precise). | 10448 // that mutate other arguments (but will otherwise be precise). |
10449 // The number of elements is precise if there are no inherited elements. | 10449 // The number of elements is precise if there are no inherited elements. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10548 failure = true; | 10548 failure = true; |
10549 break; | 10549 break; |
10550 } | 10550 } |
10551 int32_t int_value = Smi::cast(element)->value(); | 10551 int32_t int_value = Smi::cast(element)->value(); |
10552 double_storage->set(j, int_value); | 10552 double_storage->set(j, int_value); |
10553 j++; | 10553 j++; |
10554 } | 10554 } |
10555 break; | 10555 break; |
10556 } | 10556 } |
10557 case FAST_HOLEY_ELEMENTS: | 10557 case FAST_HOLEY_ELEMENTS: |
10558 ASSERT_EQ(0, length); | 10558 DCHECK_EQ(0, length); |
10559 break; | 10559 break; |
10560 default: | 10560 default: |
10561 UNREACHABLE(); | 10561 UNREACHABLE(); |
10562 } | 10562 } |
10563 } | 10563 } |
10564 if (failure) break; | 10564 if (failure) break; |
10565 } | 10565 } |
10566 } | 10566 } |
10567 Handle<JSArray> array = isolate->factory()->NewJSArray(0); | 10567 Handle<JSArray> array = isolate->factory()->NewJSArray(0); |
10568 Smi* length = Smi::FromInt(j); | 10568 Smi* length = Smi::FromInt(j); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10609 HandleVector<Object>(NULL, 0))); | 10609 HandleVector<Object>(NULL, 0))); |
10610 } | 10610 } |
10611 return *visitor.ToArray(); | 10611 return *visitor.ToArray(); |
10612 } | 10612 } |
10613 | 10613 |
10614 | 10614 |
10615 // This will not allocate (flatten the string), but it may run | 10615 // This will not allocate (flatten the string), but it may run |
10616 // very slowly for very deeply nested ConsStrings. For debugging use only. | 10616 // very slowly for very deeply nested ConsStrings. For debugging use only. |
10617 RUNTIME_FUNCTION(Runtime_GlobalPrint) { | 10617 RUNTIME_FUNCTION(Runtime_GlobalPrint) { |
10618 SealHandleScope shs(isolate); | 10618 SealHandleScope shs(isolate); |
10619 ASSERT(args.length() == 1); | 10619 DCHECK(args.length() == 1); |
10620 | 10620 |
10621 CONVERT_ARG_CHECKED(String, string, 0); | 10621 CONVERT_ARG_CHECKED(String, string, 0); |
10622 ConsStringIteratorOp op; | 10622 ConsStringIteratorOp op; |
10623 StringCharacterStream stream(string, &op); | 10623 StringCharacterStream stream(string, &op); |
10624 while (stream.HasMore()) { | 10624 while (stream.HasMore()) { |
10625 uint16_t character = stream.GetNext(); | 10625 uint16_t character = stream.GetNext(); |
10626 PrintF("%c", character); | 10626 PrintF("%c", character); |
10627 } | 10627 } |
10628 return string; | 10628 return string; |
10629 } | 10629 } |
10630 | 10630 |
10631 | 10631 |
10632 // Moves all own elements of an object, that are below a limit, to positions | 10632 // Moves all own elements of an object, that are below a limit, to positions |
10633 // starting at zero. All undefined values are placed after non-undefined values, | 10633 // starting at zero. All undefined values are placed after non-undefined values, |
10634 // and are followed by non-existing element. Does not change the length | 10634 // and are followed by non-existing element. Does not change the length |
10635 // property. | 10635 // property. |
10636 // Returns the number of non-undefined elements collected. | 10636 // Returns the number of non-undefined elements collected. |
10637 // Returns -1 if hole removal is not supported by this method. | 10637 // Returns -1 if hole removal is not supported by this method. |
10638 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) { | 10638 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) { |
10639 HandleScope scope(isolate); | 10639 HandleScope scope(isolate); |
10640 ASSERT(args.length() == 2); | 10640 DCHECK(args.length() == 2); |
10641 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 10641 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
10642 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 10642 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
10643 return *JSObject::PrepareElementsForSort(object, limit); | 10643 return *JSObject::PrepareElementsForSort(object, limit); |
10644 } | 10644 } |
10645 | 10645 |
10646 | 10646 |
10647 // Move contents of argument 0 (an array) to argument 1 (an array) | 10647 // Move contents of argument 0 (an array) to argument 1 (an array) |
10648 RUNTIME_FUNCTION(Runtime_MoveArrayContents) { | 10648 RUNTIME_FUNCTION(Runtime_MoveArrayContents) { |
10649 HandleScope scope(isolate); | 10649 HandleScope scope(isolate); |
10650 ASSERT(args.length() == 2); | 10650 DCHECK(args.length() == 2); |
10651 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); | 10651 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); |
10652 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); | 10652 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); |
10653 JSObject::ValidateElements(from); | 10653 JSObject::ValidateElements(from); |
10654 JSObject::ValidateElements(to); | 10654 JSObject::ValidateElements(to); |
10655 | 10655 |
10656 Handle<FixedArrayBase> new_elements(from->elements()); | 10656 Handle<FixedArrayBase> new_elements(from->elements()); |
10657 ElementsKind from_kind = from->GetElementsKind(); | 10657 ElementsKind from_kind = from->GetElementsKind(); |
10658 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); | 10658 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); |
10659 JSObject::SetMapAndElements(to, new_map, new_elements); | 10659 JSObject::SetMapAndElements(to, new_map, new_elements); |
10660 to->set_length(from->length()); | 10660 to->set_length(from->length()); |
10661 | 10661 |
10662 JSObject::ResetElements(from); | 10662 JSObject::ResetElements(from); |
10663 from->set_length(Smi::FromInt(0)); | 10663 from->set_length(Smi::FromInt(0)); |
10664 | 10664 |
10665 JSObject::ValidateElements(to); | 10665 JSObject::ValidateElements(to); |
10666 return *to; | 10666 return *to; |
10667 } | 10667 } |
10668 | 10668 |
10669 | 10669 |
10670 // How many elements does this object/array have? | 10670 // How many elements does this object/array have? |
10671 RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) { | 10671 RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) { |
10672 HandleScope scope(isolate); | 10672 HandleScope scope(isolate); |
10673 ASSERT(args.length() == 1); | 10673 DCHECK(args.length() == 1); |
10674 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 10674 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
10675 Handle<FixedArrayBase> elements(array->elements(), isolate); | 10675 Handle<FixedArrayBase> elements(array->elements(), isolate); |
10676 SealHandleScope shs(isolate); | 10676 SealHandleScope shs(isolate); |
10677 if (elements->IsDictionary()) { | 10677 if (elements->IsDictionary()) { |
10678 int result = | 10678 int result = |
10679 Handle<SeededNumberDictionary>::cast(elements)->NumberOfElements(); | 10679 Handle<SeededNumberDictionary>::cast(elements)->NumberOfElements(); |
10680 return Smi::FromInt(result); | 10680 return Smi::FromInt(result); |
10681 } else { | 10681 } else { |
10682 ASSERT(array->length()->IsSmi()); | 10682 DCHECK(array->length()->IsSmi()); |
10683 // For packed elements, we know the exact number of elements | 10683 // For packed elements, we know the exact number of elements |
10684 int length = elements->length(); | 10684 int length = elements->length(); |
10685 ElementsKind kind = array->GetElementsKind(); | 10685 ElementsKind kind = array->GetElementsKind(); |
10686 if (IsFastPackedElementsKind(kind)) { | 10686 if (IsFastPackedElementsKind(kind)) { |
10687 return Smi::FromInt(length); | 10687 return Smi::FromInt(length); |
10688 } | 10688 } |
10689 // For holey elements, take samples from the buffer checking for holes | 10689 // For holey elements, take samples from the buffer checking for holes |
10690 // to generate the estimate. | 10690 // to generate the estimate. |
10691 const int kNumberOfHoleCheckSamples = 97; | 10691 const int kNumberOfHoleCheckSamples = 97; |
10692 int increment = (length < kNumberOfHoleCheckSamples) | 10692 int increment = (length < kNumberOfHoleCheckSamples) |
(...skipping 13 matching lines...) Expand all Loading... |
10706 } | 10706 } |
10707 | 10707 |
10708 | 10708 |
10709 // Returns an array that tells you where in the [0, length) interval an array | 10709 // Returns an array that tells you where in the [0, length) interval an array |
10710 // might have elements. Can either return an array of keys (positive integers | 10710 // might have elements. Can either return an array of keys (positive integers |
10711 // or undefined) or a number representing the positive length of an interval | 10711 // or undefined) or a number representing the positive length of an interval |
10712 // starting at index 0. | 10712 // starting at index 0. |
10713 // Intervals can span over some keys that are not in the object. | 10713 // Intervals can span over some keys that are not in the object. |
10714 RUNTIME_FUNCTION(Runtime_GetArrayKeys) { | 10714 RUNTIME_FUNCTION(Runtime_GetArrayKeys) { |
10715 HandleScope scope(isolate); | 10715 HandleScope scope(isolate); |
10716 ASSERT(args.length() == 2); | 10716 DCHECK(args.length() == 2); |
10717 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 10717 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
10718 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 10718 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
10719 if (array->elements()->IsDictionary()) { | 10719 if (array->elements()->IsDictionary()) { |
10720 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); | 10720 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); |
10721 for (PrototypeIterator iter(isolate, array, | 10721 for (PrototypeIterator iter(isolate, array, |
10722 PrototypeIterator::START_AT_RECEIVER); | 10722 PrototypeIterator::START_AT_RECEIVER); |
10723 !iter.IsAtEnd(); iter.Advance()) { | 10723 !iter.IsAtEnd(); iter.Advance()) { |
10724 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || | 10724 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() || |
10725 JSObject::cast(*PrototypeIterator::GetCurrent(iter)) | 10725 JSObject::cast(*PrototypeIterator::GetCurrent(iter)) |
10726 ->HasIndexedInterceptor()) { | 10726 ->HasIndexedInterceptor()) { |
(...skipping 20 matching lines...) Expand all Loading... |
10747 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || | 10747 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() || |
10748 array->HasFastDoubleElements()); | 10748 array->HasFastDoubleElements()); |
10749 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 10749 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
10750 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 10750 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
10751 } | 10751 } |
10752 } | 10752 } |
10753 | 10753 |
10754 | 10754 |
10755 RUNTIME_FUNCTION(Runtime_LookupAccessor) { | 10755 RUNTIME_FUNCTION(Runtime_LookupAccessor) { |
10756 HandleScope scope(isolate); | 10756 HandleScope scope(isolate); |
10757 ASSERT(args.length() == 3); | 10757 DCHECK(args.length() == 3); |
10758 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 10758 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
10759 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10759 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10760 CONVERT_SMI_ARG_CHECKED(flag, 2); | 10760 CONVERT_SMI_ARG_CHECKED(flag, 2); |
10761 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; | 10761 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; |
10762 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); | 10762 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); |
10763 Handle<Object> result; | 10763 Handle<Object> result; |
10764 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10764 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
10765 isolate, result, | 10765 isolate, result, |
10766 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); | 10766 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); |
10767 return *result; | 10767 return *result; |
10768 } | 10768 } |
10769 | 10769 |
10770 | 10770 |
10771 RUNTIME_FUNCTION(Runtime_DebugBreak) { | 10771 RUNTIME_FUNCTION(Runtime_DebugBreak) { |
10772 SealHandleScope shs(isolate); | 10772 SealHandleScope shs(isolate); |
10773 ASSERT(args.length() == 0); | 10773 DCHECK(args.length() == 0); |
10774 isolate->debug()->HandleDebugBreak(); | 10774 isolate->debug()->HandleDebugBreak(); |
10775 return isolate->heap()->undefined_value(); | 10775 return isolate->heap()->undefined_value(); |
10776 } | 10776 } |
10777 | 10777 |
10778 | 10778 |
10779 // Helper functions for wrapping and unwrapping stack frame ids. | 10779 // Helper functions for wrapping and unwrapping stack frame ids. |
10780 static Smi* WrapFrameId(StackFrame::Id id) { | 10780 static Smi* WrapFrameId(StackFrame::Id id) { |
10781 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); | 10781 DCHECK(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); |
10782 return Smi::FromInt(id >> 2); | 10782 return Smi::FromInt(id >> 2); |
10783 } | 10783 } |
10784 | 10784 |
10785 | 10785 |
10786 static StackFrame::Id UnwrapFrameId(int wrapped) { | 10786 static StackFrame::Id UnwrapFrameId(int wrapped) { |
10787 return static_cast<StackFrame::Id>(wrapped << 2); | 10787 return static_cast<StackFrame::Id>(wrapped << 2); |
10788 } | 10788 } |
10789 | 10789 |
10790 | 10790 |
10791 // Adds a JavaScript function as a debug event listener. | 10791 // Adds a JavaScript function as a debug event listener. |
10792 // args[0]: debug event listener function to set or null or undefined for | 10792 // args[0]: debug event listener function to set or null or undefined for |
10793 // clearing the event listener function | 10793 // clearing the event listener function |
10794 // args[1]: object supplied during callback | 10794 // args[1]: object supplied during callback |
10795 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { | 10795 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { |
10796 SealHandleScope shs(isolate); | 10796 SealHandleScope shs(isolate); |
10797 ASSERT(args.length() == 2); | 10797 DCHECK(args.length() == 2); |
10798 RUNTIME_ASSERT(args[0]->IsJSFunction() || | 10798 RUNTIME_ASSERT(args[0]->IsJSFunction() || |
10799 args[0]->IsUndefined() || | 10799 args[0]->IsUndefined() || |
10800 args[0]->IsNull()); | 10800 args[0]->IsNull()); |
10801 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 10801 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
10802 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 10802 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
10803 isolate->debug()->SetEventListener(callback, data); | 10803 isolate->debug()->SetEventListener(callback, data); |
10804 | 10804 |
10805 return isolate->heap()->undefined_value(); | 10805 return isolate->heap()->undefined_value(); |
10806 } | 10806 } |
10807 | 10807 |
10808 | 10808 |
10809 RUNTIME_FUNCTION(Runtime_Break) { | 10809 RUNTIME_FUNCTION(Runtime_Break) { |
10810 SealHandleScope shs(isolate); | 10810 SealHandleScope shs(isolate); |
10811 ASSERT(args.length() == 0); | 10811 DCHECK(args.length() == 0); |
10812 isolate->stack_guard()->RequestDebugBreak(); | 10812 isolate->stack_guard()->RequestDebugBreak(); |
10813 return isolate->heap()->undefined_value(); | 10813 return isolate->heap()->undefined_value(); |
10814 } | 10814 } |
10815 | 10815 |
10816 | 10816 |
10817 static Handle<Object> DebugLookupResultValue(Isolate* isolate, | 10817 static Handle<Object> DebugLookupResultValue(Isolate* isolate, |
10818 Handle<Object> receiver, | 10818 Handle<Object> receiver, |
10819 Handle<Name> name, | 10819 Handle<Name> name, |
10820 LookupResult* result, | 10820 LookupResult* result, |
10821 bool* has_caught = NULL) { | 10821 bool* has_caught = NULL) { |
10822 Handle<Object> value = isolate->factory()->undefined_value(); | 10822 Handle<Object> value = isolate->factory()->undefined_value(); |
10823 if (!result->IsFound()) return value; | 10823 if (!result->IsFound()) return value; |
10824 switch (result->type()) { | 10824 switch (result->type()) { |
10825 case NORMAL: | 10825 case NORMAL: |
10826 return JSObject::GetNormalizedProperty(handle(result->holder(), isolate), | 10826 return JSObject::GetNormalizedProperty(handle(result->holder(), isolate), |
10827 result); | 10827 result); |
10828 case FIELD: | 10828 case FIELD: |
10829 return JSObject::FastPropertyAt(handle(result->holder(), isolate), | 10829 return JSObject::FastPropertyAt(handle(result->holder(), isolate), |
10830 result->representation(), | 10830 result->representation(), |
10831 result->GetFieldIndex()); | 10831 result->GetFieldIndex()); |
10832 case CONSTANT: | 10832 case CONSTANT: |
10833 return handle(result->GetConstant(), isolate); | 10833 return handle(result->GetConstant(), isolate); |
10834 case CALLBACKS: { | 10834 case CALLBACKS: { |
10835 Handle<Object> structure(result->GetCallbackObject(), isolate); | 10835 Handle<Object> structure(result->GetCallbackObject(), isolate); |
10836 ASSERT(!structure->IsForeign()); | 10836 DCHECK(!structure->IsForeign()); |
10837 if (structure->IsAccessorInfo()) { | 10837 if (structure->IsAccessorInfo()) { |
10838 MaybeHandle<Object> obj = JSObject::GetPropertyWithAccessor( | 10838 MaybeHandle<Object> obj = JSObject::GetPropertyWithAccessor( |
10839 receiver, name, handle(result->holder(), isolate), structure); | 10839 receiver, name, handle(result->holder(), isolate), structure); |
10840 if (!obj.ToHandle(&value)) { | 10840 if (!obj.ToHandle(&value)) { |
10841 value = handle(isolate->pending_exception(), isolate); | 10841 value = handle(isolate->pending_exception(), isolate); |
10842 isolate->clear_pending_exception(); | 10842 isolate->clear_pending_exception(); |
10843 if (has_caught != NULL) *has_caught = true; | 10843 if (has_caught != NULL) *has_caught = true; |
10844 return value; | 10844 return value; |
10845 } | 10845 } |
10846 } | 10846 } |
(...skipping 18 matching lines...) Expand all Loading... |
10865 // 0: Property value | 10865 // 0: Property value |
10866 // 1: Property details | 10866 // 1: Property details |
10867 // 2: Property value is exception | 10867 // 2: Property value is exception |
10868 // 3: Getter function if defined | 10868 // 3: Getter function if defined |
10869 // 4: Setter function if defined | 10869 // 4: Setter function if defined |
10870 // Items 2-4 are only filled if the property has either a getter or a setter | 10870 // Items 2-4 are only filled if the property has either a getter or a setter |
10871 // defined through __defineGetter__ and/or __defineSetter__. | 10871 // defined through __defineGetter__ and/or __defineSetter__. |
10872 RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) { | 10872 RUNTIME_FUNCTION(Runtime_DebugGetPropertyDetails) { |
10873 HandleScope scope(isolate); | 10873 HandleScope scope(isolate); |
10874 | 10874 |
10875 ASSERT(args.length() == 2); | 10875 DCHECK(args.length() == 2); |
10876 | 10876 |
10877 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10877 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
10878 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10878 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10879 | 10879 |
10880 // Make sure to set the current context to the context before the debugger was | 10880 // Make sure to set the current context to the context before the debugger was |
10881 // entered (if the debugger is entered). The reason for switching context here | 10881 // entered (if the debugger is entered). The reason for switching context here |
10882 // is that for some property lookups (accessors and interceptors) callbacks | 10882 // is that for some property lookups (accessors and interceptors) callbacks |
10883 // into the embedding application can occour, and the embedding application | 10883 // into the embedding application can occour, and the embedding application |
10884 // could have the assumption that its own native context is the current | 10884 // could have the assumption that its own native context is the current |
10885 // context and not some internal debugger context. | 10885 // context and not some internal debugger context. |
(...skipping 16 matching lines...) Expand all Loading... |
10902 1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi()); | 10902 1, PropertyDetails(NONE, NORMAL, Representation::None()).AsSmi()); |
10903 return *isolate->factory()->NewJSArrayWithElements(details); | 10903 return *isolate->factory()->NewJSArrayWithElements(details); |
10904 } | 10904 } |
10905 | 10905 |
10906 // Find the number of objects making up this. | 10906 // Find the number of objects making up this. |
10907 int length = OwnPrototypeChainLength(*obj); | 10907 int length = OwnPrototypeChainLength(*obj); |
10908 | 10908 |
10909 // Try own lookup on each of the objects. | 10909 // Try own lookup on each of the objects. |
10910 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 10910 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
10911 for (int i = 0; i < length; i++) { | 10911 for (int i = 0; i < length; i++) { |
10912 ASSERT(!iter.IsAtEnd()); | 10912 DCHECK(!iter.IsAtEnd()); |
10913 Handle<JSObject> jsproto = | 10913 Handle<JSObject> jsproto = |
10914 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | 10914 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
10915 LookupResult result(isolate); | 10915 LookupResult result(isolate); |
10916 jsproto->LookupOwn(name, &result); | 10916 jsproto->LookupOwn(name, &result); |
10917 if (result.IsFound()) { | 10917 if (result.IsFound()) { |
10918 // LookupResult is not GC safe as it holds raw object pointers. | 10918 // LookupResult is not GC safe as it holds raw object pointers. |
10919 // GC can happen later in this code so put the required fields into | 10919 // GC can happen later in this code so put the required fields into |
10920 // local variables using handles when required for later use. | 10920 // local variables using handles when required for later use. |
10921 Handle<Object> result_callback_obj; | 10921 Handle<Object> result_callback_obj; |
10922 if (result.IsPropertyCallbacks()) { | 10922 if (result.IsPropertyCallbacks()) { |
(...skipping 26 matching lines...) Expand all Loading... |
10949 iter.Advance(); | 10949 iter.Advance(); |
10950 } | 10950 } |
10951 | 10951 |
10952 return isolate->heap()->undefined_value(); | 10952 return isolate->heap()->undefined_value(); |
10953 } | 10953 } |
10954 | 10954 |
10955 | 10955 |
10956 RUNTIME_FUNCTION(Runtime_DebugGetProperty) { | 10956 RUNTIME_FUNCTION(Runtime_DebugGetProperty) { |
10957 HandleScope scope(isolate); | 10957 HandleScope scope(isolate); |
10958 | 10958 |
10959 ASSERT(args.length() == 2); | 10959 DCHECK(args.length() == 2); |
10960 | 10960 |
10961 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10961 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
10962 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10962 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10963 | 10963 |
10964 LookupResult result(isolate); | 10964 LookupResult result(isolate); |
10965 obj->Lookup(name, &result); | 10965 obj->Lookup(name, &result); |
10966 return *DebugLookupResultValue(isolate, obj, name, &result); | 10966 return *DebugLookupResultValue(isolate, obj, name, &result); |
10967 } | 10967 } |
10968 | 10968 |
10969 | 10969 |
10970 // Return the property type calculated from the property details. | 10970 // Return the property type calculated from the property details. |
10971 // args[0]: smi with property details. | 10971 // args[0]: smi with property details. |
10972 RUNTIME_FUNCTION(Runtime_DebugPropertyTypeFromDetails) { | 10972 RUNTIME_FUNCTION(Runtime_DebugPropertyTypeFromDetails) { |
10973 SealHandleScope shs(isolate); | 10973 SealHandleScope shs(isolate); |
10974 ASSERT(args.length() == 1); | 10974 DCHECK(args.length() == 1); |
10975 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10975 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10976 return Smi::FromInt(static_cast<int>(details.type())); | 10976 return Smi::FromInt(static_cast<int>(details.type())); |
10977 } | 10977 } |
10978 | 10978 |
10979 | 10979 |
10980 // Return the property attribute calculated from the property details. | 10980 // Return the property attribute calculated from the property details. |
10981 // args[0]: smi with property details. | 10981 // args[0]: smi with property details. |
10982 RUNTIME_FUNCTION(Runtime_DebugPropertyAttributesFromDetails) { | 10982 RUNTIME_FUNCTION(Runtime_DebugPropertyAttributesFromDetails) { |
10983 SealHandleScope shs(isolate); | 10983 SealHandleScope shs(isolate); |
10984 ASSERT(args.length() == 1); | 10984 DCHECK(args.length() == 1); |
10985 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10985 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10986 return Smi::FromInt(static_cast<int>(details.attributes())); | 10986 return Smi::FromInt(static_cast<int>(details.attributes())); |
10987 } | 10987 } |
10988 | 10988 |
10989 | 10989 |
10990 // Return the property insertion index calculated from the property details. | 10990 // Return the property insertion index calculated from the property details. |
10991 // args[0]: smi with property details. | 10991 // args[0]: smi with property details. |
10992 RUNTIME_FUNCTION(Runtime_DebugPropertyIndexFromDetails) { | 10992 RUNTIME_FUNCTION(Runtime_DebugPropertyIndexFromDetails) { |
10993 SealHandleScope shs(isolate); | 10993 SealHandleScope shs(isolate); |
10994 ASSERT(args.length() == 1); | 10994 DCHECK(args.length() == 1); |
10995 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10995 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10996 // TODO(verwaest): Depends on the type of details. | 10996 // TODO(verwaest): Depends on the type of details. |
10997 return Smi::FromInt(details.dictionary_index()); | 10997 return Smi::FromInt(details.dictionary_index()); |
10998 } | 10998 } |
10999 | 10999 |
11000 | 11000 |
11001 // Return property value from named interceptor. | 11001 // Return property value from named interceptor. |
11002 // args[0]: object | 11002 // args[0]: object |
11003 // args[1]: property name | 11003 // args[1]: property name |
11004 RUNTIME_FUNCTION(Runtime_DebugNamedInterceptorPropertyValue) { | 11004 RUNTIME_FUNCTION(Runtime_DebugNamedInterceptorPropertyValue) { |
11005 HandleScope scope(isolate); | 11005 HandleScope scope(isolate); |
11006 ASSERT(args.length() == 2); | 11006 DCHECK(args.length() == 2); |
11007 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 11007 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
11008 RUNTIME_ASSERT(obj->HasNamedInterceptor()); | 11008 RUNTIME_ASSERT(obj->HasNamedInterceptor()); |
11009 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 11009 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
11010 | 11010 |
11011 Handle<Object> result; | 11011 Handle<Object> result; |
11012 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 11012 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
11013 isolate, result, JSObject::GetProperty(obj, name)); | 11013 isolate, result, JSObject::GetProperty(obj, name)); |
11014 return *result; | 11014 return *result; |
11015 } | 11015 } |
11016 | 11016 |
11017 | 11017 |
11018 // Return element value from indexed interceptor. | 11018 // Return element value from indexed interceptor. |
11019 // args[0]: object | 11019 // args[0]: object |
11020 // args[1]: index | 11020 // args[1]: index |
11021 RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) { | 11021 RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) { |
11022 HandleScope scope(isolate); | 11022 HandleScope scope(isolate); |
11023 ASSERT(args.length() == 2); | 11023 DCHECK(args.length() == 2); |
11024 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 11024 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
11025 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | 11025 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); |
11026 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); | 11026 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); |
11027 Handle<Object> result; | 11027 Handle<Object> result; |
11028 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 11028 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
11029 isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); | 11029 isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); |
11030 return *result; | 11030 return *result; |
11031 } | 11031 } |
11032 | 11032 |
11033 | 11033 |
11034 static bool CheckExecutionState(Isolate* isolate, int break_id) { | 11034 static bool CheckExecutionState(Isolate* isolate, int break_id) { |
11035 return !isolate->debug()->debug_context().is_null() && | 11035 return !isolate->debug()->debug_context().is_null() && |
11036 isolate->debug()->break_id() != 0 && | 11036 isolate->debug()->break_id() != 0 && |
11037 isolate->debug()->break_id() == break_id; | 11037 isolate->debug()->break_id() == break_id; |
11038 } | 11038 } |
11039 | 11039 |
11040 | 11040 |
11041 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { | 11041 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { |
11042 SealHandleScope shs(isolate); | 11042 SealHandleScope shs(isolate); |
11043 ASSERT(args.length() == 1); | 11043 DCHECK(args.length() == 1); |
11044 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 11044 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
11045 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 11045 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
11046 return isolate->heap()->true_value(); | 11046 return isolate->heap()->true_value(); |
11047 } | 11047 } |
11048 | 11048 |
11049 | 11049 |
11050 RUNTIME_FUNCTION(Runtime_GetFrameCount) { | 11050 RUNTIME_FUNCTION(Runtime_GetFrameCount) { |
11051 HandleScope scope(isolate); | 11051 HandleScope scope(isolate); |
11052 ASSERT(args.length() == 1); | 11052 DCHECK(args.length() == 1); |
11053 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 11053 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
11054 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 11054 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
11055 | 11055 |
11056 // Count all frames which are relevant to debugging stack trace. | 11056 // Count all frames which are relevant to debugging stack trace. |
11057 int n = 0; | 11057 int n = 0; |
11058 StackFrame::Id id = isolate->debug()->break_frame_id(); | 11058 StackFrame::Id id = isolate->debug()->break_frame_id(); |
11059 if (id == StackFrame::NO_ID) { | 11059 if (id == StackFrame::NO_ID) { |
11060 // If there is no JavaScript stack frame count is 0. | 11060 // If there is no JavaScript stack frame count is 0. |
11061 return Smi::FromInt(0); | 11061 return Smi::FromInt(0); |
11062 } | 11062 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11120 } | 11120 } |
11121 bool IsConstructor() { | 11121 bool IsConstructor() { |
11122 return is_optimized_ && !is_bottommost_ | 11122 return is_optimized_ && !is_bottommost_ |
11123 ? deoptimized_frame_->HasConstructStub() | 11123 ? deoptimized_frame_->HasConstructStub() |
11124 : frame_->IsConstructor(); | 11124 : frame_->IsConstructor(); |
11125 } | 11125 } |
11126 | 11126 |
11127 // To inspect all the provided arguments the frame might need to be | 11127 // To inspect all the provided arguments the frame might need to be |
11128 // replaced with the arguments frame. | 11128 // replaced with the arguments frame. |
11129 void SetArgumentsFrame(JavaScriptFrame* frame) { | 11129 void SetArgumentsFrame(JavaScriptFrame* frame) { |
11130 ASSERT(has_adapted_arguments_); | 11130 DCHECK(has_adapted_arguments_); |
11131 frame_ = frame; | 11131 frame_ = frame; |
11132 is_optimized_ = frame_->is_optimized(); | 11132 is_optimized_ = frame_->is_optimized(); |
11133 ASSERT(!is_optimized_); | 11133 DCHECK(!is_optimized_); |
11134 } | 11134 } |
11135 | 11135 |
11136 private: | 11136 private: |
11137 JavaScriptFrame* frame_; | 11137 JavaScriptFrame* frame_; |
11138 DeoptimizedFrameInfo* deoptimized_frame_; | 11138 DeoptimizedFrameInfo* deoptimized_frame_; |
11139 Isolate* isolate_; | 11139 Isolate* isolate_; |
11140 bool is_optimized_; | 11140 bool is_optimized_; |
11141 bool is_bottommost_; | 11141 bool is_bottommost_; |
11142 bool has_adapted_arguments_; | 11142 bool has_adapted_arguments_; |
11143 | 11143 |
(...skipping 12 matching lines...) Expand all Loading... |
11156 static const int kFrameDetailsFlagsIndex = 8; | 11156 static const int kFrameDetailsFlagsIndex = 8; |
11157 static const int kFrameDetailsFirstDynamicIndex = 9; | 11157 static const int kFrameDetailsFirstDynamicIndex = 9; |
11158 | 11158 |
11159 | 11159 |
11160 static SaveContext* FindSavedContextForFrame(Isolate* isolate, | 11160 static SaveContext* FindSavedContextForFrame(Isolate* isolate, |
11161 JavaScriptFrame* frame) { | 11161 JavaScriptFrame* frame) { |
11162 SaveContext* save = isolate->save_context(); | 11162 SaveContext* save = isolate->save_context(); |
11163 while (save != NULL && !save->IsBelowFrame(frame)) { | 11163 while (save != NULL && !save->IsBelowFrame(frame)) { |
11164 save = save->prev(); | 11164 save = save->prev(); |
11165 } | 11165 } |
11166 ASSERT(save != NULL); | 11166 DCHECK(save != NULL); |
11167 return save; | 11167 return save; |
11168 } | 11168 } |
11169 | 11169 |
11170 | 11170 |
11171 RUNTIME_FUNCTION(Runtime_IsOptimized) { | 11171 RUNTIME_FUNCTION(Runtime_IsOptimized) { |
11172 SealHandleScope shs(isolate); | 11172 SealHandleScope shs(isolate); |
11173 ASSERT(args.length() == 0); | 11173 DCHECK(args.length() == 0); |
11174 JavaScriptFrameIterator it(isolate); | 11174 JavaScriptFrameIterator it(isolate); |
11175 JavaScriptFrame* frame = it.frame(); | 11175 JavaScriptFrame* frame = it.frame(); |
11176 return isolate->heap()->ToBoolean(frame->is_optimized()); | 11176 return isolate->heap()->ToBoolean(frame->is_optimized()); |
11177 } | 11177 } |
11178 | 11178 |
11179 | 11179 |
11180 // Return an array with frame details | 11180 // Return an array with frame details |
11181 // args[0]: number: break id | 11181 // args[0]: number: break id |
11182 // args[1]: number: frame index | 11182 // args[1]: number: frame index |
11183 // | 11183 // |
11184 // The array returned contains the following information: | 11184 // The array returned contains the following information: |
11185 // 0: Frame id | 11185 // 0: Frame id |
11186 // 1: Receiver | 11186 // 1: Receiver |
11187 // 2: Function | 11187 // 2: Function |
11188 // 3: Argument count | 11188 // 3: Argument count |
11189 // 4: Local count | 11189 // 4: Local count |
11190 // 5: Source position | 11190 // 5: Source position |
11191 // 6: Constructor call | 11191 // 6: Constructor call |
11192 // 7: Is at return | 11192 // 7: Is at return |
11193 // 8: Flags | 11193 // 8: Flags |
11194 // Arguments name, value | 11194 // Arguments name, value |
11195 // Locals name, value | 11195 // Locals name, value |
11196 // Return value if any | 11196 // Return value if any |
11197 RUNTIME_FUNCTION(Runtime_GetFrameDetails) { | 11197 RUNTIME_FUNCTION(Runtime_GetFrameDetails) { |
11198 HandleScope scope(isolate); | 11198 HandleScope scope(isolate); |
11199 ASSERT(args.length() == 2); | 11199 DCHECK(args.length() == 2); |
11200 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 11200 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
11201 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 11201 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
11202 | 11202 |
11203 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 11203 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
11204 Heap* heap = isolate->heap(); | 11204 Heap* heap = isolate->heap(); |
11205 | 11205 |
11206 // Find the relevant frame with the requested index. | 11206 // Find the relevant frame with the requested index. |
11207 StackFrame::Id id = isolate->debug()->break_frame_id(); | 11207 StackFrame::Id id = isolate->debug()->break_frame_id(); |
11208 if (id == StackFrame::NO_ID) { | 11208 if (id == StackFrame::NO_ID) { |
11209 // If there are no JavaScript stack frames return undefined. | 11209 // If there are no JavaScript stack frames return undefined. |
(...skipping 27 matching lines...) Expand all Loading... |
11237 // Find source position in unoptimized code. | 11237 // Find source position in unoptimized code. |
11238 int position = frame_inspector.GetSourcePosition(); | 11238 int position = frame_inspector.GetSourcePosition(); |
11239 | 11239 |
11240 // Check for constructor frame. | 11240 // Check for constructor frame. |
11241 bool constructor = frame_inspector.IsConstructor(); | 11241 bool constructor = frame_inspector.IsConstructor(); |
11242 | 11242 |
11243 // Get scope info and read from it for local variable information. | 11243 // Get scope info and read from it for local variable information. |
11244 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 11244 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
11245 Handle<SharedFunctionInfo> shared(function->shared()); | 11245 Handle<SharedFunctionInfo> shared(function->shared()); |
11246 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11246 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11247 ASSERT(*scope_info != ScopeInfo::Empty(isolate)); | 11247 DCHECK(*scope_info != ScopeInfo::Empty(isolate)); |
11248 | 11248 |
11249 // Get the locals names and values into a temporary array. | 11249 // Get the locals names and values into a temporary array. |
11250 int local_count = scope_info->LocalCount(); | 11250 int local_count = scope_info->LocalCount(); |
11251 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { | 11251 for (int slot = 0; slot < scope_info->LocalCount(); ++slot) { |
11252 // Hide compiler-introduced temporary variables, whether on the stack or on | 11252 // Hide compiler-introduced temporary variables, whether on the stack or on |
11253 // the context. | 11253 // the context. |
11254 if (scope_info->LocalIsSynthetic(slot)) | 11254 if (scope_info->LocalIsSynthetic(slot)) |
11255 local_count--; | 11255 local_count--; |
11256 } | 11256 } |
11257 | 11257 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11431 // If the receiver is not a JSObject and the function is not a | 11431 // If the receiver is not a JSObject and the function is not a |
11432 // builtin or strict-mode we have hit an optimization where a | 11432 // builtin or strict-mode we have hit an optimization where a |
11433 // value object is not converted into a wrapped JS objects. To | 11433 // value object is not converted into a wrapped JS objects. To |
11434 // hide this optimization from the debugger, we wrap the receiver | 11434 // hide this optimization from the debugger, we wrap the receiver |
11435 // by creating correct wrapper object based on the calling frame's | 11435 // by creating correct wrapper object based on the calling frame's |
11436 // native context. | 11436 // native context. |
11437 it.Advance(); | 11437 it.Advance(); |
11438 if (receiver->IsUndefined()) { | 11438 if (receiver->IsUndefined()) { |
11439 receiver = handle(function->global_proxy()); | 11439 receiver = handle(function->global_proxy()); |
11440 } else { | 11440 } else { |
11441 ASSERT(!receiver->IsNull()); | 11441 DCHECK(!receiver->IsNull()); |
11442 Context* context = Context::cast(it.frame()->context()); | 11442 Context* context = Context::cast(it.frame()->context()); |
11443 Handle<Context> native_context(Context::cast(context->native_context())); | 11443 Handle<Context> native_context(Context::cast(context->native_context())); |
11444 receiver = Object::ToObject( | 11444 receiver = Object::ToObject( |
11445 isolate, receiver, native_context).ToHandleChecked(); | 11445 isolate, receiver, native_context).ToHandleChecked(); |
11446 } | 11446 } |
11447 } | 11447 } |
11448 details->set(kFrameDetailsReceiverIndex, *receiver); | 11448 details->set(kFrameDetailsReceiverIndex, *receiver); |
11449 | 11449 |
11450 ASSERT_EQ(details_size, details_index); | 11450 DCHECK_EQ(details_size, details_index); |
11451 return *isolate->factory()->NewJSArrayWithElements(details); | 11451 return *isolate->factory()->NewJSArrayWithElements(details); |
11452 } | 11452 } |
11453 | 11453 |
11454 | 11454 |
11455 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, | 11455 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, |
11456 Handle<String> parameter_name) { | 11456 Handle<String> parameter_name) { |
11457 VariableMode mode; | 11457 VariableMode mode; |
11458 InitializationFlag init_flag; | 11458 InitializationFlag init_flag; |
11459 MaybeAssignedFlag maybe_assigned_flag; | 11459 MaybeAssignedFlag maybe_assigned_flag; |
11460 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &init_flag, | 11460 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &init_flag, |
(...skipping 16 matching lines...) Expand all Loading... |
11477 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11477 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
11478 // Do not materialize the parameter if it is shadowed by a context local. | 11478 // Do not materialize the parameter if it is shadowed by a context local. |
11479 Handle<String> name(scope_info->ParameterName(i)); | 11479 Handle<String> name(scope_info->ParameterName(i)); |
11480 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 11480 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
11481 | 11481 |
11482 HandleScope scope(isolate); | 11482 HandleScope scope(isolate); |
11483 Handle<Object> value(i < frame_inspector->GetParametersCount() | 11483 Handle<Object> value(i < frame_inspector->GetParametersCount() |
11484 ? frame_inspector->GetParameter(i) | 11484 ? frame_inspector->GetParameter(i) |
11485 : isolate->heap()->undefined_value(), | 11485 : isolate->heap()->undefined_value(), |
11486 isolate); | 11486 isolate); |
11487 ASSERT(!value->IsTheHole()); | 11487 DCHECK(!value->IsTheHole()); |
11488 | 11488 |
11489 RETURN_ON_EXCEPTION( | 11489 RETURN_ON_EXCEPTION( |
11490 isolate, | 11490 isolate, |
11491 Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY), | 11491 Runtime::SetObjectProperty(isolate, target, name, value, SLOPPY), |
11492 JSObject); | 11492 JSObject); |
11493 } | 11493 } |
11494 | 11494 |
11495 // Second fill all stack locals. | 11495 // Second fill all stack locals. |
11496 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11496 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11497 if (scope_info->LocalIsSynthetic(i)) continue; | 11497 if (scope_info->LocalIsSynthetic(i)) continue; |
(...skipping 25 matching lines...) Expand all Loading... |
11523 | 11523 |
11524 Handle<SharedFunctionInfo> shared(function->shared()); | 11524 Handle<SharedFunctionInfo> shared(function->shared()); |
11525 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11525 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11526 | 11526 |
11527 // Parameters. | 11527 // Parameters. |
11528 for (int i = 0; i < scope_info->ParameterCount(); ++i) { | 11528 for (int i = 0; i < scope_info->ParameterCount(); ++i) { |
11529 // Shadowed parameters were not materialized. | 11529 // Shadowed parameters were not materialized. |
11530 Handle<String> name(scope_info->ParameterName(i)); | 11530 Handle<String> name(scope_info->ParameterName(i)); |
11531 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; | 11531 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue; |
11532 | 11532 |
11533 ASSERT(!frame->GetParameter(i)->IsTheHole()); | 11533 DCHECK(!frame->GetParameter(i)->IsTheHole()); |
11534 HandleScope scope(isolate); | 11534 HandleScope scope(isolate); |
11535 Handle<Object> value = | 11535 Handle<Object> value = |
11536 Object::GetPropertyOrElement(target, name).ToHandleChecked(); | 11536 Object::GetPropertyOrElement(target, name).ToHandleChecked(); |
11537 frame->SetParameterValue(i, *value); | 11537 frame->SetParameterValue(i, *value); |
11538 } | 11538 } |
11539 | 11539 |
11540 // Stack locals. | 11540 // Stack locals. |
11541 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { | 11541 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { |
11542 if (scope_info->LocalIsSynthetic(i)) continue; | 11542 if (scope_info->LocalIsSynthetic(i)) continue; |
11543 if (frame->GetExpression(i)->IsTheHole()) continue; | 11543 if (frame->GetExpression(i)->IsTheHole()) continue; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11576 !function_context->IsNativeContext()) { | 11576 !function_context->IsNativeContext()) { |
11577 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 11577 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
11578 Handle<FixedArray> keys; | 11578 Handle<FixedArray> keys; |
11579 ASSIGN_RETURN_ON_EXCEPTION( | 11579 ASSIGN_RETURN_ON_EXCEPTION( |
11580 isolate, keys, | 11580 isolate, keys, |
11581 JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), | 11581 JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), |
11582 JSObject); | 11582 JSObject); |
11583 | 11583 |
11584 for (int i = 0; i < keys->length(); i++) { | 11584 for (int i = 0; i < keys->length(); i++) { |
11585 // Names of variables introduced by eval are strings. | 11585 // Names of variables introduced by eval are strings. |
11586 ASSERT(keys->get(i)->IsString()); | 11586 DCHECK(keys->get(i)->IsString()); |
11587 Handle<String> key(String::cast(keys->get(i))); | 11587 Handle<String> key(String::cast(keys->get(i))); |
11588 Handle<Object> value; | 11588 Handle<Object> value; |
11589 ASSIGN_RETURN_ON_EXCEPTION( | 11589 ASSIGN_RETURN_ON_EXCEPTION( |
11590 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); | 11590 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); |
11591 RETURN_ON_EXCEPTION( | 11591 RETURN_ON_EXCEPTION( |
11592 isolate, | 11592 isolate, |
11593 Runtime::SetObjectProperty(isolate, target, key, value, SLOPPY), | 11593 Runtime::SetObjectProperty(isolate, target, key, value, SLOPPY), |
11594 JSObject); | 11594 JSObject); |
11595 } | 11595 } |
11596 } | 11596 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11686 return true; | 11686 return true; |
11687 } | 11687 } |
11688 | 11688 |
11689 // Function context extension. These are variables introduced by eval. | 11689 // Function context extension. These are variables introduced by eval. |
11690 if (function_context->closure() == *function) { | 11690 if (function_context->closure() == *function) { |
11691 if (function_context->has_extension() && | 11691 if (function_context->has_extension() && |
11692 !function_context->IsNativeContext()) { | 11692 !function_context->IsNativeContext()) { |
11693 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 11693 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
11694 | 11694 |
11695 Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name); | 11695 Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name); |
11696 ASSERT(maybe.has_value); | 11696 DCHECK(maybe.has_value); |
11697 if (maybe.value) { | 11697 if (maybe.value) { |
11698 // We don't expect this to do anything except replacing | 11698 // We don't expect this to do anything except replacing |
11699 // property value. | 11699 // property value. |
11700 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, | 11700 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, |
11701 SLOPPY).Assert(); | 11701 SLOPPY).Assert(); |
11702 return true; | 11702 return true; |
11703 } | 11703 } |
11704 } | 11704 } |
11705 } | 11705 } |
11706 } | 11706 } |
11707 | 11707 |
11708 return default_result; | 11708 return default_result; |
11709 } | 11709 } |
11710 | 11710 |
11711 | 11711 |
11712 // Create a plain JSObject which materializes the closure content for the | 11712 // Create a plain JSObject which materializes the closure content for the |
11713 // context. | 11713 // context. |
11714 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure( | 11714 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeClosure( |
11715 Isolate* isolate, | 11715 Isolate* isolate, |
11716 Handle<Context> context) { | 11716 Handle<Context> context) { |
11717 ASSERT(context->IsFunctionContext()); | 11717 DCHECK(context->IsFunctionContext()); |
11718 | 11718 |
11719 Handle<SharedFunctionInfo> shared(context->closure()->shared()); | 11719 Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
11720 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11720 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11721 | 11721 |
11722 // Allocate and initialize a JSObject with all the content of this function | 11722 // Allocate and initialize a JSObject with all the content of this function |
11723 // closure. | 11723 // closure. |
11724 Handle<JSObject> closure_scope = | 11724 Handle<JSObject> closure_scope = |
11725 isolate->factory()->NewJSObject(isolate->object_function()); | 11725 isolate->factory()->NewJSObject(isolate->object_function()); |
11726 | 11726 |
11727 // Fill all context locals to the context extension. | 11727 // Fill all context locals to the context extension. |
11728 if (!ScopeInfo::CopyContextLocalsToScopeObject( | 11728 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
11729 scope_info, context, closure_scope)) { | 11729 scope_info, context, closure_scope)) { |
11730 return MaybeHandle<JSObject>(); | 11730 return MaybeHandle<JSObject>(); |
11731 } | 11731 } |
11732 | 11732 |
11733 // Finally copy any properties from the function context extension. This will | 11733 // Finally copy any properties from the function context extension. This will |
11734 // be variables introduced by eval. | 11734 // be variables introduced by eval. |
11735 if (context->has_extension()) { | 11735 if (context->has_extension()) { |
11736 Handle<JSObject> ext(JSObject::cast(context->extension())); | 11736 Handle<JSObject> ext(JSObject::cast(context->extension())); |
11737 Handle<FixedArray> keys; | 11737 Handle<FixedArray> keys; |
11738 ASSIGN_RETURN_ON_EXCEPTION( | 11738 ASSIGN_RETURN_ON_EXCEPTION( |
11739 isolate, keys, | 11739 isolate, keys, |
11740 JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), JSObject); | 11740 JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), JSObject); |
11741 | 11741 |
11742 for (int i = 0; i < keys->length(); i++) { | 11742 for (int i = 0; i < keys->length(); i++) { |
11743 HandleScope scope(isolate); | 11743 HandleScope scope(isolate); |
11744 // Names of variables introduced by eval are strings. | 11744 // Names of variables introduced by eval are strings. |
11745 ASSERT(keys->get(i)->IsString()); | 11745 DCHECK(keys->get(i)->IsString()); |
11746 Handle<String> key(String::cast(keys->get(i))); | 11746 Handle<String> key(String::cast(keys->get(i))); |
11747 Handle<Object> value; | 11747 Handle<Object> value; |
11748 ASSIGN_RETURN_ON_EXCEPTION( | 11748 ASSIGN_RETURN_ON_EXCEPTION( |
11749 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); | 11749 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); |
11750 RETURN_ON_EXCEPTION( | 11750 RETURN_ON_EXCEPTION( |
11751 isolate, | 11751 isolate, |
11752 Runtime::DefineObjectProperty(closure_scope, key, value, NONE), | 11752 Runtime::DefineObjectProperty(closure_scope, key, value, NONE), |
11753 JSObject); | 11753 JSObject); |
11754 } | 11754 } |
11755 } | 11755 } |
11756 | 11756 |
11757 return closure_scope; | 11757 return closure_scope; |
11758 } | 11758 } |
11759 | 11759 |
11760 | 11760 |
11761 // This method copies structure of MaterializeClosure method above. | 11761 // This method copies structure of MaterializeClosure method above. |
11762 static bool SetClosureVariableValue(Isolate* isolate, | 11762 static bool SetClosureVariableValue(Isolate* isolate, |
11763 Handle<Context> context, | 11763 Handle<Context> context, |
11764 Handle<String> variable_name, | 11764 Handle<String> variable_name, |
11765 Handle<Object> new_value) { | 11765 Handle<Object> new_value) { |
11766 ASSERT(context->IsFunctionContext()); | 11766 DCHECK(context->IsFunctionContext()); |
11767 | 11767 |
11768 Handle<SharedFunctionInfo> shared(context->closure()->shared()); | 11768 Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
11769 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11769 Handle<ScopeInfo> scope_info(shared->scope_info()); |
11770 | 11770 |
11771 // Context locals to the context extension. | 11771 // Context locals to the context extension. |
11772 if (SetContextLocalValue( | 11772 if (SetContextLocalValue( |
11773 isolate, scope_info, context, variable_name, new_value)) { | 11773 isolate, scope_info, context, variable_name, new_value)) { |
11774 return true; | 11774 return true; |
11775 } | 11775 } |
11776 | 11776 |
11777 // Properties from the function context extension. This will | 11777 // Properties from the function context extension. This will |
11778 // be variables introduced by eval. | 11778 // be variables introduced by eval. |
11779 if (context->has_extension()) { | 11779 if (context->has_extension()) { |
11780 Handle<JSObject> ext(JSObject::cast(context->extension())); | 11780 Handle<JSObject> ext(JSObject::cast(context->extension())); |
11781 Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name); | 11781 Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name); |
11782 ASSERT(maybe.has_value); | 11782 DCHECK(maybe.has_value); |
11783 if (maybe.value) { | 11783 if (maybe.value) { |
11784 // We don't expect this to do anything except replacing property value. | 11784 // We don't expect this to do anything except replacing property value. |
11785 Runtime::DefineObjectProperty( | 11785 Runtime::DefineObjectProperty( |
11786 ext, variable_name, new_value, NONE).Assert(); | 11786 ext, variable_name, new_value, NONE).Assert(); |
11787 return true; | 11787 return true; |
11788 } | 11788 } |
11789 } | 11789 } |
11790 | 11790 |
11791 return false; | 11791 return false; |
11792 } | 11792 } |
11793 | 11793 |
11794 | 11794 |
11795 // Create a plain JSObject which materializes the scope for the specified | 11795 // Create a plain JSObject which materializes the scope for the specified |
11796 // catch context. | 11796 // catch context. |
11797 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( | 11797 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope( |
11798 Isolate* isolate, | 11798 Isolate* isolate, |
11799 Handle<Context> context) { | 11799 Handle<Context> context) { |
11800 ASSERT(context->IsCatchContext()); | 11800 DCHECK(context->IsCatchContext()); |
11801 Handle<String> name(String::cast(context->extension())); | 11801 Handle<String> name(String::cast(context->extension())); |
11802 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), | 11802 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), |
11803 isolate); | 11803 isolate); |
11804 Handle<JSObject> catch_scope = | 11804 Handle<JSObject> catch_scope = |
11805 isolate->factory()->NewJSObject(isolate->object_function()); | 11805 isolate->factory()->NewJSObject(isolate->object_function()); |
11806 RETURN_ON_EXCEPTION( | 11806 RETURN_ON_EXCEPTION( |
11807 isolate, | 11807 isolate, |
11808 Runtime::DefineObjectProperty(catch_scope, name, thrown_object, NONE), | 11808 Runtime::DefineObjectProperty(catch_scope, name, thrown_object, NONE), |
11809 JSObject); | 11809 JSObject); |
11810 return catch_scope; | 11810 return catch_scope; |
11811 } | 11811 } |
11812 | 11812 |
11813 | 11813 |
11814 static bool SetCatchVariableValue(Isolate* isolate, | 11814 static bool SetCatchVariableValue(Isolate* isolate, |
11815 Handle<Context> context, | 11815 Handle<Context> context, |
11816 Handle<String> variable_name, | 11816 Handle<String> variable_name, |
11817 Handle<Object> new_value) { | 11817 Handle<Object> new_value) { |
11818 ASSERT(context->IsCatchContext()); | 11818 DCHECK(context->IsCatchContext()); |
11819 Handle<String> name(String::cast(context->extension())); | 11819 Handle<String> name(String::cast(context->extension())); |
11820 if (!String::Equals(name, variable_name)) { | 11820 if (!String::Equals(name, variable_name)) { |
11821 return false; | 11821 return false; |
11822 } | 11822 } |
11823 context->set(Context::THROWN_OBJECT_INDEX, *new_value); | 11823 context->set(Context::THROWN_OBJECT_INDEX, *new_value); |
11824 return true; | 11824 return true; |
11825 } | 11825 } |
11826 | 11826 |
11827 | 11827 |
11828 // Create a plain JSObject which materializes the block scope for the specified | 11828 // Create a plain JSObject which materializes the block scope for the specified |
11829 // block context. | 11829 // block context. |
11830 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeBlockScope( | 11830 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeBlockScope( |
11831 Isolate* isolate, | 11831 Isolate* isolate, |
11832 Handle<Context> context) { | 11832 Handle<Context> context) { |
11833 ASSERT(context->IsBlockContext()); | 11833 DCHECK(context->IsBlockContext()); |
11834 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | 11834 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
11835 | 11835 |
11836 // Allocate and initialize a JSObject with all the arguments, stack locals | 11836 // Allocate and initialize a JSObject with all the arguments, stack locals |
11837 // heap locals and extension properties of the debugged function. | 11837 // heap locals and extension properties of the debugged function. |
11838 Handle<JSObject> block_scope = | 11838 Handle<JSObject> block_scope = |
11839 isolate->factory()->NewJSObject(isolate->object_function()); | 11839 isolate->factory()->NewJSObject(isolate->object_function()); |
11840 | 11840 |
11841 // Fill all context locals. | 11841 // Fill all context locals. |
11842 if (!ScopeInfo::CopyContextLocalsToScopeObject( | 11842 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
11843 scope_info, context, block_scope)) { | 11843 scope_info, context, block_scope)) { |
11844 return MaybeHandle<JSObject>(); | 11844 return MaybeHandle<JSObject>(); |
11845 } | 11845 } |
11846 | 11846 |
11847 return block_scope; | 11847 return block_scope; |
11848 } | 11848 } |
11849 | 11849 |
11850 | 11850 |
11851 // Create a plain JSObject which materializes the module scope for the specified | 11851 // Create a plain JSObject which materializes the module scope for the specified |
11852 // module context. | 11852 // module context. |
11853 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope( | 11853 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeModuleScope( |
11854 Isolate* isolate, | 11854 Isolate* isolate, |
11855 Handle<Context> context) { | 11855 Handle<Context> context) { |
11856 ASSERT(context->IsModuleContext()); | 11856 DCHECK(context->IsModuleContext()); |
11857 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | 11857 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
11858 | 11858 |
11859 // Allocate and initialize a JSObject with all the members of the debugged | 11859 // Allocate and initialize a JSObject with all the members of the debugged |
11860 // module. | 11860 // module. |
11861 Handle<JSObject> module_scope = | 11861 Handle<JSObject> module_scope = |
11862 isolate->factory()->NewJSObject(isolate->object_function()); | 11862 isolate->factory()->NewJSObject(isolate->object_function()); |
11863 | 11863 |
11864 // Fill all context locals. | 11864 // Fill all context locals. |
11865 if (!ScopeInfo::CopyContextLocalsToScopeObject( | 11865 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
11866 scope_info, context, module_scope)) { | 11866 scope_info, context, module_scope)) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11955 Scope* scope = NULL; | 11955 Scope* scope = NULL; |
11956 | 11956 |
11957 // Check whether we are in global, eval or function code. | 11957 // Check whether we are in global, eval or function code. |
11958 Handle<ScopeInfo> scope_info(shared_info->scope_info()); | 11958 Handle<ScopeInfo> scope_info(shared_info->scope_info()); |
11959 if (scope_info->scope_type() != FUNCTION_SCOPE) { | 11959 if (scope_info->scope_type() != FUNCTION_SCOPE) { |
11960 // Global or eval code. | 11960 // Global or eval code. |
11961 CompilationInfoWithZone info(script); | 11961 CompilationInfoWithZone info(script); |
11962 if (scope_info->scope_type() == GLOBAL_SCOPE) { | 11962 if (scope_info->scope_type() == GLOBAL_SCOPE) { |
11963 info.MarkAsGlobal(); | 11963 info.MarkAsGlobal(); |
11964 } else { | 11964 } else { |
11965 ASSERT(scope_info->scope_type() == EVAL_SCOPE); | 11965 DCHECK(scope_info->scope_type() == EVAL_SCOPE); |
11966 info.MarkAsEval(); | 11966 info.MarkAsEval(); |
11967 info.SetContext(Handle<Context>(function_->context())); | 11967 info.SetContext(Handle<Context>(function_->context())); |
11968 } | 11968 } |
11969 if (Parser::Parse(&info) && Scope::Analyze(&info)) { | 11969 if (Parser::Parse(&info) && Scope::Analyze(&info)) { |
11970 scope = info.function()->scope(); | 11970 scope = info.function()->scope(); |
11971 } | 11971 } |
11972 RetrieveScopeChain(scope, shared_info); | 11972 RetrieveScopeChain(scope, shared_info); |
11973 } else { | 11973 } else { |
11974 // Function code | 11974 // Function code |
11975 CompilationInfoWithZone info(shared_info); | 11975 CompilationInfoWithZone info(shared_info); |
(...skipping 13 matching lines...) Expand all Loading... |
11989 function_(function), | 11989 function_(function), |
11990 context_(function->context()), | 11990 context_(function->context()), |
11991 failed_(false) { | 11991 failed_(false) { |
11992 if (function->IsBuiltin()) { | 11992 if (function->IsBuiltin()) { |
11993 context_ = Handle<Context>(); | 11993 context_ = Handle<Context>(); |
11994 } | 11994 } |
11995 } | 11995 } |
11996 | 11996 |
11997 // More scopes? | 11997 // More scopes? |
11998 bool Done() { | 11998 bool Done() { |
11999 ASSERT(!failed_); | 11999 DCHECK(!failed_); |
12000 return context_.is_null(); | 12000 return context_.is_null(); |
12001 } | 12001 } |
12002 | 12002 |
12003 bool Failed() { return failed_; } | 12003 bool Failed() { return failed_; } |
12004 | 12004 |
12005 // Move to the next scope. | 12005 // Move to the next scope. |
12006 void Next() { | 12006 void Next() { |
12007 ASSERT(!failed_); | 12007 DCHECK(!failed_); |
12008 ScopeType scope_type = Type(); | 12008 ScopeType scope_type = Type(); |
12009 if (scope_type == ScopeTypeGlobal) { | 12009 if (scope_type == ScopeTypeGlobal) { |
12010 // The global scope is always the last in the chain. | 12010 // The global scope is always the last in the chain. |
12011 ASSERT(context_->IsNativeContext()); | 12011 DCHECK(context_->IsNativeContext()); |
12012 context_ = Handle<Context>(); | 12012 context_ = Handle<Context>(); |
12013 return; | 12013 return; |
12014 } | 12014 } |
12015 if (nested_scope_chain_.is_empty()) { | 12015 if (nested_scope_chain_.is_empty()) { |
12016 context_ = Handle<Context>(context_->previous(), isolate_); | 12016 context_ = Handle<Context>(context_->previous(), isolate_); |
12017 } else { | 12017 } else { |
12018 if (nested_scope_chain_.last()->HasContext()) { | 12018 if (nested_scope_chain_.last()->HasContext()) { |
12019 ASSERT(context_->previous() != NULL); | 12019 DCHECK(context_->previous() != NULL); |
12020 context_ = Handle<Context>(context_->previous(), isolate_); | 12020 context_ = Handle<Context>(context_->previous(), isolate_); |
12021 } | 12021 } |
12022 nested_scope_chain_.RemoveLast(); | 12022 nested_scope_chain_.RemoveLast(); |
12023 } | 12023 } |
12024 } | 12024 } |
12025 | 12025 |
12026 // Return the type of the current scope. | 12026 // Return the type of the current scope. |
12027 ScopeType Type() { | 12027 ScopeType Type() { |
12028 ASSERT(!failed_); | 12028 DCHECK(!failed_); |
12029 if (!nested_scope_chain_.is_empty()) { | 12029 if (!nested_scope_chain_.is_empty()) { |
12030 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); | 12030 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); |
12031 switch (scope_info->scope_type()) { | 12031 switch (scope_info->scope_type()) { |
12032 case FUNCTION_SCOPE: | 12032 case FUNCTION_SCOPE: |
12033 ASSERT(context_->IsFunctionContext() || | 12033 DCHECK(context_->IsFunctionContext() || |
12034 !scope_info->HasContext()); | 12034 !scope_info->HasContext()); |
12035 return ScopeTypeLocal; | 12035 return ScopeTypeLocal; |
12036 case MODULE_SCOPE: | 12036 case MODULE_SCOPE: |
12037 ASSERT(context_->IsModuleContext()); | 12037 DCHECK(context_->IsModuleContext()); |
12038 return ScopeTypeModule; | 12038 return ScopeTypeModule; |
12039 case GLOBAL_SCOPE: | 12039 case GLOBAL_SCOPE: |
12040 ASSERT(context_->IsNativeContext()); | 12040 DCHECK(context_->IsNativeContext()); |
12041 return ScopeTypeGlobal; | 12041 return ScopeTypeGlobal; |
12042 case WITH_SCOPE: | 12042 case WITH_SCOPE: |
12043 ASSERT(context_->IsWithContext()); | 12043 DCHECK(context_->IsWithContext()); |
12044 return ScopeTypeWith; | 12044 return ScopeTypeWith; |
12045 case CATCH_SCOPE: | 12045 case CATCH_SCOPE: |
12046 ASSERT(context_->IsCatchContext()); | 12046 DCHECK(context_->IsCatchContext()); |
12047 return ScopeTypeCatch; | 12047 return ScopeTypeCatch; |
12048 case BLOCK_SCOPE: | 12048 case BLOCK_SCOPE: |
12049 ASSERT(!scope_info->HasContext() || | 12049 DCHECK(!scope_info->HasContext() || |
12050 context_->IsBlockContext()); | 12050 context_->IsBlockContext()); |
12051 return ScopeTypeBlock; | 12051 return ScopeTypeBlock; |
12052 case EVAL_SCOPE: | 12052 case EVAL_SCOPE: |
12053 UNREACHABLE(); | 12053 UNREACHABLE(); |
12054 } | 12054 } |
12055 } | 12055 } |
12056 if (context_->IsNativeContext()) { | 12056 if (context_->IsNativeContext()) { |
12057 ASSERT(context_->global_object()->IsGlobalObject()); | 12057 DCHECK(context_->global_object()->IsGlobalObject()); |
12058 return ScopeTypeGlobal; | 12058 return ScopeTypeGlobal; |
12059 } | 12059 } |
12060 if (context_->IsFunctionContext()) { | 12060 if (context_->IsFunctionContext()) { |
12061 return ScopeTypeClosure; | 12061 return ScopeTypeClosure; |
12062 } | 12062 } |
12063 if (context_->IsCatchContext()) { | 12063 if (context_->IsCatchContext()) { |
12064 return ScopeTypeCatch; | 12064 return ScopeTypeCatch; |
12065 } | 12065 } |
12066 if (context_->IsBlockContext()) { | 12066 if (context_->IsBlockContext()) { |
12067 return ScopeTypeBlock; | 12067 return ScopeTypeBlock; |
12068 } | 12068 } |
12069 if (context_->IsModuleContext()) { | 12069 if (context_->IsModuleContext()) { |
12070 return ScopeTypeModule; | 12070 return ScopeTypeModule; |
12071 } | 12071 } |
12072 ASSERT(context_->IsWithContext()); | 12072 DCHECK(context_->IsWithContext()); |
12073 return ScopeTypeWith; | 12073 return ScopeTypeWith; |
12074 } | 12074 } |
12075 | 12075 |
12076 // Return the JavaScript object with the content of the current scope. | 12076 // Return the JavaScript object with the content of the current scope. |
12077 MaybeHandle<JSObject> ScopeObject() { | 12077 MaybeHandle<JSObject> ScopeObject() { |
12078 ASSERT(!failed_); | 12078 DCHECK(!failed_); |
12079 switch (Type()) { | 12079 switch (Type()) { |
12080 case ScopeIterator::ScopeTypeGlobal: | 12080 case ScopeIterator::ScopeTypeGlobal: |
12081 return Handle<JSObject>(CurrentContext()->global_object()); | 12081 return Handle<JSObject>(CurrentContext()->global_object()); |
12082 case ScopeIterator::ScopeTypeLocal: | 12082 case ScopeIterator::ScopeTypeLocal: |
12083 // Materialize the content of the local scope into a JSObject. | 12083 // Materialize the content of the local scope into a JSObject. |
12084 ASSERT(nested_scope_chain_.length() == 1); | 12084 DCHECK(nested_scope_chain_.length() == 1); |
12085 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_); | 12085 return MaterializeLocalScope(isolate_, frame_, inlined_jsframe_index_); |
12086 case ScopeIterator::ScopeTypeWith: | 12086 case ScopeIterator::ScopeTypeWith: |
12087 // Return the with object. | 12087 // Return the with object. |
12088 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); | 12088 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); |
12089 case ScopeIterator::ScopeTypeCatch: | 12089 case ScopeIterator::ScopeTypeCatch: |
12090 return MaterializeCatchScope(isolate_, CurrentContext()); | 12090 return MaterializeCatchScope(isolate_, CurrentContext()); |
12091 case ScopeIterator::ScopeTypeClosure: | 12091 case ScopeIterator::ScopeTypeClosure: |
12092 // Materialize the content of the closure scope into a JSObject. | 12092 // Materialize the content of the closure scope into a JSObject. |
12093 return MaterializeClosure(isolate_, CurrentContext()); | 12093 return MaterializeClosure(isolate_, CurrentContext()); |
12094 case ScopeIterator::ScopeTypeBlock: | 12094 case ScopeIterator::ScopeTypeBlock: |
12095 return MaterializeBlockScope(isolate_, CurrentContext()); | 12095 return MaterializeBlockScope(isolate_, CurrentContext()); |
12096 case ScopeIterator::ScopeTypeModule: | 12096 case ScopeIterator::ScopeTypeModule: |
12097 return MaterializeModuleScope(isolate_, CurrentContext()); | 12097 return MaterializeModuleScope(isolate_, CurrentContext()); |
12098 } | 12098 } |
12099 UNREACHABLE(); | 12099 UNREACHABLE(); |
12100 return Handle<JSObject>(); | 12100 return Handle<JSObject>(); |
12101 } | 12101 } |
12102 | 12102 |
12103 bool SetVariableValue(Handle<String> variable_name, | 12103 bool SetVariableValue(Handle<String> variable_name, |
12104 Handle<Object> new_value) { | 12104 Handle<Object> new_value) { |
12105 ASSERT(!failed_); | 12105 DCHECK(!failed_); |
12106 switch (Type()) { | 12106 switch (Type()) { |
12107 case ScopeIterator::ScopeTypeGlobal: | 12107 case ScopeIterator::ScopeTypeGlobal: |
12108 break; | 12108 break; |
12109 case ScopeIterator::ScopeTypeLocal: | 12109 case ScopeIterator::ScopeTypeLocal: |
12110 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_, | 12110 return SetLocalVariableValue(isolate_, frame_, inlined_jsframe_index_, |
12111 variable_name, new_value); | 12111 variable_name, new_value); |
12112 case ScopeIterator::ScopeTypeWith: | 12112 case ScopeIterator::ScopeTypeWith: |
12113 break; | 12113 break; |
12114 case ScopeIterator::ScopeTypeCatch: | 12114 case ScopeIterator::ScopeTypeCatch: |
12115 return SetCatchVariableValue(isolate_, CurrentContext(), | 12115 return SetCatchVariableValue(isolate_, CurrentContext(), |
12116 variable_name, new_value); | 12116 variable_name, new_value); |
12117 case ScopeIterator::ScopeTypeClosure: | 12117 case ScopeIterator::ScopeTypeClosure: |
12118 return SetClosureVariableValue(isolate_, CurrentContext(), | 12118 return SetClosureVariableValue(isolate_, CurrentContext(), |
12119 variable_name, new_value); | 12119 variable_name, new_value); |
12120 case ScopeIterator::ScopeTypeBlock: | 12120 case ScopeIterator::ScopeTypeBlock: |
12121 // TODO(2399): should we implement it? | 12121 // TODO(2399): should we implement it? |
12122 break; | 12122 break; |
12123 case ScopeIterator::ScopeTypeModule: | 12123 case ScopeIterator::ScopeTypeModule: |
12124 // TODO(2399): should we implement it? | 12124 // TODO(2399): should we implement it? |
12125 break; | 12125 break; |
12126 } | 12126 } |
12127 return false; | 12127 return false; |
12128 } | 12128 } |
12129 | 12129 |
12130 Handle<ScopeInfo> CurrentScopeInfo() { | 12130 Handle<ScopeInfo> CurrentScopeInfo() { |
12131 ASSERT(!failed_); | 12131 DCHECK(!failed_); |
12132 if (!nested_scope_chain_.is_empty()) { | 12132 if (!nested_scope_chain_.is_empty()) { |
12133 return nested_scope_chain_.last(); | 12133 return nested_scope_chain_.last(); |
12134 } else if (context_->IsBlockContext()) { | 12134 } else if (context_->IsBlockContext()) { |
12135 return Handle<ScopeInfo>(ScopeInfo::cast(context_->extension())); | 12135 return Handle<ScopeInfo>(ScopeInfo::cast(context_->extension())); |
12136 } else if (context_->IsFunctionContext()) { | 12136 } else if (context_->IsFunctionContext()) { |
12137 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); | 12137 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); |
12138 } | 12138 } |
12139 return Handle<ScopeInfo>::null(); | 12139 return Handle<ScopeInfo>::null(); |
12140 } | 12140 } |
12141 | 12141 |
12142 // Return the context for this scope. For the local context there might not | 12142 // Return the context for this scope. For the local context there might not |
12143 // be an actual context. | 12143 // be an actual context. |
12144 Handle<Context> CurrentContext() { | 12144 Handle<Context> CurrentContext() { |
12145 ASSERT(!failed_); | 12145 DCHECK(!failed_); |
12146 if (Type() == ScopeTypeGlobal || | 12146 if (Type() == ScopeTypeGlobal || |
12147 nested_scope_chain_.is_empty()) { | 12147 nested_scope_chain_.is_empty()) { |
12148 return context_; | 12148 return context_; |
12149 } else if (nested_scope_chain_.last()->HasContext()) { | 12149 } else if (nested_scope_chain_.last()->HasContext()) { |
12150 return context_; | 12150 return context_; |
12151 } else { | 12151 } else { |
12152 return Handle<Context>(); | 12152 return Handle<Context>(); |
12153 } | 12153 } |
12154 } | 12154 } |
12155 | 12155 |
12156 #ifdef DEBUG | 12156 #ifdef DEBUG |
12157 // Debug print of the content of the current scope. | 12157 // Debug print of the content of the current scope. |
12158 void DebugPrint() { | 12158 void DebugPrint() { |
12159 OFStream os(stdout); | 12159 OFStream os(stdout); |
12160 ASSERT(!failed_); | 12160 DCHECK(!failed_); |
12161 switch (Type()) { | 12161 switch (Type()) { |
12162 case ScopeIterator::ScopeTypeGlobal: | 12162 case ScopeIterator::ScopeTypeGlobal: |
12163 os << "Global:\n"; | 12163 os << "Global:\n"; |
12164 CurrentContext()->Print(os); | 12164 CurrentContext()->Print(os); |
12165 break; | 12165 break; |
12166 | 12166 |
12167 case ScopeIterator::ScopeTypeLocal: { | 12167 case ScopeIterator::ScopeTypeLocal: { |
12168 os << "Local:\n"; | 12168 os << "Local:\n"; |
12169 function_->shared()->scope_info()->Print(); | 12169 function_->shared()->scope_info()->Print(); |
12170 if (!CurrentContext().is_null()) { | 12170 if (!CurrentContext().is_null()) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12222 if (scope != NULL) { | 12222 if (scope != NULL) { |
12223 int source_position = shared_info->code()->SourcePosition(frame_->pc()); | 12223 int source_position = shared_info->code()->SourcePosition(frame_->pc()); |
12224 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); | 12224 scope->GetNestedScopeChain(&nested_scope_chain_, source_position); |
12225 } else { | 12225 } else { |
12226 // A failed reparse indicates that the preparser has diverged from the | 12226 // A failed reparse indicates that the preparser has diverged from the |
12227 // parser or that the preparse data given to the initial parse has been | 12227 // parser or that the preparse data given to the initial parse has been |
12228 // faulty. We fail in debug mode but in release mode we only provide the | 12228 // faulty. We fail in debug mode but in release mode we only provide the |
12229 // information we get from the context chain but nothing about | 12229 // information we get from the context chain but nothing about |
12230 // completely stack allocated scopes or stack allocated locals. | 12230 // completely stack allocated scopes or stack allocated locals. |
12231 // Or it could be due to stack overflow. | 12231 // Or it could be due to stack overflow. |
12232 ASSERT(isolate_->has_pending_exception()); | 12232 DCHECK(isolate_->has_pending_exception()); |
12233 failed_ = true; | 12233 failed_ = true; |
12234 } | 12234 } |
12235 } | 12235 } |
12236 | 12236 |
12237 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 12237 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
12238 }; | 12238 }; |
12239 | 12239 |
12240 | 12240 |
12241 RUNTIME_FUNCTION(Runtime_GetScopeCount) { | 12241 RUNTIME_FUNCTION(Runtime_GetScopeCount) { |
12242 HandleScope scope(isolate); | 12242 HandleScope scope(isolate); |
12243 ASSERT(args.length() == 2); | 12243 DCHECK(args.length() == 2); |
12244 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12244 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12245 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12245 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12246 | 12246 |
12247 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12247 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12248 | 12248 |
12249 // Get the frame where the debugging is performed. | 12249 // Get the frame where the debugging is performed. |
12250 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12250 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12251 JavaScriptFrameIterator it(isolate, id); | 12251 JavaScriptFrameIterator it(isolate, id); |
12252 JavaScriptFrame* frame = it.frame(); | 12252 JavaScriptFrame* frame = it.frame(); |
12253 | 12253 |
12254 // Count the visible scopes. | 12254 // Count the visible scopes. |
12255 int n = 0; | 12255 int n = 0; |
12256 for (ScopeIterator it(isolate, frame, 0); | 12256 for (ScopeIterator it(isolate, frame, 0); |
12257 !it.Done(); | 12257 !it.Done(); |
12258 it.Next()) { | 12258 it.Next()) { |
12259 n++; | 12259 n++; |
12260 } | 12260 } |
12261 | 12261 |
12262 return Smi::FromInt(n); | 12262 return Smi::FromInt(n); |
12263 } | 12263 } |
12264 | 12264 |
12265 | 12265 |
12266 // Returns the list of step-in positions (text offset) in a function of the | 12266 // Returns the list of step-in positions (text offset) in a function of the |
12267 // stack frame in a range from the current debug break position to the end | 12267 // stack frame in a range from the current debug break position to the end |
12268 // of the corresponding statement. | 12268 // of the corresponding statement. |
12269 RUNTIME_FUNCTION(Runtime_GetStepInPositions) { | 12269 RUNTIME_FUNCTION(Runtime_GetStepInPositions) { |
12270 HandleScope scope(isolate); | 12270 HandleScope scope(isolate); |
12271 ASSERT(args.length() == 2); | 12271 DCHECK(args.length() == 2); |
12272 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12272 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12273 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12273 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12274 | 12274 |
12275 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12275 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12276 | 12276 |
12277 // Get the frame where the debugging is performed. | 12277 // Get the frame where the debugging is performed. |
12278 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12278 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12279 JavaScriptFrameIterator frame_it(isolate, id); | 12279 JavaScriptFrameIterator frame_it(isolate, id); |
12280 RUNTIME_ASSERT(!frame_it.done()); | 12280 RUNTIME_ASSERT(!frame_it.done()); |
12281 | 12281 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12368 // args[0]: number: break id | 12368 // args[0]: number: break id |
12369 // args[1]: number: frame index | 12369 // args[1]: number: frame index |
12370 // args[2]: number: inlined frame index | 12370 // args[2]: number: inlined frame index |
12371 // args[3]: number: scope index | 12371 // args[3]: number: scope index |
12372 // | 12372 // |
12373 // The array returned contains the following information: | 12373 // The array returned contains the following information: |
12374 // 0: Scope type | 12374 // 0: Scope type |
12375 // 1: Scope object | 12375 // 1: Scope object |
12376 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { | 12376 RUNTIME_FUNCTION(Runtime_GetScopeDetails) { |
12377 HandleScope scope(isolate); | 12377 HandleScope scope(isolate); |
12378 ASSERT(args.length() == 4); | 12378 DCHECK(args.length() == 4); |
12379 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12379 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12380 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12380 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12381 | 12381 |
12382 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12382 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12383 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12383 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
12384 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 12384 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
12385 | 12385 |
12386 // Get the frame where the debugging is performed. | 12386 // Get the frame where the debugging is performed. |
12387 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12387 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12388 JavaScriptFrameIterator frame_it(isolate, id); | 12388 JavaScriptFrameIterator frame_it(isolate, id); |
(...skipping 19 matching lines...) Expand all Loading... |
12408 // args[0]: number: break id | 12408 // args[0]: number: break id |
12409 // args[1]: number: frame index | 12409 // args[1]: number: frame index |
12410 // args[2]: number: inlined frame index | 12410 // args[2]: number: inlined frame index |
12411 // args[3]: boolean: ignore nested scopes | 12411 // args[3]: boolean: ignore nested scopes |
12412 // | 12412 // |
12413 // The array returned contains arrays with the following information: | 12413 // The array returned contains arrays with the following information: |
12414 // 0: Scope type | 12414 // 0: Scope type |
12415 // 1: Scope object | 12415 // 1: Scope object |
12416 RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { | 12416 RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { |
12417 HandleScope scope(isolate); | 12417 HandleScope scope(isolate); |
12418 ASSERT(args.length() == 3 || args.length() == 4); | 12418 DCHECK(args.length() == 3 || args.length() == 4); |
12419 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12419 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12420 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12420 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12421 | 12421 |
12422 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12422 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12423 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12423 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
12424 | 12424 |
12425 bool ignore_nested_scopes = false; | 12425 bool ignore_nested_scopes = false; |
12426 if (args.length() == 4) { | 12426 if (args.length() == 4) { |
12427 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); | 12427 CONVERT_BOOLEAN_ARG_CHECKED(flag, 3); |
12428 ignore_nested_scopes = flag; | 12428 ignore_nested_scopes = flag; |
(...skipping 16 matching lines...) Expand all Loading... |
12445 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); | 12445 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); |
12446 for (int i = 0; i < result.length(); ++i) { | 12446 for (int i = 0; i < result.length(); ++i) { |
12447 array->set(i, *result[i]); | 12447 array->set(i, *result[i]); |
12448 } | 12448 } |
12449 return *isolate->factory()->NewJSArrayWithElements(array); | 12449 return *isolate->factory()->NewJSArrayWithElements(array); |
12450 } | 12450 } |
12451 | 12451 |
12452 | 12452 |
12453 RUNTIME_FUNCTION(Runtime_GetFunctionScopeCount) { | 12453 RUNTIME_FUNCTION(Runtime_GetFunctionScopeCount) { |
12454 HandleScope scope(isolate); | 12454 HandleScope scope(isolate); |
12455 ASSERT(args.length() == 1); | 12455 DCHECK(args.length() == 1); |
12456 | 12456 |
12457 // Check arguments. | 12457 // Check arguments. |
12458 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12458 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
12459 | 12459 |
12460 // Count the visible scopes. | 12460 // Count the visible scopes. |
12461 int n = 0; | 12461 int n = 0; |
12462 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { | 12462 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { |
12463 n++; | 12463 n++; |
12464 } | 12464 } |
12465 | 12465 |
12466 return Smi::FromInt(n); | 12466 return Smi::FromInt(n); |
12467 } | 12467 } |
12468 | 12468 |
12469 | 12469 |
12470 RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) { | 12470 RUNTIME_FUNCTION(Runtime_GetFunctionScopeDetails) { |
12471 HandleScope scope(isolate); | 12471 HandleScope scope(isolate); |
12472 ASSERT(args.length() == 2); | 12472 DCHECK(args.length() == 2); |
12473 | 12473 |
12474 // Check arguments. | 12474 // Check arguments. |
12475 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12475 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
12476 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 12476 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
12477 | 12477 |
12478 // Find the requested scope. | 12478 // Find the requested scope. |
12479 int n = 0; | 12479 int n = 0; |
12480 ScopeIterator it(isolate, fun); | 12480 ScopeIterator it(isolate, fun); |
12481 for (; !it.Done() && n < index; it.Next()) { | 12481 for (; !it.Done() && n < index; it.Next()) { |
12482 n++; | 12482 n++; |
(...skipping 26 matching lines...) Expand all Loading... |
12509 // args[0]: number or JsFunction: break id or function | 12509 // args[0]: number or JsFunction: break id or function |
12510 // args[1]: number: frame index (when arg[0] is break id) | 12510 // args[1]: number: frame index (when arg[0] is break id) |
12511 // args[2]: number: inlined frame index (when arg[0] is break id) | 12511 // args[2]: number: inlined frame index (when arg[0] is break id) |
12512 // args[3]: number: scope index | 12512 // args[3]: number: scope index |
12513 // args[4]: string: variable name | 12513 // args[4]: string: variable name |
12514 // args[5]: object: new value | 12514 // args[5]: object: new value |
12515 // | 12515 // |
12516 // Return true if success and false otherwise | 12516 // Return true if success and false otherwise |
12517 RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) { | 12517 RUNTIME_FUNCTION(Runtime_SetScopeVariableValue) { |
12518 HandleScope scope(isolate); | 12518 HandleScope scope(isolate); |
12519 ASSERT(args.length() == 6); | 12519 DCHECK(args.length() == 6); |
12520 | 12520 |
12521 // Check arguments. | 12521 // Check arguments. |
12522 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 12522 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
12523 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); | 12523 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); |
12524 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); | 12524 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); |
12525 | 12525 |
12526 bool res; | 12526 bool res; |
12527 if (args[0]->IsNumber()) { | 12527 if (args[0]->IsNumber()) { |
12528 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12528 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12529 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12529 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
(...skipping 13 matching lines...) Expand all Loading... |
12543 ScopeIterator it(isolate, fun); | 12543 ScopeIterator it(isolate, fun); |
12544 res = SetScopeVariableValue(&it, index, variable_name, new_value); | 12544 res = SetScopeVariableValue(&it, index, variable_name, new_value); |
12545 } | 12545 } |
12546 | 12546 |
12547 return isolate->heap()->ToBoolean(res); | 12547 return isolate->heap()->ToBoolean(res); |
12548 } | 12548 } |
12549 | 12549 |
12550 | 12550 |
12551 RUNTIME_FUNCTION(Runtime_DebugPrintScopes) { | 12551 RUNTIME_FUNCTION(Runtime_DebugPrintScopes) { |
12552 HandleScope scope(isolate); | 12552 HandleScope scope(isolate); |
12553 ASSERT(args.length() == 0); | 12553 DCHECK(args.length() == 0); |
12554 | 12554 |
12555 #ifdef DEBUG | 12555 #ifdef DEBUG |
12556 // Print the scopes for the top frame. | 12556 // Print the scopes for the top frame. |
12557 StackFrameLocator locator(isolate); | 12557 StackFrameLocator locator(isolate); |
12558 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 12558 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
12559 for (ScopeIterator it(isolate, frame, 0); | 12559 for (ScopeIterator it(isolate, frame, 0); |
12560 !it.Done(); | 12560 !it.Done(); |
12561 it.Next()) { | 12561 it.Next()) { |
12562 it.DebugPrint(); | 12562 it.DebugPrint(); |
12563 } | 12563 } |
12564 #endif | 12564 #endif |
12565 return isolate->heap()->undefined_value(); | 12565 return isolate->heap()->undefined_value(); |
12566 } | 12566 } |
12567 | 12567 |
12568 | 12568 |
12569 RUNTIME_FUNCTION(Runtime_GetThreadCount) { | 12569 RUNTIME_FUNCTION(Runtime_GetThreadCount) { |
12570 HandleScope scope(isolate); | 12570 HandleScope scope(isolate); |
12571 ASSERT(args.length() == 1); | 12571 DCHECK(args.length() == 1); |
12572 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12572 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12573 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12573 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12574 | 12574 |
12575 // Count all archived V8 threads. | 12575 // Count all archived V8 threads. |
12576 int n = 0; | 12576 int n = 0; |
12577 for (ThreadState* thread = | 12577 for (ThreadState* thread = |
12578 isolate->thread_manager()->FirstThreadStateInUse(); | 12578 isolate->thread_manager()->FirstThreadStateInUse(); |
12579 thread != NULL; | 12579 thread != NULL; |
12580 thread = thread->Next()) { | 12580 thread = thread->Next()) { |
12581 n++; | 12581 n++; |
(...skipping 10 matching lines...) Expand all Loading... |
12592 | 12592 |
12593 // Return an array with thread details | 12593 // Return an array with thread details |
12594 // args[0]: number: break id | 12594 // args[0]: number: break id |
12595 // args[1]: number: thread index | 12595 // args[1]: number: thread index |
12596 // | 12596 // |
12597 // The array returned contains the following information: | 12597 // The array returned contains the following information: |
12598 // 0: Is current thread? | 12598 // 0: Is current thread? |
12599 // 1: Thread id | 12599 // 1: Thread id |
12600 RUNTIME_FUNCTION(Runtime_GetThreadDetails) { | 12600 RUNTIME_FUNCTION(Runtime_GetThreadDetails) { |
12601 HandleScope scope(isolate); | 12601 HandleScope scope(isolate); |
12602 ASSERT(args.length() == 2); | 12602 DCHECK(args.length() == 2); |
12603 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12603 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12604 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12604 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12605 | 12605 |
12606 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 12606 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
12607 | 12607 |
12608 // Allocate array for result. | 12608 // Allocate array for result. |
12609 Handle<FixedArray> details = | 12609 Handle<FixedArray> details = |
12610 isolate->factory()->NewFixedArray(kThreadDetailsSize); | 12610 isolate->factory()->NewFixedArray(kThreadDetailsSize); |
12611 | 12611 |
12612 // Thread index 0 is current thread. | 12612 // Thread index 0 is current thread. |
(...skipping 25 matching lines...) Expand all Loading... |
12638 | 12638 |
12639 // Convert to JS array and return. | 12639 // Convert to JS array and return. |
12640 return *isolate->factory()->NewJSArrayWithElements(details); | 12640 return *isolate->factory()->NewJSArrayWithElements(details); |
12641 } | 12641 } |
12642 | 12642 |
12643 | 12643 |
12644 // Sets the disable break state | 12644 // Sets the disable break state |
12645 // args[0]: disable break state | 12645 // args[0]: disable break state |
12646 RUNTIME_FUNCTION(Runtime_SetDisableBreak) { | 12646 RUNTIME_FUNCTION(Runtime_SetDisableBreak) { |
12647 HandleScope scope(isolate); | 12647 HandleScope scope(isolate); |
12648 ASSERT(args.length() == 1); | 12648 DCHECK(args.length() == 1); |
12649 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); | 12649 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); |
12650 isolate->debug()->set_disable_break(disable_break); | 12650 isolate->debug()->set_disable_break(disable_break); |
12651 return isolate->heap()->undefined_value(); | 12651 return isolate->heap()->undefined_value(); |
12652 } | 12652 } |
12653 | 12653 |
12654 | 12654 |
12655 static bool IsPositionAlignmentCodeCorrect(int alignment) { | 12655 static bool IsPositionAlignmentCodeCorrect(int alignment) { |
12656 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; | 12656 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; |
12657 } | 12657 } |
12658 | 12658 |
12659 | 12659 |
12660 RUNTIME_FUNCTION(Runtime_GetBreakLocations) { | 12660 RUNTIME_FUNCTION(Runtime_GetBreakLocations) { |
12661 HandleScope scope(isolate); | 12661 HandleScope scope(isolate); |
12662 ASSERT(args.length() == 2); | 12662 DCHECK(args.length() == 2); |
12663 | 12663 |
12664 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12664 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
12665 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); | 12665 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); |
12666 | 12666 |
12667 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 12667 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
12668 return isolate->ThrowIllegalOperation(); | 12668 return isolate->ThrowIllegalOperation(); |
12669 } | 12669 } |
12670 BreakPositionAlignment alignment = | 12670 BreakPositionAlignment alignment = |
12671 static_cast<BreakPositionAlignment>(statement_aligned_code); | 12671 static_cast<BreakPositionAlignment>(statement_aligned_code); |
12672 | 12672 |
12673 Handle<SharedFunctionInfo> shared(fun->shared()); | 12673 Handle<SharedFunctionInfo> shared(fun->shared()); |
12674 // Find the number of break points | 12674 // Find the number of break points |
12675 Handle<Object> break_locations = | 12675 Handle<Object> break_locations = |
12676 Debug::GetSourceBreakLocations(shared, alignment); | 12676 Debug::GetSourceBreakLocations(shared, alignment); |
12677 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); | 12677 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); |
12678 // Return array as JS array | 12678 // Return array as JS array |
12679 return *isolate->factory()->NewJSArrayWithElements( | 12679 return *isolate->factory()->NewJSArrayWithElements( |
12680 Handle<FixedArray>::cast(break_locations)); | 12680 Handle<FixedArray>::cast(break_locations)); |
12681 } | 12681 } |
12682 | 12682 |
12683 | 12683 |
12684 // Set a break point in a function. | 12684 // Set a break point in a function. |
12685 // args[0]: function | 12685 // args[0]: function |
12686 // args[1]: number: break source position (within the function source) | 12686 // args[1]: number: break source position (within the function source) |
12687 // args[2]: number: break point object | 12687 // args[2]: number: break point object |
12688 RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) { | 12688 RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) { |
12689 HandleScope scope(isolate); | 12689 HandleScope scope(isolate); |
12690 ASSERT(args.length() == 3); | 12690 DCHECK(args.length() == 3); |
12691 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 12691 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
12692 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 12692 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
12693 RUNTIME_ASSERT(source_position >= function->shared()->start_position() && | 12693 RUNTIME_ASSERT(source_position >= function->shared()->start_position() && |
12694 source_position <= function->shared()->end_position()); | 12694 source_position <= function->shared()->end_position()); |
12695 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); | 12695 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); |
12696 | 12696 |
12697 // Set break point. | 12697 // Set break point. |
12698 RUNTIME_ASSERT(isolate->debug()->SetBreakPoint( | 12698 RUNTIME_ASSERT(isolate->debug()->SetBreakPoint( |
12699 function, break_point_object_arg, &source_position)); | 12699 function, break_point_object_arg, &source_position)); |
12700 | 12700 |
12701 return Smi::FromInt(source_position); | 12701 return Smi::FromInt(source_position); |
12702 } | 12702 } |
12703 | 12703 |
12704 | 12704 |
12705 // Changes the state of a break point in a script and returns source position | 12705 // Changes the state of a break point in a script and returns source position |
12706 // where break point was set. NOTE: Regarding performance see the NOTE for | 12706 // where break point was set. NOTE: Regarding performance see the NOTE for |
12707 // GetScriptFromScriptData. | 12707 // GetScriptFromScriptData. |
12708 // args[0]: script to set break point in | 12708 // args[0]: script to set break point in |
12709 // args[1]: number: break source position (within the script source) | 12709 // args[1]: number: break source position (within the script source) |
12710 // args[2]: number, breakpoint position alignment | 12710 // args[2]: number, breakpoint position alignment |
12711 // args[3]: number: break point object | 12711 // args[3]: number: break point object |
12712 RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { | 12712 RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { |
12713 HandleScope scope(isolate); | 12713 HandleScope scope(isolate); |
12714 ASSERT(args.length() == 4); | 12714 DCHECK(args.length() == 4); |
12715 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); | 12715 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); |
12716 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 12716 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
12717 RUNTIME_ASSERT(source_position >= 0); | 12717 RUNTIME_ASSERT(source_position >= 0); |
12718 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); | 12718 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); |
12719 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); | 12719 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); |
12720 | 12720 |
12721 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 12721 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
12722 return isolate->ThrowIllegalOperation(); | 12722 return isolate->ThrowIllegalOperation(); |
12723 } | 12723 } |
12724 BreakPositionAlignment alignment = | 12724 BreakPositionAlignment alignment = |
(...skipping 11 matching lines...) Expand all Loading... |
12736 } | 12736 } |
12737 | 12737 |
12738 return Smi::FromInt(source_position); | 12738 return Smi::FromInt(source_position); |
12739 } | 12739 } |
12740 | 12740 |
12741 | 12741 |
12742 // Clear a break point | 12742 // Clear a break point |
12743 // args[0]: number: break point object | 12743 // args[0]: number: break point object |
12744 RUNTIME_FUNCTION(Runtime_ClearBreakPoint) { | 12744 RUNTIME_FUNCTION(Runtime_ClearBreakPoint) { |
12745 HandleScope scope(isolate); | 12745 HandleScope scope(isolate); |
12746 ASSERT(args.length() == 1); | 12746 DCHECK(args.length() == 1); |
12747 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); | 12747 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); |
12748 | 12748 |
12749 // Clear break point. | 12749 // Clear break point. |
12750 isolate->debug()->ClearBreakPoint(break_point_object_arg); | 12750 isolate->debug()->ClearBreakPoint(break_point_object_arg); |
12751 | 12751 |
12752 return isolate->heap()->undefined_value(); | 12752 return isolate->heap()->undefined_value(); |
12753 } | 12753 } |
12754 | 12754 |
12755 | 12755 |
12756 // Change the state of break on exceptions. | 12756 // Change the state of break on exceptions. |
12757 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. | 12757 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. |
12758 // args[1]: Boolean indicating on/off. | 12758 // args[1]: Boolean indicating on/off. |
12759 RUNTIME_FUNCTION(Runtime_ChangeBreakOnException) { | 12759 RUNTIME_FUNCTION(Runtime_ChangeBreakOnException) { |
12760 HandleScope scope(isolate); | 12760 HandleScope scope(isolate); |
12761 ASSERT(args.length() == 2); | 12761 DCHECK(args.length() == 2); |
12762 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); | 12762 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); |
12763 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); | 12763 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); |
12764 | 12764 |
12765 // If the number doesn't match an enum value, the ChangeBreakOnException | 12765 // If the number doesn't match an enum value, the ChangeBreakOnException |
12766 // function will default to affecting caught exceptions. | 12766 // function will default to affecting caught exceptions. |
12767 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); | 12767 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); |
12768 // Update break point state. | 12768 // Update break point state. |
12769 isolate->debug()->ChangeBreakOnException(type, enable); | 12769 isolate->debug()->ChangeBreakOnException(type, enable); |
12770 return isolate->heap()->undefined_value(); | 12770 return isolate->heap()->undefined_value(); |
12771 } | 12771 } |
12772 | 12772 |
12773 | 12773 |
12774 // Returns the state of break on exceptions | 12774 // Returns the state of break on exceptions |
12775 // args[0]: boolean indicating uncaught exceptions | 12775 // args[0]: boolean indicating uncaught exceptions |
12776 RUNTIME_FUNCTION(Runtime_IsBreakOnException) { | 12776 RUNTIME_FUNCTION(Runtime_IsBreakOnException) { |
12777 HandleScope scope(isolate); | 12777 HandleScope scope(isolate); |
12778 ASSERT(args.length() == 1); | 12778 DCHECK(args.length() == 1); |
12779 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); | 12779 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); |
12780 | 12780 |
12781 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); | 12781 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); |
12782 bool result = isolate->debug()->IsBreakOnException(type); | 12782 bool result = isolate->debug()->IsBreakOnException(type); |
12783 return Smi::FromInt(result); | 12783 return Smi::FromInt(result); |
12784 } | 12784 } |
12785 | 12785 |
12786 | 12786 |
12787 // Prepare for stepping | 12787 // Prepare for stepping |
12788 // args[0]: break id for checking execution state | 12788 // args[0]: break id for checking execution state |
12789 // args[1]: step action from the enumeration StepAction | 12789 // args[1]: step action from the enumeration StepAction |
12790 // args[2]: number of times to perform the step, for step out it is the number | 12790 // args[2]: number of times to perform the step, for step out it is the number |
12791 // of frames to step down. | 12791 // of frames to step down. |
12792 RUNTIME_FUNCTION(Runtime_PrepareStep) { | 12792 RUNTIME_FUNCTION(Runtime_PrepareStep) { |
12793 HandleScope scope(isolate); | 12793 HandleScope scope(isolate); |
12794 ASSERT(args.length() == 4); | 12794 DCHECK(args.length() == 4); |
12795 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12795 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12796 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12796 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12797 | 12797 |
12798 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { | 12798 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { |
12799 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 12799 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
12800 } | 12800 } |
12801 | 12801 |
12802 CONVERT_NUMBER_CHECKED(int, wrapped_frame_id, Int32, args[3]); | 12802 CONVERT_NUMBER_CHECKED(int, wrapped_frame_id, Int32, args[3]); |
12803 | 12803 |
12804 StackFrame::Id frame_id; | 12804 StackFrame::Id frame_id; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12836 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), | 12836 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), |
12837 step_count, | 12837 step_count, |
12838 frame_id); | 12838 frame_id); |
12839 return isolate->heap()->undefined_value(); | 12839 return isolate->heap()->undefined_value(); |
12840 } | 12840 } |
12841 | 12841 |
12842 | 12842 |
12843 // Clear all stepping set by PrepareStep. | 12843 // Clear all stepping set by PrepareStep. |
12844 RUNTIME_FUNCTION(Runtime_ClearStepping) { | 12844 RUNTIME_FUNCTION(Runtime_ClearStepping) { |
12845 HandleScope scope(isolate); | 12845 HandleScope scope(isolate); |
12846 ASSERT(args.length() == 0); | 12846 DCHECK(args.length() == 0); |
12847 isolate->debug()->ClearStepping(); | 12847 isolate->debug()->ClearStepping(); |
12848 return isolate->heap()->undefined_value(); | 12848 return isolate->heap()->undefined_value(); |
12849 } | 12849 } |
12850 | 12850 |
12851 | 12851 |
12852 // Helper function to find or create the arguments object for | 12852 // Helper function to find or create the arguments object for |
12853 // Runtime_DebugEvaluate. | 12853 // Runtime_DebugEvaluate. |
12854 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( | 12854 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( |
12855 Isolate* isolate, | 12855 Isolate* isolate, |
12856 Handle<JSObject> target, | 12856 Handle<JSObject> target, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12920 // Evaluate a piece of JavaScript in the context of a stack frame for | 12920 // Evaluate a piece of JavaScript in the context of a stack frame for |
12921 // debugging. Things that need special attention are: | 12921 // debugging. Things that need special attention are: |
12922 // - Parameters and stack-allocated locals need to be materialized. Altered | 12922 // - Parameters and stack-allocated locals need to be materialized. Altered |
12923 // values need to be written back to the stack afterwards. | 12923 // values need to be written back to the stack afterwards. |
12924 // - The arguments object needs to materialized. | 12924 // - The arguments object needs to materialized. |
12925 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { | 12925 RUNTIME_FUNCTION(Runtime_DebugEvaluate) { |
12926 HandleScope scope(isolate); | 12926 HandleScope scope(isolate); |
12927 | 12927 |
12928 // Check the execution state and decode arguments frame and source to be | 12928 // Check the execution state and decode arguments frame and source to be |
12929 // evaluated. | 12929 // evaluated. |
12930 ASSERT(args.length() == 6); | 12930 DCHECK(args.length() == 6); |
12931 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12931 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12932 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12932 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12933 | 12933 |
12934 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12934 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12935 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12935 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
12936 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); | 12936 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); |
12937 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); | 12937 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); |
12938 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 5); | 12938 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 5); |
12939 | 12939 |
12940 // Handle the processing of break. | 12940 // Handle the processing of break. |
12941 DisableBreak disable_break_scope(isolate->debug(), disable_break); | 12941 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
12942 | 12942 |
12943 // Get the frame where the debugging is performed. | 12943 // Get the frame where the debugging is performed. |
12944 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12944 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12945 JavaScriptFrameIterator it(isolate, id); | 12945 JavaScriptFrameIterator it(isolate, id); |
12946 JavaScriptFrame* frame = it.frame(); | 12946 JavaScriptFrame* frame = it.frame(); |
12947 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 12947 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
12948 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 12948 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
12949 | 12949 |
12950 // Traverse the saved contexts chain to find the active context for the | 12950 // Traverse the saved contexts chain to find the active context for the |
12951 // selected frame. | 12951 // selected frame. |
12952 SaveContext* save = FindSavedContextForFrame(isolate, frame); | 12952 SaveContext* save = FindSavedContextForFrame(isolate, frame); |
12953 | 12953 |
12954 SaveContext savex(isolate); | 12954 SaveContext savex(isolate); |
12955 isolate->set_context(*(save->context())); | 12955 isolate->set_context(*(save->context())); |
12956 | 12956 |
12957 // Evaluate on the context of the frame. | 12957 // Evaluate on the context of the frame. |
12958 Handle<Context> context(Context::cast(frame->context())); | 12958 Handle<Context> context(Context::cast(frame->context())); |
12959 ASSERT(!context.is_null()); | 12959 DCHECK(!context.is_null()); |
12960 | 12960 |
12961 // Materialize stack locals and the arguments object. | 12961 // Materialize stack locals and the arguments object. |
12962 Handle<JSObject> materialized = | 12962 Handle<JSObject> materialized = |
12963 isolate->factory()->NewJSObject(isolate->object_function()); | 12963 isolate->factory()->NewJSObject(isolate->object_function()); |
12964 | 12964 |
12965 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 12965 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
12966 isolate, materialized, | 12966 isolate, materialized, |
12967 MaterializeStackLocalsWithFrameInspector( | 12967 MaterializeStackLocalsWithFrameInspector( |
12968 isolate, materialized, function, &frame_inspector)); | 12968 isolate, materialized, function, &frame_inspector)); |
12969 | 12969 |
(...skipping 16 matching lines...) Expand all Loading... |
12986 | 12986 |
12987 return *result; | 12987 return *result; |
12988 } | 12988 } |
12989 | 12989 |
12990 | 12990 |
12991 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { | 12991 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { |
12992 HandleScope scope(isolate); | 12992 HandleScope scope(isolate); |
12993 | 12993 |
12994 // Check the execution state and decode arguments frame and source to be | 12994 // Check the execution state and decode arguments frame and source to be |
12995 // evaluated. | 12995 // evaluated. |
12996 ASSERT(args.length() == 4); | 12996 DCHECK(args.length() == 4); |
12997 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12997 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12998 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12998 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12999 | 12999 |
13000 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13000 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
13001 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 13001 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
13002 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 3); | 13002 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 3); |
13003 | 13003 |
13004 // Handle the processing of break. | 13004 // Handle the processing of break. |
13005 DisableBreak disable_break_scope(isolate->debug(), disable_break); | 13005 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
13006 | 13006 |
(...skipping 14 matching lines...) Expand all Loading... |
13021 Handle<Object> result; | 13021 Handle<Object> result; |
13022 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13022 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13023 isolate, result, | 13023 isolate, result, |
13024 DebugEvaluate(isolate, context, context_extension, receiver, source)); | 13024 DebugEvaluate(isolate, context, context_extension, receiver, source)); |
13025 return *result; | 13025 return *result; |
13026 } | 13026 } |
13027 | 13027 |
13028 | 13028 |
13029 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { | 13029 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { |
13030 HandleScope scope(isolate); | 13030 HandleScope scope(isolate); |
13031 ASSERT(args.length() == 0); | 13031 DCHECK(args.length() == 0); |
13032 | 13032 |
13033 // Fill the script objects. | 13033 // Fill the script objects. |
13034 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); | 13034 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); |
13035 | 13035 |
13036 // Convert the script objects to proper JS objects. | 13036 // Convert the script objects to proper JS objects. |
13037 for (int i = 0; i < instances->length(); i++) { | 13037 for (int i = 0; i < instances->length(); i++) { |
13038 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); | 13038 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); |
13039 // Get the script wrapper in a local handle before calling GetScriptWrapper, | 13039 // Get the script wrapper in a local handle before calling GetScriptWrapper, |
13040 // because using | 13040 // because using |
13041 // instances->set(i, *GetScriptWrapper(script)) | 13041 // instances->set(i, *GetScriptWrapper(script)) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13118 return count; | 13118 return count; |
13119 } | 13119 } |
13120 | 13120 |
13121 | 13121 |
13122 // Scan the heap for objects with direct references to an object | 13122 // Scan the heap for objects with direct references to an object |
13123 // args[0]: the object to find references to | 13123 // args[0]: the object to find references to |
13124 // args[1]: constructor function for instances to exclude (Mirror) | 13124 // args[1]: constructor function for instances to exclude (Mirror) |
13125 // args[2]: the the maximum number of objects to return | 13125 // args[2]: the the maximum number of objects to return |
13126 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { | 13126 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { |
13127 HandleScope scope(isolate); | 13127 HandleScope scope(isolate); |
13128 ASSERT(args.length() == 3); | 13128 DCHECK(args.length() == 3); |
13129 | 13129 |
13130 // Check parameters. | 13130 // Check parameters. |
13131 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); | 13131 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); |
13132 CONVERT_ARG_HANDLE_CHECKED(Object, instance_filter, 1); | 13132 CONVERT_ARG_HANDLE_CHECKED(Object, instance_filter, 1); |
13133 RUNTIME_ASSERT(instance_filter->IsUndefined() || | 13133 RUNTIME_ASSERT(instance_filter->IsUndefined() || |
13134 instance_filter->IsJSObject()); | 13134 instance_filter->IsJSObject()); |
13135 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); | 13135 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); |
13136 RUNTIME_ASSERT(max_references >= 0); | 13136 RUNTIME_ASSERT(max_references >= 0); |
13137 | 13137 |
13138 | 13138 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13203 // Return the number of referencing objects found. | 13203 // Return the number of referencing objects found. |
13204 return count; | 13204 return count; |
13205 } | 13205 } |
13206 | 13206 |
13207 | 13207 |
13208 // Scan the heap for objects constructed by a specific function. | 13208 // Scan the heap for objects constructed by a specific function. |
13209 // args[0]: the constructor to find instances of | 13209 // args[0]: the constructor to find instances of |
13210 // args[1]: the the maximum number of objects to return | 13210 // args[1]: the the maximum number of objects to return |
13211 RUNTIME_FUNCTION(Runtime_DebugConstructedBy) { | 13211 RUNTIME_FUNCTION(Runtime_DebugConstructedBy) { |
13212 HandleScope scope(isolate); | 13212 HandleScope scope(isolate); |
13213 ASSERT(args.length() == 2); | 13213 DCHECK(args.length() == 2); |
13214 | 13214 |
13215 | 13215 |
13216 // Check parameters. | 13216 // Check parameters. |
13217 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | 13217 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); |
13218 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 13218 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
13219 RUNTIME_ASSERT(max_references >= 0); | 13219 RUNTIME_ASSERT(max_references >= 0); |
13220 | 13220 |
13221 // Get the number of referencing objects. | 13221 // Get the number of referencing objects. |
13222 int count; | 13222 int count; |
13223 // First perform a full GC in order to avoid dead objects and to make the heap | 13223 // First perform a full GC in order to avoid dead objects and to make the heap |
(...skipping 27 matching lines...) Expand all Loading... |
13251 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); | 13251 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); |
13252 JSArray::SetContent(Handle<JSArray>::cast(result), instances); | 13252 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
13253 return *result; | 13253 return *result; |
13254 } | 13254 } |
13255 | 13255 |
13256 | 13256 |
13257 // Find the effective prototype object as returned by __proto__. | 13257 // Find the effective prototype object as returned by __proto__. |
13258 // args[0]: the object to find the prototype for. | 13258 // args[0]: the object to find the prototype for. |
13259 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) { | 13259 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) { |
13260 HandleScope shs(isolate); | 13260 HandleScope shs(isolate); |
13261 ASSERT(args.length() == 1); | 13261 DCHECK(args.length() == 1); |
13262 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 13262 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
13263 return *GetPrototypeSkipHiddenPrototypes(isolate, obj); | 13263 return *GetPrototypeSkipHiddenPrototypes(isolate, obj); |
13264 } | 13264 } |
13265 | 13265 |
13266 | 13266 |
13267 // Patches script source (should be called upon BeforeCompile event). | 13267 // Patches script source (should be called upon BeforeCompile event). |
13268 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { | 13268 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { |
13269 HandleScope scope(isolate); | 13269 HandleScope scope(isolate); |
13270 ASSERT(args.length() == 2); | 13270 DCHECK(args.length() == 2); |
13271 | 13271 |
13272 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); | 13272 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); |
13273 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13273 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
13274 | 13274 |
13275 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); | 13275 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); |
13276 Handle<Script> script(Script::cast(script_wrapper->value())); | 13276 Handle<Script> script(Script::cast(script_wrapper->value())); |
13277 | 13277 |
13278 int compilation_state = script->compilation_state(); | 13278 int compilation_state = script->compilation_state(); |
13279 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 13279 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
13280 script->set_source(*source); | 13280 script->set_source(*source); |
13281 | 13281 |
13282 return isolate->heap()->undefined_value(); | 13282 return isolate->heap()->undefined_value(); |
13283 } | 13283 } |
13284 | 13284 |
13285 | 13285 |
13286 RUNTIME_FUNCTION(Runtime_SystemBreak) { | 13286 RUNTIME_FUNCTION(Runtime_SystemBreak) { |
13287 SealHandleScope shs(isolate); | 13287 SealHandleScope shs(isolate); |
13288 ASSERT(args.length() == 0); | 13288 DCHECK(args.length() == 0); |
13289 base::OS::DebugBreak(); | 13289 base::OS::DebugBreak(); |
13290 return isolate->heap()->undefined_value(); | 13290 return isolate->heap()->undefined_value(); |
13291 } | 13291 } |
13292 | 13292 |
13293 | 13293 |
13294 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { | 13294 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { |
13295 HandleScope scope(isolate); | 13295 HandleScope scope(isolate); |
13296 #ifdef DEBUG | 13296 #ifdef DEBUG |
13297 ASSERT(args.length() == 1); | 13297 DCHECK(args.length() == 1); |
13298 // Get the function and make sure it is compiled. | 13298 // Get the function and make sure it is compiled. |
13299 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13299 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
13300 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13300 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
13301 return isolate->heap()->exception(); | 13301 return isolate->heap()->exception(); |
13302 } | 13302 } |
13303 OFStream os(stdout); | 13303 OFStream os(stdout); |
13304 func->code()->Print(os); | 13304 func->code()->Print(os); |
13305 os << endl; | 13305 os << endl; |
13306 #endif // DEBUG | 13306 #endif // DEBUG |
13307 return isolate->heap()->undefined_value(); | 13307 return isolate->heap()->undefined_value(); |
13308 } | 13308 } |
13309 | 13309 |
13310 | 13310 |
13311 RUNTIME_FUNCTION(Runtime_DebugDisassembleConstructor) { | 13311 RUNTIME_FUNCTION(Runtime_DebugDisassembleConstructor) { |
13312 HandleScope scope(isolate); | 13312 HandleScope scope(isolate); |
13313 #ifdef DEBUG | 13313 #ifdef DEBUG |
13314 ASSERT(args.length() == 1); | 13314 DCHECK(args.length() == 1); |
13315 // Get the function and make sure it is compiled. | 13315 // Get the function and make sure it is compiled. |
13316 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13316 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
13317 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13317 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
13318 return isolate->heap()->exception(); | 13318 return isolate->heap()->exception(); |
13319 } | 13319 } |
13320 OFStream os(stdout); | 13320 OFStream os(stdout); |
13321 func->shared()->construct_stub()->Print(os); | 13321 func->shared()->construct_stub()->Print(os); |
13322 os << endl; | 13322 os << endl; |
13323 #endif // DEBUG | 13323 #endif // DEBUG |
13324 return isolate->heap()->undefined_value(); | 13324 return isolate->heap()->undefined_value(); |
13325 } | 13325 } |
13326 | 13326 |
13327 | 13327 |
13328 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { | 13328 RUNTIME_FUNCTION(Runtime_FunctionGetInferredName) { |
13329 SealHandleScope shs(isolate); | 13329 SealHandleScope shs(isolate); |
13330 ASSERT(args.length() == 1); | 13330 DCHECK(args.length() == 1); |
13331 | 13331 |
13332 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 13332 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
13333 return f->shared()->inferred_name(); | 13333 return f->shared()->inferred_name(); |
13334 } | 13334 } |
13335 | 13335 |
13336 | 13336 |
13337 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, | 13337 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
13338 Script* script, | 13338 Script* script, |
13339 FixedArray* buffer) { | 13339 FixedArray* buffer) { |
13340 DisallowHeapAllocation no_allocation; | 13340 DisallowHeapAllocation no_allocation; |
13341 int counter = 0; | 13341 int counter = 0; |
13342 int buffer_size = buffer->length(); | 13342 int buffer_size = buffer->length(); |
13343 for (HeapObject* obj = iterator->next(); | 13343 for (HeapObject* obj = iterator->next(); |
13344 obj != NULL; | 13344 obj != NULL; |
13345 obj = iterator->next()) { | 13345 obj = iterator->next()) { |
13346 ASSERT(obj != NULL); | 13346 DCHECK(obj != NULL); |
13347 if (!obj->IsSharedFunctionInfo()) { | 13347 if (!obj->IsSharedFunctionInfo()) { |
13348 continue; | 13348 continue; |
13349 } | 13349 } |
13350 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); | 13350 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); |
13351 if (shared->script() != script) { | 13351 if (shared->script() != script) { |
13352 continue; | 13352 continue; |
13353 } | 13353 } |
13354 if (counter < buffer_size) { | 13354 if (counter < buffer_size) { |
13355 buffer->set(counter, shared); | 13355 buffer->set(counter, shared); |
13356 } | 13356 } |
13357 counter++; | 13357 counter++; |
13358 } | 13358 } |
13359 return counter; | 13359 return counter; |
13360 } | 13360 } |
13361 | 13361 |
13362 | 13362 |
13363 // For a script finds all SharedFunctionInfo's in the heap that points | 13363 // For a script finds all SharedFunctionInfo's in the heap that points |
13364 // to this script. Returns JSArray of SharedFunctionInfo wrapped | 13364 // to this script. Returns JSArray of SharedFunctionInfo wrapped |
13365 // in OpaqueReferences. | 13365 // in OpaqueReferences. |
13366 RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { | 13366 RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { |
13367 HandleScope scope(isolate); | 13367 HandleScope scope(isolate); |
13368 CHECK(isolate->debug()->live_edit_enabled()); | 13368 CHECK(isolate->debug()->live_edit_enabled()); |
13369 ASSERT(args.length() == 1); | 13369 DCHECK(args.length() == 1); |
13370 CONVERT_ARG_CHECKED(JSValue, script_value, 0); | 13370 CONVERT_ARG_CHECKED(JSValue, script_value, 0); |
13371 | 13371 |
13372 RUNTIME_ASSERT(script_value->value()->IsScript()); | 13372 RUNTIME_ASSERT(script_value->value()->IsScript()); |
13373 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 13373 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
13374 | 13374 |
13375 const int kBufferSize = 32; | 13375 const int kBufferSize = 32; |
13376 | 13376 |
13377 Handle<FixedArray> array; | 13377 Handle<FixedArray> array; |
13378 array = isolate->factory()->NewFixedArray(kBufferSize); | 13378 array = isolate->factory()->NewFixedArray(kBufferSize); |
13379 int number; | 13379 int number; |
(...skipping 24 matching lines...) Expand all Loading... |
13404 // For a script calculates compilation information about all its functions. | 13404 // For a script calculates compilation information about all its functions. |
13405 // The script source is explicitly specified by the second argument. | 13405 // The script source is explicitly specified by the second argument. |
13406 // The source of the actual script is not used, however it is important that | 13406 // The source of the actual script is not used, however it is important that |
13407 // all generated code keeps references to this particular instance of script. | 13407 // all generated code keeps references to this particular instance of script. |
13408 // Returns a JSArray of compilation infos. The array is ordered so that | 13408 // Returns a JSArray of compilation infos. The array is ordered so that |
13409 // each function with all its descendant is always stored in a continues range | 13409 // each function with all its descendant is always stored in a continues range |
13410 // with the function itself going first. The root function is a script function. | 13410 // with the function itself going first. The root function is a script function. |
13411 RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) { | 13411 RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) { |
13412 HandleScope scope(isolate); | 13412 HandleScope scope(isolate); |
13413 CHECK(isolate->debug()->live_edit_enabled()); | 13413 CHECK(isolate->debug()->live_edit_enabled()); |
13414 ASSERT(args.length() == 2); | 13414 DCHECK(args.length() == 2); |
13415 CONVERT_ARG_CHECKED(JSValue, script, 0); | 13415 CONVERT_ARG_CHECKED(JSValue, script, 0); |
13416 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13416 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
13417 | 13417 |
13418 RUNTIME_ASSERT(script->value()->IsScript()); | 13418 RUNTIME_ASSERT(script->value()->IsScript()); |
13419 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 13419 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
13420 | 13420 |
13421 Handle<JSArray> result; | 13421 Handle<JSArray> result; |
13422 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13422 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13423 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); | 13423 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); |
13424 return *result; | 13424 return *result; |
13425 } | 13425 } |
13426 | 13426 |
13427 | 13427 |
13428 // Changes the source of the script to a new_source. | 13428 // Changes the source of the script to a new_source. |
13429 // If old_script_name is provided (i.e. is a String), also creates a copy of | 13429 // If old_script_name is provided (i.e. is a String), also creates a copy of |
13430 // the script with its original source and sends notification to debugger. | 13430 // the script with its original source and sends notification to debugger. |
13431 RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) { | 13431 RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) { |
13432 HandleScope scope(isolate); | 13432 HandleScope scope(isolate); |
13433 CHECK(isolate->debug()->live_edit_enabled()); | 13433 CHECK(isolate->debug()->live_edit_enabled()); |
13434 ASSERT(args.length() == 3); | 13434 DCHECK(args.length() == 3); |
13435 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); | 13435 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); |
13436 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); | 13436 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); |
13437 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); | 13437 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); |
13438 | 13438 |
13439 RUNTIME_ASSERT(original_script_value->value()->IsScript()); | 13439 RUNTIME_ASSERT(original_script_value->value()->IsScript()); |
13440 Handle<Script> original_script(Script::cast(original_script_value->value())); | 13440 Handle<Script> original_script(Script::cast(original_script_value->value())); |
13441 | 13441 |
13442 Handle<Object> old_script = LiveEdit::ChangeScriptSource( | 13442 Handle<Object> old_script = LiveEdit::ChangeScriptSource( |
13443 original_script, new_source, old_script_name); | 13443 original_script, new_source, old_script_name); |
13444 | 13444 |
13445 if (old_script->IsScript()) { | 13445 if (old_script->IsScript()) { |
13446 Handle<Script> script_handle = Handle<Script>::cast(old_script); | 13446 Handle<Script> script_handle = Handle<Script>::cast(old_script); |
13447 return *Script::GetWrapper(script_handle); | 13447 return *Script::GetWrapper(script_handle); |
13448 } else { | 13448 } else { |
13449 return isolate->heap()->null_value(); | 13449 return isolate->heap()->null_value(); |
13450 } | 13450 } |
13451 } | 13451 } |
13452 | 13452 |
13453 | 13453 |
13454 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { | 13454 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { |
13455 HandleScope scope(isolate); | 13455 HandleScope scope(isolate); |
13456 CHECK(isolate->debug()->live_edit_enabled()); | 13456 CHECK(isolate->debug()->live_edit_enabled()); |
13457 ASSERT(args.length() == 1); | 13457 DCHECK(args.length() == 1); |
13458 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); | 13458 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); |
13459 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13459 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
13460 | 13460 |
13461 LiveEdit::FunctionSourceUpdated(shared_info); | 13461 LiveEdit::FunctionSourceUpdated(shared_info); |
13462 return isolate->heap()->undefined_value(); | 13462 return isolate->heap()->undefined_value(); |
13463 } | 13463 } |
13464 | 13464 |
13465 | 13465 |
13466 // Replaces code of SharedFunctionInfo with a new one. | 13466 // Replaces code of SharedFunctionInfo with a new one. |
13467 RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) { | 13467 RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) { |
13468 HandleScope scope(isolate); | 13468 HandleScope scope(isolate); |
13469 CHECK(isolate->debug()->live_edit_enabled()); | 13469 CHECK(isolate->debug()->live_edit_enabled()); |
13470 ASSERT(args.length() == 2); | 13470 DCHECK(args.length() == 2); |
13471 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); | 13471 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); |
13472 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); | 13472 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); |
13473 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13473 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
13474 | 13474 |
13475 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); | 13475 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); |
13476 return isolate->heap()->undefined_value(); | 13476 return isolate->heap()->undefined_value(); |
13477 } | 13477 } |
13478 | 13478 |
13479 | 13479 |
13480 // Connects SharedFunctionInfo to another script. | 13480 // Connects SharedFunctionInfo to another script. |
13481 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) { | 13481 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) { |
13482 HandleScope scope(isolate); | 13482 HandleScope scope(isolate); |
13483 CHECK(isolate->debug()->live_edit_enabled()); | 13483 CHECK(isolate->debug()->live_edit_enabled()); |
13484 ASSERT(args.length() == 2); | 13484 DCHECK(args.length() == 2); |
13485 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); | 13485 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
13486 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); | 13486 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); |
13487 | 13487 |
13488 if (function_object->IsJSValue()) { | 13488 if (function_object->IsJSValue()) { |
13489 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); | 13489 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); |
13490 if (script_object->IsJSValue()) { | 13490 if (script_object->IsJSValue()) { |
13491 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); | 13491 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); |
13492 Script* script = Script::cast(JSValue::cast(*script_object)->value()); | 13492 Script* script = Script::cast(JSValue::cast(*script_object)->value()); |
13493 script_object = Handle<Object>(script, isolate); | 13493 script_object = Handle<Object>(script, isolate); |
13494 } | 13494 } |
13495 RUNTIME_ASSERT(function_wrapper->value()->IsSharedFunctionInfo()); | 13495 RUNTIME_ASSERT(function_wrapper->value()->IsSharedFunctionInfo()); |
13496 LiveEdit::SetFunctionScript(function_wrapper, script_object); | 13496 LiveEdit::SetFunctionScript(function_wrapper, script_object); |
13497 } else { | 13497 } else { |
13498 // Just ignore this. We may not have a SharedFunctionInfo for some functions | 13498 // Just ignore this. We may not have a SharedFunctionInfo for some functions |
13499 // and we check it in this function. | 13499 // and we check it in this function. |
13500 } | 13500 } |
13501 | 13501 |
13502 return isolate->heap()->undefined_value(); | 13502 return isolate->heap()->undefined_value(); |
13503 } | 13503 } |
13504 | 13504 |
13505 | 13505 |
13506 // In a code of a parent function replaces original function as embedded object | 13506 // In a code of a parent function replaces original function as embedded object |
13507 // with a substitution one. | 13507 // with a substitution one. |
13508 RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) { | 13508 RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) { |
13509 HandleScope scope(isolate); | 13509 HandleScope scope(isolate); |
13510 CHECK(isolate->debug()->live_edit_enabled()); | 13510 CHECK(isolate->debug()->live_edit_enabled()); |
13511 ASSERT(args.length() == 3); | 13511 DCHECK(args.length() == 3); |
13512 | 13512 |
13513 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); | 13513 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); |
13514 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); | 13514 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); |
13515 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); | 13515 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); |
13516 RUNTIME_ASSERT(parent_wrapper->value()->IsSharedFunctionInfo()); | 13516 RUNTIME_ASSERT(parent_wrapper->value()->IsSharedFunctionInfo()); |
13517 RUNTIME_ASSERT(orig_wrapper->value()->IsSharedFunctionInfo()); | 13517 RUNTIME_ASSERT(orig_wrapper->value()->IsSharedFunctionInfo()); |
13518 RUNTIME_ASSERT(subst_wrapper->value()->IsSharedFunctionInfo()); | 13518 RUNTIME_ASSERT(subst_wrapper->value()->IsSharedFunctionInfo()); |
13519 | 13519 |
13520 LiveEdit::ReplaceRefToNestedFunction( | 13520 LiveEdit::ReplaceRefToNestedFunction( |
13521 parent_wrapper, orig_wrapper, subst_wrapper); | 13521 parent_wrapper, orig_wrapper, subst_wrapper); |
13522 return isolate->heap()->undefined_value(); | 13522 return isolate->heap()->undefined_value(); |
13523 } | 13523 } |
13524 | 13524 |
13525 | 13525 |
13526 // Updates positions of a shared function info (first parameter) according | 13526 // Updates positions of a shared function info (first parameter) according |
13527 // to script source change. Text change is described in second parameter as | 13527 // to script source change. Text change is described in second parameter as |
13528 // array of groups of 3 numbers: | 13528 // array of groups of 3 numbers: |
13529 // (change_begin, change_end, change_end_new_position). | 13529 // (change_begin, change_end, change_end_new_position). |
13530 // Each group describes a change in text; groups are sorted by change_begin. | 13530 // Each group describes a change in text; groups are sorted by change_begin. |
13531 RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) { | 13531 RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) { |
13532 HandleScope scope(isolate); | 13532 HandleScope scope(isolate); |
13533 CHECK(isolate->debug()->live_edit_enabled()); | 13533 CHECK(isolate->debug()->live_edit_enabled()); |
13534 ASSERT(args.length() == 2); | 13534 DCHECK(args.length() == 2); |
13535 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13535 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
13536 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); | 13536 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); |
13537 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) | 13537 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) |
13538 | 13538 |
13539 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); | 13539 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); |
13540 return isolate->heap()->undefined_value(); | 13540 return isolate->heap()->undefined_value(); |
13541 } | 13541 } |
13542 | 13542 |
13543 | 13543 |
13544 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 13544 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
13545 // checks that none of them have activations on stacks (of any thread). | 13545 // checks that none of them have activations on stacks (of any thread). |
13546 // Returns array of the same length with corresponding results of | 13546 // Returns array of the same length with corresponding results of |
13547 // LiveEdit::FunctionPatchabilityStatus type. | 13547 // LiveEdit::FunctionPatchabilityStatus type. |
13548 RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) { | 13548 RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) { |
13549 HandleScope scope(isolate); | 13549 HandleScope scope(isolate); |
13550 CHECK(isolate->debug()->live_edit_enabled()); | 13550 CHECK(isolate->debug()->live_edit_enabled()); |
13551 ASSERT(args.length() == 2); | 13551 DCHECK(args.length() == 2); |
13552 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13552 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
13553 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); | 13553 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); |
13554 RUNTIME_ASSERT(shared_array->length()->IsSmi()); | 13554 RUNTIME_ASSERT(shared_array->length()->IsSmi()); |
13555 RUNTIME_ASSERT(shared_array->HasFastElements()) | 13555 RUNTIME_ASSERT(shared_array->HasFastElements()) |
13556 int array_length = Smi::cast(shared_array->length())->value(); | 13556 int array_length = Smi::cast(shared_array->length())->value(); |
13557 for (int i = 0; i < array_length; i++) { | 13557 for (int i = 0; i < array_length; i++) { |
13558 Handle<Object> element = | 13558 Handle<Object> element = |
13559 Object::GetElement(isolate, shared_array, i).ToHandleChecked(); | 13559 Object::GetElement(isolate, shared_array, i).ToHandleChecked(); |
13560 RUNTIME_ASSERT( | 13560 RUNTIME_ASSERT( |
13561 element->IsJSValue() && | 13561 element->IsJSValue() && |
13562 Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo()); | 13562 Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo()); |
13563 } | 13563 } |
13564 | 13564 |
13565 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); | 13565 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
13566 } | 13566 } |
13567 | 13567 |
13568 | 13568 |
13569 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 13569 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
13570 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 13570 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
13571 // of diff chunks. | 13571 // of diff chunks. |
13572 RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) { | 13572 RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) { |
13573 HandleScope scope(isolate); | 13573 HandleScope scope(isolate); |
13574 CHECK(isolate->debug()->live_edit_enabled()); | 13574 CHECK(isolate->debug()->live_edit_enabled()); |
13575 ASSERT(args.length() == 2); | 13575 DCHECK(args.length() == 2); |
13576 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); | 13576 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); |
13577 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); | 13577 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); |
13578 | 13578 |
13579 return *LiveEdit::CompareStrings(s1, s2); | 13579 return *LiveEdit::CompareStrings(s1, s2); |
13580 } | 13580 } |
13581 | 13581 |
13582 | 13582 |
13583 // Restarts a call frame and completely drops all frames above. | 13583 // Restarts a call frame and completely drops all frames above. |
13584 // Returns true if successful. Otherwise returns undefined or an error message. | 13584 // Returns true if successful. Otherwise returns undefined or an error message. |
13585 RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { | 13585 RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { |
13586 HandleScope scope(isolate); | 13586 HandleScope scope(isolate); |
13587 CHECK(isolate->debug()->live_edit_enabled()); | 13587 CHECK(isolate->debug()->live_edit_enabled()); |
13588 ASSERT(args.length() == 2); | 13588 DCHECK(args.length() == 2); |
13589 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 13589 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
13590 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 13590 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
13591 | 13591 |
13592 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 13592 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
13593 Heap* heap = isolate->heap(); | 13593 Heap* heap = isolate->heap(); |
13594 | 13594 |
13595 // Find the relevant frame with the requested index. | 13595 // Find the relevant frame with the requested index. |
13596 StackFrame::Id id = isolate->debug()->break_frame_id(); | 13596 StackFrame::Id id = isolate->debug()->break_frame_id(); |
13597 if (id == StackFrame::NO_ID) { | 13597 if (id == StackFrame::NO_ID) { |
13598 // If there are no JavaScript stack frames return undefined. | 13598 // If there are no JavaScript stack frames return undefined. |
(...skipping 14 matching lines...) Expand all Loading... |
13613 } | 13613 } |
13614 return heap->true_value(); | 13614 return heap->true_value(); |
13615 } | 13615 } |
13616 | 13616 |
13617 | 13617 |
13618 // A testing entry. Returns statement position which is the closest to | 13618 // A testing entry. Returns statement position which is the closest to |
13619 // source_position. | 13619 // source_position. |
13620 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { | 13620 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { |
13621 HandleScope scope(isolate); | 13621 HandleScope scope(isolate); |
13622 CHECK(isolate->debug()->live_edit_enabled()); | 13622 CHECK(isolate->debug()->live_edit_enabled()); |
13623 ASSERT(args.length() == 2); | 13623 DCHECK(args.length() == 2); |
13624 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13624 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
13625 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 13625 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
13626 | 13626 |
13627 Handle<Code> code(function->code(), isolate); | 13627 Handle<Code> code(function->code(), isolate); |
13628 | 13628 |
13629 if (code->kind() != Code::FUNCTION && | 13629 if (code->kind() != Code::FUNCTION && |
13630 code->kind() != Code::OPTIMIZED_FUNCTION) { | 13630 code->kind() != Code::OPTIMIZED_FUNCTION) { |
13631 return isolate->heap()->undefined_value(); | 13631 return isolate->heap()->undefined_value(); |
13632 } | 13632 } |
13633 | 13633 |
(...skipping 16 matching lines...) Expand all Loading... |
13650 | 13650 |
13651 return Smi::FromInt(closest_pc); | 13651 return Smi::FromInt(closest_pc); |
13652 } | 13652 } |
13653 | 13653 |
13654 | 13654 |
13655 // Calls specified function with or without entering the debugger. | 13655 // Calls specified function with or without entering the debugger. |
13656 // This is used in unit tests to run code as if debugger is entered or simply | 13656 // This is used in unit tests to run code as if debugger is entered or simply |
13657 // to have a stack with C++ frame in the middle. | 13657 // to have a stack with C++ frame in the middle. |
13658 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { | 13658 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { |
13659 HandleScope scope(isolate); | 13659 HandleScope scope(isolate); |
13660 ASSERT(args.length() == 2); | 13660 DCHECK(args.length() == 2); |
13661 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13661 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
13662 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); | 13662 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); |
13663 | 13663 |
13664 MaybeHandle<Object> maybe_result; | 13664 MaybeHandle<Object> maybe_result; |
13665 if (without_debugger) { | 13665 if (without_debugger) { |
13666 maybe_result = Execution::Call(isolate, | 13666 maybe_result = Execution::Call(isolate, |
13667 function, | 13667 function, |
13668 handle(function->global_proxy()), | 13668 handle(function->global_proxy()), |
13669 0, | 13669 0, |
13670 NULL); | 13670 NULL); |
13671 } else { | 13671 } else { |
13672 DebugScope debug_scope(isolate->debug()); | 13672 DebugScope debug_scope(isolate->debug()); |
13673 maybe_result = Execution::Call(isolate, | 13673 maybe_result = Execution::Call(isolate, |
13674 function, | 13674 function, |
13675 handle(function->global_proxy()), | 13675 handle(function->global_proxy()), |
13676 0, | 13676 0, |
13677 NULL); | 13677 NULL); |
13678 } | 13678 } |
13679 Handle<Object> result; | 13679 Handle<Object> result; |
13680 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 13680 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); |
13681 return *result; | 13681 return *result; |
13682 } | 13682 } |
13683 | 13683 |
13684 | 13684 |
13685 // Sets a v8 flag. | 13685 // Sets a v8 flag. |
13686 RUNTIME_FUNCTION(Runtime_SetFlags) { | 13686 RUNTIME_FUNCTION(Runtime_SetFlags) { |
13687 SealHandleScope shs(isolate); | 13687 SealHandleScope shs(isolate); |
13688 ASSERT(args.length() == 1); | 13688 DCHECK(args.length() == 1); |
13689 CONVERT_ARG_CHECKED(String, arg, 0); | 13689 CONVERT_ARG_CHECKED(String, arg, 0); |
13690 SmartArrayPointer<char> flags = | 13690 SmartArrayPointer<char> flags = |
13691 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 13691 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
13692 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); | 13692 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); |
13693 return isolate->heap()->undefined_value(); | 13693 return isolate->heap()->undefined_value(); |
13694 } | 13694 } |
13695 | 13695 |
13696 | 13696 |
13697 // Performs a GC. | 13697 // Performs a GC. |
13698 // Presently, it only does a full GC. | 13698 // Presently, it only does a full GC. |
13699 RUNTIME_FUNCTION(Runtime_CollectGarbage) { | 13699 RUNTIME_FUNCTION(Runtime_CollectGarbage) { |
13700 SealHandleScope shs(isolate); | 13700 SealHandleScope shs(isolate); |
13701 ASSERT(args.length() == 1); | 13701 DCHECK(args.length() == 1); |
13702 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); | 13702 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); |
13703 return isolate->heap()->undefined_value(); | 13703 return isolate->heap()->undefined_value(); |
13704 } | 13704 } |
13705 | 13705 |
13706 | 13706 |
13707 // Gets the current heap usage. | 13707 // Gets the current heap usage. |
13708 RUNTIME_FUNCTION(Runtime_GetHeapUsage) { | 13708 RUNTIME_FUNCTION(Runtime_GetHeapUsage) { |
13709 SealHandleScope shs(isolate); | 13709 SealHandleScope shs(isolate); |
13710 ASSERT(args.length() == 0); | 13710 DCHECK(args.length() == 0); |
13711 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); | 13711 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); |
13712 if (!Smi::IsValid(usage)) { | 13712 if (!Smi::IsValid(usage)) { |
13713 return *isolate->factory()->NewNumberFromInt(usage); | 13713 return *isolate->factory()->NewNumberFromInt(usage); |
13714 } | 13714 } |
13715 return Smi::FromInt(usage); | 13715 return Smi::FromInt(usage); |
13716 } | 13716 } |
13717 | 13717 |
13718 | 13718 |
13719 #ifdef V8_I18N_SUPPORT | 13719 #ifdef V8_I18N_SUPPORT |
13720 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) { | 13720 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) { |
13721 HandleScope scope(isolate); | 13721 HandleScope scope(isolate); |
13722 Factory* factory = isolate->factory(); | 13722 Factory* factory = isolate->factory(); |
13723 | 13723 |
13724 ASSERT(args.length() == 1); | 13724 DCHECK(args.length() == 1); |
13725 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); | 13725 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); |
13726 | 13726 |
13727 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); | 13727 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); |
13728 | 13728 |
13729 // Return value which denotes invalid language tag. | 13729 // Return value which denotes invalid language tag. |
13730 const char* const kInvalidTag = "invalid-tag"; | 13730 const char* const kInvalidTag = "invalid-tag"; |
13731 | 13731 |
13732 UErrorCode error = U_ZERO_ERROR; | 13732 UErrorCode error = U_ZERO_ERROR; |
13733 char icu_result[ULOC_FULLNAME_CAPACITY]; | 13733 char icu_result[ULOC_FULLNAME_CAPACITY]; |
13734 int icu_length = 0; | 13734 int icu_length = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
13749 } | 13749 } |
13750 | 13750 |
13751 return *factory->NewStringFromAsciiChecked(result); | 13751 return *factory->NewStringFromAsciiChecked(result); |
13752 } | 13752 } |
13753 | 13753 |
13754 | 13754 |
13755 RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) { | 13755 RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) { |
13756 HandleScope scope(isolate); | 13756 HandleScope scope(isolate); |
13757 Factory* factory = isolate->factory(); | 13757 Factory* factory = isolate->factory(); |
13758 | 13758 |
13759 ASSERT(args.length() == 1); | 13759 DCHECK(args.length() == 1); |
13760 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); | 13760 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); |
13761 | 13761 |
13762 const icu::Locale* available_locales = NULL; | 13762 const icu::Locale* available_locales = NULL; |
13763 int32_t count = 0; | 13763 int32_t count = 0; |
13764 | 13764 |
13765 if (service->IsUtf8EqualTo(CStrVector("collator"))) { | 13765 if (service->IsUtf8EqualTo(CStrVector("collator"))) { |
13766 available_locales = icu::Collator::getAvailableLocales(count); | 13766 available_locales = icu::Collator::getAvailableLocales(count); |
13767 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) { | 13767 } else if (service->IsUtf8EqualTo(CStrVector("numberformat"))) { |
13768 available_locales = icu::NumberFormat::getAvailableLocales(count); | 13768 available_locales = icu::NumberFormat::getAvailableLocales(count); |
13769 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) { | 13769 } else if (service->IsUtf8EqualTo(CStrVector("dateformat"))) { |
(...skipping 27 matching lines...) Expand all Loading... |
13797 } | 13797 } |
13798 | 13798 |
13799 return *locales; | 13799 return *locales; |
13800 } | 13800 } |
13801 | 13801 |
13802 | 13802 |
13803 RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) { | 13803 RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) { |
13804 HandleScope scope(isolate); | 13804 HandleScope scope(isolate); |
13805 Factory* factory = isolate->factory(); | 13805 Factory* factory = isolate->factory(); |
13806 | 13806 |
13807 ASSERT(args.length() == 0); | 13807 DCHECK(args.length() == 0); |
13808 | 13808 |
13809 icu::Locale default_locale; | 13809 icu::Locale default_locale; |
13810 | 13810 |
13811 // Set the locale | 13811 // Set the locale |
13812 char result[ULOC_FULLNAME_CAPACITY]; | 13812 char result[ULOC_FULLNAME_CAPACITY]; |
13813 UErrorCode status = U_ZERO_ERROR; | 13813 UErrorCode status = U_ZERO_ERROR; |
13814 uloc_toLanguageTag( | 13814 uloc_toLanguageTag( |
13815 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 13815 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
13816 if (U_SUCCESS(status)) { | 13816 if (U_SUCCESS(status)) { |
13817 return *factory->NewStringFromAsciiChecked(result); | 13817 return *factory->NewStringFromAsciiChecked(result); |
13818 } | 13818 } |
13819 | 13819 |
13820 return *factory->NewStringFromStaticAscii("und"); | 13820 return *factory->NewStringFromStaticAscii("und"); |
13821 } | 13821 } |
13822 | 13822 |
13823 | 13823 |
13824 RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) { | 13824 RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) { |
13825 HandleScope scope(isolate); | 13825 HandleScope scope(isolate); |
13826 Factory* factory = isolate->factory(); | 13826 Factory* factory = isolate->factory(); |
13827 | 13827 |
13828 ASSERT(args.length() == 1); | 13828 DCHECK(args.length() == 1); |
13829 | 13829 |
13830 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); | 13830 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); |
13831 | 13831 |
13832 uint32_t length = static_cast<uint32_t>(input->length()->Number()); | 13832 uint32_t length = static_cast<uint32_t>(input->length()->Number()); |
13833 // Set some limit to prevent fuzz tests from going OOM. | 13833 // Set some limit to prevent fuzz tests from going OOM. |
13834 // Can be bumped when callers' requirements change. | 13834 // Can be bumped when callers' requirements change. |
13835 RUNTIME_ASSERT(length < 100); | 13835 RUNTIME_ASSERT(length < 100); |
13836 Handle<FixedArray> output = factory->NewFixedArray(length); | 13836 Handle<FixedArray> output = factory->NewFixedArray(length); |
13837 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); | 13837 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); |
13838 Handle<Name> base = factory->NewStringFromStaticAscii("base"); | 13838 Handle<Name> base = factory->NewStringFromStaticAscii("base"); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13902 | 13902 |
13903 Handle<JSArray> result = factory->NewJSArrayWithElements(output); | 13903 Handle<JSArray> result = factory->NewJSArrayWithElements(output); |
13904 result->set_length(Smi::FromInt(length)); | 13904 result->set_length(Smi::FromInt(length)); |
13905 return *result; | 13905 return *result; |
13906 } | 13906 } |
13907 | 13907 |
13908 | 13908 |
13909 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) { | 13909 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) { |
13910 HandleScope scope(isolate); | 13910 HandleScope scope(isolate); |
13911 | 13911 |
13912 ASSERT(args.length() == 1); | 13912 DCHECK(args.length() == 1); |
13913 | 13913 |
13914 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13914 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
13915 | 13915 |
13916 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 13916 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
13917 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13917 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
13918 | 13918 |
13919 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13919 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
13920 Handle<Object> tag(obj->GetHiddenProperty(marker), isolate); | 13920 Handle<Object> tag(obj->GetHiddenProperty(marker), isolate); |
13921 return isolate->heap()->ToBoolean(!tag->IsTheHole()); | 13921 return isolate->heap()->ToBoolean(!tag->IsTheHole()); |
13922 } | 13922 } |
13923 | 13923 |
13924 | 13924 |
13925 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { | 13925 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { |
13926 HandleScope scope(isolate); | 13926 HandleScope scope(isolate); |
13927 | 13927 |
13928 ASSERT(args.length() == 2); | 13928 DCHECK(args.length() == 2); |
13929 | 13929 |
13930 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13930 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
13931 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); | 13931 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); |
13932 | 13932 |
13933 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 13933 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
13934 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13934 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
13935 | 13935 |
13936 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13936 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
13937 Handle<Object> tag(obj->GetHiddenProperty(marker), isolate); | 13937 Handle<Object> tag(obj->GetHiddenProperty(marker), isolate); |
13938 return isolate->heap()->ToBoolean( | 13938 return isolate->heap()->ToBoolean( |
13939 tag->IsString() && String::cast(*tag)->Equals(*expected_type)); | 13939 tag->IsString() && String::cast(*tag)->Equals(*expected_type)); |
13940 } | 13940 } |
13941 | 13941 |
13942 | 13942 |
13943 RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { | 13943 RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { |
13944 HandleScope scope(isolate); | 13944 HandleScope scope(isolate); |
13945 | 13945 |
13946 ASSERT(args.length() == 3); | 13946 DCHECK(args.length() == 3); |
13947 | 13947 |
13948 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); | 13948 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); |
13949 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 13949 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
13950 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); | 13950 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); |
13951 | 13951 |
13952 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13952 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
13953 JSObject::SetHiddenProperty(input, marker, type); | 13953 JSObject::SetHiddenProperty(input, marker, type); |
13954 | 13954 |
13955 marker = isolate->factory()->intl_impl_object_string(); | 13955 marker = isolate->factory()->intl_impl_object_string(); |
13956 JSObject::SetHiddenProperty(input, marker, impl); | 13956 JSObject::SetHiddenProperty(input, marker, impl); |
13957 | 13957 |
13958 return isolate->heap()->undefined_value(); | 13958 return isolate->heap()->undefined_value(); |
13959 } | 13959 } |
13960 | 13960 |
13961 | 13961 |
13962 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { | 13962 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { |
13963 HandleScope scope(isolate); | 13963 HandleScope scope(isolate); |
13964 | 13964 |
13965 ASSERT(args.length() == 1); | 13965 DCHECK(args.length() == 1); |
13966 | 13966 |
13967 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13967 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
13968 | 13968 |
13969 if (!input->IsJSObject()) { | 13969 if (!input->IsJSObject()) { |
13970 Vector< Handle<Object> > arguments = HandleVector(&input, 1); | 13970 Vector< Handle<Object> > arguments = HandleVector(&input, 1); |
13971 Handle<Object> type_error = | 13971 Handle<Object> type_error = |
13972 isolate->factory()->NewTypeError("not_intl_object", arguments); | 13972 isolate->factory()->NewTypeError("not_intl_object", arguments); |
13973 return isolate->Throw(*type_error); | 13973 return isolate->Throw(*type_error); |
13974 } | 13974 } |
13975 | 13975 |
13976 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13976 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
13977 | 13977 |
13978 Handle<String> marker = isolate->factory()->intl_impl_object_string(); | 13978 Handle<String> marker = isolate->factory()->intl_impl_object_string(); |
13979 Handle<Object> impl(obj->GetHiddenProperty(marker), isolate); | 13979 Handle<Object> impl(obj->GetHiddenProperty(marker), isolate); |
13980 if (impl->IsTheHole()) { | 13980 if (impl->IsTheHole()) { |
13981 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); | 13981 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); |
13982 Handle<Object> type_error = | 13982 Handle<Object> type_error = |
13983 isolate->factory()->NewTypeError("not_intl_object", arguments); | 13983 isolate->factory()->NewTypeError("not_intl_object", arguments); |
13984 return isolate->Throw(*type_error); | 13984 return isolate->Throw(*type_error); |
13985 } | 13985 } |
13986 return *impl; | 13986 return *impl; |
13987 } | 13987 } |
13988 | 13988 |
13989 | 13989 |
13990 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { | 13990 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { |
13991 HandleScope scope(isolate); | 13991 HandleScope scope(isolate); |
13992 | 13992 |
13993 ASSERT(args.length() == 3); | 13993 DCHECK(args.length() == 3); |
13994 | 13994 |
13995 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 13995 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
13996 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 13996 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
13997 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 13997 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
13998 | 13998 |
13999 Handle<ObjectTemplateInfo> date_format_template = | 13999 Handle<ObjectTemplateInfo> date_format_template = |
14000 I18N::GetTemplate(isolate); | 14000 I18N::GetTemplate(isolate); |
14001 | 14001 |
14002 // Create an empty object wrapper. | 14002 // Create an empty object wrapper. |
14003 Handle<JSObject> local_object; | 14003 Handle<JSObject> local_object; |
(...skipping 19 matching lines...) Expand all Loading... |
14023 GlobalHandles::MakeWeak(wrapper.location(), | 14023 GlobalHandles::MakeWeak(wrapper.location(), |
14024 reinterpret_cast<void*>(wrapper.location()), | 14024 reinterpret_cast<void*>(wrapper.location()), |
14025 DateFormat::DeleteDateFormat); | 14025 DateFormat::DeleteDateFormat); |
14026 return *local_object; | 14026 return *local_object; |
14027 } | 14027 } |
14028 | 14028 |
14029 | 14029 |
14030 RUNTIME_FUNCTION(Runtime_InternalDateFormat) { | 14030 RUNTIME_FUNCTION(Runtime_InternalDateFormat) { |
14031 HandleScope scope(isolate); | 14031 HandleScope scope(isolate); |
14032 | 14032 |
14033 ASSERT(args.length() == 2); | 14033 DCHECK(args.length() == 2); |
14034 | 14034 |
14035 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 14035 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
14036 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); | 14036 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); |
14037 | 14037 |
14038 Handle<Object> value; | 14038 Handle<Object> value; |
14039 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14039 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14040 isolate, value, Execution::ToNumber(isolate, date)); | 14040 isolate, value, Execution::ToNumber(isolate, date)); |
14041 | 14041 |
14042 icu::SimpleDateFormat* date_format = | 14042 icu::SimpleDateFormat* date_format = |
14043 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 14043 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
14044 if (!date_format) return isolate->ThrowIllegalOperation(); | 14044 if (!date_format) return isolate->ThrowIllegalOperation(); |
14045 | 14045 |
14046 icu::UnicodeString result; | 14046 icu::UnicodeString result; |
14047 date_format->format(value->Number(), result); | 14047 date_format->format(value->Number(), result); |
14048 | 14048 |
14049 Handle<String> result_str; | 14049 Handle<String> result_str; |
14050 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14050 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14051 isolate, result_str, | 14051 isolate, result_str, |
14052 isolate->factory()->NewStringFromTwoByte( | 14052 isolate->factory()->NewStringFromTwoByte( |
14053 Vector<const uint16_t>( | 14053 Vector<const uint16_t>( |
14054 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14054 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
14055 result.length()))); | 14055 result.length()))); |
14056 return *result_str; | 14056 return *result_str; |
14057 } | 14057 } |
14058 | 14058 |
14059 | 14059 |
14060 RUNTIME_FUNCTION(Runtime_InternalDateParse) { | 14060 RUNTIME_FUNCTION(Runtime_InternalDateParse) { |
14061 HandleScope scope(isolate); | 14061 HandleScope scope(isolate); |
14062 | 14062 |
14063 ASSERT(args.length() == 2); | 14063 DCHECK(args.length() == 2); |
14064 | 14064 |
14065 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 14065 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
14066 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); | 14066 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); |
14067 | 14067 |
14068 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string)); | 14068 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string)); |
14069 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date)); | 14069 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date)); |
14070 icu::SimpleDateFormat* date_format = | 14070 icu::SimpleDateFormat* date_format = |
14071 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 14071 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
14072 if (!date_format) return isolate->ThrowIllegalOperation(); | 14072 if (!date_format) return isolate->ThrowIllegalOperation(); |
14073 | 14073 |
14074 UErrorCode status = U_ZERO_ERROR; | 14074 UErrorCode status = U_ZERO_ERROR; |
14075 UDate date = date_format->parse(u_date, status); | 14075 UDate date = date_format->parse(u_date, status); |
14076 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); | 14076 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); |
14077 | 14077 |
14078 Handle<Object> result; | 14078 Handle<Object> result; |
14079 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14079 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14080 isolate, result, | 14080 isolate, result, |
14081 Execution::NewDate(isolate, static_cast<double>(date))); | 14081 Execution::NewDate(isolate, static_cast<double>(date))); |
14082 ASSERT(result->IsJSDate()); | 14082 DCHECK(result->IsJSDate()); |
14083 return *result; | 14083 return *result; |
14084 } | 14084 } |
14085 | 14085 |
14086 | 14086 |
14087 RUNTIME_FUNCTION(Runtime_CreateNumberFormat) { | 14087 RUNTIME_FUNCTION(Runtime_CreateNumberFormat) { |
14088 HandleScope scope(isolate); | 14088 HandleScope scope(isolate); |
14089 | 14089 |
14090 ASSERT(args.length() == 3); | 14090 DCHECK(args.length() == 3); |
14091 | 14091 |
14092 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14092 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14093 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14093 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14094 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14094 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14095 | 14095 |
14096 Handle<ObjectTemplateInfo> number_format_template = | 14096 Handle<ObjectTemplateInfo> number_format_template = |
14097 I18N::GetTemplate(isolate); | 14097 I18N::GetTemplate(isolate); |
14098 | 14098 |
14099 // Create an empty object wrapper. | 14099 // Create an empty object wrapper. |
14100 Handle<JSObject> local_object; | 14100 Handle<JSObject> local_object; |
(...skipping 18 matching lines...) Expand all Loading... |
14119 GlobalHandles::MakeWeak(wrapper.location(), | 14119 GlobalHandles::MakeWeak(wrapper.location(), |
14120 reinterpret_cast<void*>(wrapper.location()), | 14120 reinterpret_cast<void*>(wrapper.location()), |
14121 NumberFormat::DeleteNumberFormat); | 14121 NumberFormat::DeleteNumberFormat); |
14122 return *local_object; | 14122 return *local_object; |
14123 } | 14123 } |
14124 | 14124 |
14125 | 14125 |
14126 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { | 14126 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { |
14127 HandleScope scope(isolate); | 14127 HandleScope scope(isolate); |
14128 | 14128 |
14129 ASSERT(args.length() == 2); | 14129 DCHECK(args.length() == 2); |
14130 | 14130 |
14131 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14131 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
14132 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); | 14132 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); |
14133 | 14133 |
14134 Handle<Object> value; | 14134 Handle<Object> value; |
14135 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14135 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14136 isolate, value, Execution::ToNumber(isolate, number)); | 14136 isolate, value, Execution::ToNumber(isolate, number)); |
14137 | 14137 |
14138 icu::DecimalFormat* number_format = | 14138 icu::DecimalFormat* number_format = |
14139 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); | 14139 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); |
14140 if (!number_format) return isolate->ThrowIllegalOperation(); | 14140 if (!number_format) return isolate->ThrowIllegalOperation(); |
14141 | 14141 |
14142 icu::UnicodeString result; | 14142 icu::UnicodeString result; |
14143 number_format->format(value->Number(), result); | 14143 number_format->format(value->Number(), result); |
14144 | 14144 |
14145 Handle<String> result_str; | 14145 Handle<String> result_str; |
14146 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14146 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14147 isolate, result_str, | 14147 isolate, result_str, |
14148 isolate->factory()->NewStringFromTwoByte( | 14148 isolate->factory()->NewStringFromTwoByte( |
14149 Vector<const uint16_t>( | 14149 Vector<const uint16_t>( |
14150 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14150 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
14151 result.length()))); | 14151 result.length()))); |
14152 return *result_str; | 14152 return *result_str; |
14153 } | 14153 } |
14154 | 14154 |
14155 | 14155 |
14156 RUNTIME_FUNCTION(Runtime_InternalNumberParse) { | 14156 RUNTIME_FUNCTION(Runtime_InternalNumberParse) { |
14157 HandleScope scope(isolate); | 14157 HandleScope scope(isolate); |
14158 | 14158 |
14159 ASSERT(args.length() == 2); | 14159 DCHECK(args.length() == 2); |
14160 | 14160 |
14161 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14161 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
14162 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); | 14162 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); |
14163 | 14163 |
14164 v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string)); | 14164 v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string)); |
14165 icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number)); | 14165 icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number)); |
14166 icu::DecimalFormat* number_format = | 14166 icu::DecimalFormat* number_format = |
14167 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); | 14167 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); |
14168 if (!number_format) return isolate->ThrowIllegalOperation(); | 14168 if (!number_format) return isolate->ThrowIllegalOperation(); |
14169 | 14169 |
(...skipping 18 matching lines...) Expand all Loading... |
14188 static_cast<double>(result.getInt64())); | 14188 static_cast<double>(result.getInt64())); |
14189 default: | 14189 default: |
14190 return isolate->heap()->undefined_value(); | 14190 return isolate->heap()->undefined_value(); |
14191 } | 14191 } |
14192 } | 14192 } |
14193 | 14193 |
14194 | 14194 |
14195 RUNTIME_FUNCTION(Runtime_CreateCollator) { | 14195 RUNTIME_FUNCTION(Runtime_CreateCollator) { |
14196 HandleScope scope(isolate); | 14196 HandleScope scope(isolate); |
14197 | 14197 |
14198 ASSERT(args.length() == 3); | 14198 DCHECK(args.length() == 3); |
14199 | 14199 |
14200 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14200 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14201 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14201 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14202 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14202 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14203 | 14203 |
14204 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); | 14204 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); |
14205 | 14205 |
14206 // Create an empty object wrapper. | 14206 // Create an empty object wrapper. |
14207 Handle<JSObject> local_object; | 14207 Handle<JSObject> local_object; |
14208 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14208 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
(...skipping 16 matching lines...) Expand all Loading... |
14225 GlobalHandles::MakeWeak(wrapper.location(), | 14225 GlobalHandles::MakeWeak(wrapper.location(), |
14226 reinterpret_cast<void*>(wrapper.location()), | 14226 reinterpret_cast<void*>(wrapper.location()), |
14227 Collator::DeleteCollator); | 14227 Collator::DeleteCollator); |
14228 return *local_object; | 14228 return *local_object; |
14229 } | 14229 } |
14230 | 14230 |
14231 | 14231 |
14232 RUNTIME_FUNCTION(Runtime_InternalCompare) { | 14232 RUNTIME_FUNCTION(Runtime_InternalCompare) { |
14233 HandleScope scope(isolate); | 14233 HandleScope scope(isolate); |
14234 | 14234 |
14235 ASSERT(args.length() == 3); | 14235 DCHECK(args.length() == 3); |
14236 | 14236 |
14237 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); | 14237 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); |
14238 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); | 14238 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); |
14239 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); | 14239 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); |
14240 | 14240 |
14241 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); | 14241 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); |
14242 if (!collator) return isolate->ThrowIllegalOperation(); | 14242 if (!collator) return isolate->ThrowIllegalOperation(); |
14243 | 14243 |
14244 v8::String::Value string_value1(v8::Utils::ToLocal(string1)); | 14244 v8::String::Value string_value1(v8::Utils::ToLocal(string1)); |
14245 v8::String::Value string_value2(v8::Utils::ToLocal(string2)); | 14245 v8::String::Value string_value2(v8::Utils::ToLocal(string2)); |
14246 const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1); | 14246 const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1); |
14247 const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2); | 14247 const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2); |
14248 UErrorCode status = U_ZERO_ERROR; | 14248 UErrorCode status = U_ZERO_ERROR; |
14249 UCollationResult result = collator->compare(u_string1, | 14249 UCollationResult result = collator->compare(u_string1, |
14250 string_value1.length(), | 14250 string_value1.length(), |
14251 u_string2, | 14251 u_string2, |
14252 string_value2.length(), | 14252 string_value2.length(), |
14253 status); | 14253 status); |
14254 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); | 14254 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
14255 | 14255 |
14256 return *isolate->factory()->NewNumberFromInt(result); | 14256 return *isolate->factory()->NewNumberFromInt(result); |
14257 } | 14257 } |
14258 | 14258 |
14259 | 14259 |
14260 RUNTIME_FUNCTION(Runtime_StringNormalize) { | 14260 RUNTIME_FUNCTION(Runtime_StringNormalize) { |
14261 HandleScope scope(isolate); | 14261 HandleScope scope(isolate); |
14262 static const UNormalizationMode normalizationForms[] = | 14262 static const UNormalizationMode normalizationForms[] = |
14263 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; | 14263 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; |
14264 | 14264 |
14265 ASSERT(args.length() == 2); | 14265 DCHECK(args.length() == 2); |
14266 | 14266 |
14267 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); | 14267 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); |
14268 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); | 14268 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); |
14269 RUNTIME_ASSERT(form_id >= 0 && | 14269 RUNTIME_ASSERT(form_id >= 0 && |
14270 static_cast<size_t>(form_id) < ARRAY_SIZE(normalizationForms)); | 14270 static_cast<size_t>(form_id) < ARRAY_SIZE(normalizationForms)); |
14271 | 14271 |
14272 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); | 14272 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); |
14273 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value); | 14273 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value); |
14274 | 14274 |
14275 // TODO(mnita): check Normalizer2 (not available in ICU 46) | 14275 // TODO(mnita): check Normalizer2 (not available in ICU 46) |
(...skipping 12 matching lines...) Expand all Loading... |
14288 Vector<const uint16_t>( | 14288 Vector<const uint16_t>( |
14289 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14289 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
14290 result.length()))); | 14290 result.length()))); |
14291 return *result_str; | 14291 return *result_str; |
14292 } | 14292 } |
14293 | 14293 |
14294 | 14294 |
14295 RUNTIME_FUNCTION(Runtime_CreateBreakIterator) { | 14295 RUNTIME_FUNCTION(Runtime_CreateBreakIterator) { |
14296 HandleScope scope(isolate); | 14296 HandleScope scope(isolate); |
14297 | 14297 |
14298 ASSERT(args.length() == 3); | 14298 DCHECK(args.length() == 3); |
14299 | 14299 |
14300 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14300 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14301 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14301 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14302 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14302 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14303 | 14303 |
14304 Handle<ObjectTemplateInfo> break_iterator_template = | 14304 Handle<ObjectTemplateInfo> break_iterator_template = |
14305 I18N::GetTemplate2(isolate); | 14305 I18N::GetTemplate2(isolate); |
14306 | 14306 |
14307 // Create an empty object wrapper. | 14307 // Create an empty object wrapper. |
14308 Handle<JSObject> local_object; | 14308 Handle<JSObject> local_object; |
(...skipping 22 matching lines...) Expand all Loading... |
14331 GlobalHandles::MakeWeak(wrapper.location(), | 14331 GlobalHandles::MakeWeak(wrapper.location(), |
14332 reinterpret_cast<void*>(wrapper.location()), | 14332 reinterpret_cast<void*>(wrapper.location()), |
14333 BreakIterator::DeleteBreakIterator); | 14333 BreakIterator::DeleteBreakIterator); |
14334 return *local_object; | 14334 return *local_object; |
14335 } | 14335 } |
14336 | 14336 |
14337 | 14337 |
14338 RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { | 14338 RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { |
14339 HandleScope scope(isolate); | 14339 HandleScope scope(isolate); |
14340 | 14340 |
14341 ASSERT(args.length() == 2); | 14341 DCHECK(args.length() == 2); |
14342 | 14342 |
14343 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14343 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14344 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); | 14344 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); |
14345 | 14345 |
14346 icu::BreakIterator* break_iterator = | 14346 icu::BreakIterator* break_iterator = |
14347 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14347 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14348 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14348 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14349 | 14349 |
14350 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( | 14350 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( |
14351 break_iterator_holder->GetInternalField(1)); | 14351 break_iterator_holder->GetInternalField(1)); |
14352 delete u_text; | 14352 delete u_text; |
14353 | 14353 |
14354 v8::String::Value text_value(v8::Utils::ToLocal(text)); | 14354 v8::String::Value text_value(v8::Utils::ToLocal(text)); |
14355 u_text = new icu::UnicodeString( | 14355 u_text = new icu::UnicodeString( |
14356 reinterpret_cast<const UChar*>(*text_value), text_value.length()); | 14356 reinterpret_cast<const UChar*>(*text_value), text_value.length()); |
14357 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); | 14357 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); |
14358 | 14358 |
14359 break_iterator->setText(*u_text); | 14359 break_iterator->setText(*u_text); |
14360 | 14360 |
14361 return isolate->heap()->undefined_value(); | 14361 return isolate->heap()->undefined_value(); |
14362 } | 14362 } |
14363 | 14363 |
14364 | 14364 |
14365 RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { | 14365 RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { |
14366 HandleScope scope(isolate); | 14366 HandleScope scope(isolate); |
14367 | 14367 |
14368 ASSERT(args.length() == 1); | 14368 DCHECK(args.length() == 1); |
14369 | 14369 |
14370 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14370 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14371 | 14371 |
14372 icu::BreakIterator* break_iterator = | 14372 icu::BreakIterator* break_iterator = |
14373 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14373 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14374 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14374 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14375 | 14375 |
14376 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); | 14376 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); |
14377 } | 14377 } |
14378 | 14378 |
14379 | 14379 |
14380 RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { | 14380 RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { |
14381 HandleScope scope(isolate); | 14381 HandleScope scope(isolate); |
14382 | 14382 |
14383 ASSERT(args.length() == 1); | 14383 DCHECK(args.length() == 1); |
14384 | 14384 |
14385 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14385 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14386 | 14386 |
14387 icu::BreakIterator* break_iterator = | 14387 icu::BreakIterator* break_iterator = |
14388 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14388 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14389 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14389 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14390 | 14390 |
14391 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); | 14391 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); |
14392 } | 14392 } |
14393 | 14393 |
14394 | 14394 |
14395 RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { | 14395 RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { |
14396 HandleScope scope(isolate); | 14396 HandleScope scope(isolate); |
14397 | 14397 |
14398 ASSERT(args.length() == 1); | 14398 DCHECK(args.length() == 1); |
14399 | 14399 |
14400 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14400 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14401 | 14401 |
14402 icu::BreakIterator* break_iterator = | 14402 icu::BreakIterator* break_iterator = |
14403 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14403 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14404 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14404 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14405 | 14405 |
14406 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); | 14406 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); |
14407 } | 14407 } |
14408 | 14408 |
14409 | 14409 |
14410 RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { | 14410 RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { |
14411 HandleScope scope(isolate); | 14411 HandleScope scope(isolate); |
14412 | 14412 |
14413 ASSERT(args.length() == 1); | 14413 DCHECK(args.length() == 1); |
14414 | 14414 |
14415 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14415 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14416 | 14416 |
14417 icu::BreakIterator* break_iterator = | 14417 icu::BreakIterator* break_iterator = |
14418 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14418 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14419 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14419 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14420 | 14420 |
14421 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. | 14421 // TODO(cira): Remove cast once ICU fixes base BreakIterator class. |
14422 icu::RuleBasedBreakIterator* rule_based_iterator = | 14422 icu::RuleBasedBreakIterator* rule_based_iterator = |
14423 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); | 14423 static_cast<icu::RuleBasedBreakIterator*>(break_iterator); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14473 return Script::GetWrapper(script); | 14473 return Script::GetWrapper(script); |
14474 } | 14474 } |
14475 | 14475 |
14476 | 14476 |
14477 // Get the script object from script data. NOTE: Regarding performance | 14477 // Get the script object from script data. NOTE: Regarding performance |
14478 // see the NOTE for GetScriptFromScriptData. | 14478 // see the NOTE for GetScriptFromScriptData. |
14479 // args[0]: script data for the script to find the source for | 14479 // args[0]: script data for the script to find the source for |
14480 RUNTIME_FUNCTION(Runtime_GetScript) { | 14480 RUNTIME_FUNCTION(Runtime_GetScript) { |
14481 HandleScope scope(isolate); | 14481 HandleScope scope(isolate); |
14482 | 14482 |
14483 ASSERT(args.length() == 1); | 14483 DCHECK(args.length() == 1); |
14484 | 14484 |
14485 CONVERT_ARG_CHECKED(String, script_name, 0); | 14485 CONVERT_ARG_CHECKED(String, script_name, 0); |
14486 | 14486 |
14487 // Find the requested script. | 14487 // Find the requested script. |
14488 Handle<Object> result = | 14488 Handle<Object> result = |
14489 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); | 14489 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); |
14490 return *result; | 14490 return *result; |
14491 } | 14491 } |
14492 | 14492 |
14493 | 14493 |
14494 // Collect the raw data for a stack trace. Returns an array of 4 | 14494 // Collect the raw data for a stack trace. Returns an array of 4 |
14495 // element segments each containing a receiver, function, code and | 14495 // element segments each containing a receiver, function, code and |
14496 // native code offset. | 14496 // native code offset. |
14497 RUNTIME_FUNCTION(Runtime_CollectStackTrace) { | 14497 RUNTIME_FUNCTION(Runtime_CollectStackTrace) { |
14498 HandleScope scope(isolate); | 14498 HandleScope scope(isolate); |
14499 ASSERT(args.length() == 2); | 14499 DCHECK(args.length() == 2); |
14500 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | 14500 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); |
14501 CONVERT_ARG_HANDLE_CHECKED(Object, caller, 1); | 14501 CONVERT_ARG_HANDLE_CHECKED(Object, caller, 1); |
14502 | 14502 |
14503 if (!isolate->bootstrapper()->IsActive()) { | 14503 if (!isolate->bootstrapper()->IsActive()) { |
14504 // Optionally capture a more detailed stack trace for the message. | 14504 // Optionally capture a more detailed stack trace for the message. |
14505 isolate->CaptureAndSetDetailedStackTrace(error_object); | 14505 isolate->CaptureAndSetDetailedStackTrace(error_object); |
14506 // Capture a simple stack trace for the stack property. | 14506 // Capture a simple stack trace for the stack property. |
14507 isolate->CaptureAndSetSimpleStackTrace(error_object, caller); | 14507 isolate->CaptureAndSetSimpleStackTrace(error_object, caller); |
14508 } | 14508 } |
14509 return isolate->heap()->undefined_value(); | 14509 return isolate->heap()->undefined_value(); |
14510 } | 14510 } |
14511 | 14511 |
14512 | 14512 |
14513 // Returns V8 version as a string. | 14513 // Returns V8 version as a string. |
14514 RUNTIME_FUNCTION(Runtime_GetV8Version) { | 14514 RUNTIME_FUNCTION(Runtime_GetV8Version) { |
14515 HandleScope scope(isolate); | 14515 HandleScope scope(isolate); |
14516 ASSERT(args.length() == 0); | 14516 DCHECK(args.length() == 0); |
14517 | 14517 |
14518 const char* version_string = v8::V8::GetVersion(); | 14518 const char* version_string = v8::V8::GetVersion(); |
14519 | 14519 |
14520 return *isolate->factory()->NewStringFromAsciiChecked(version_string); | 14520 return *isolate->factory()->NewStringFromAsciiChecked(version_string); |
14521 } | 14521 } |
14522 | 14522 |
14523 | 14523 |
14524 RUNTIME_FUNCTION(Runtime_Abort) { | 14524 RUNTIME_FUNCTION(Runtime_Abort) { |
14525 SealHandleScope shs(isolate); | 14525 SealHandleScope shs(isolate); |
14526 ASSERT(args.length() == 1); | 14526 DCHECK(args.length() == 1); |
14527 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 14527 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
14528 const char* message = GetBailoutReason( | 14528 const char* message = GetBailoutReason( |
14529 static_cast<BailoutReason>(message_id)); | 14529 static_cast<BailoutReason>(message_id)); |
14530 base::OS::PrintError("abort: %s\n", message); | 14530 base::OS::PrintError("abort: %s\n", message); |
14531 isolate->PrintStack(stderr); | 14531 isolate->PrintStack(stderr); |
14532 base::OS::Abort(); | 14532 base::OS::Abort(); |
14533 UNREACHABLE(); | 14533 UNREACHABLE(); |
14534 return NULL; | 14534 return NULL; |
14535 } | 14535 } |
14536 | 14536 |
14537 | 14537 |
14538 RUNTIME_FUNCTION(Runtime_AbortJS) { | 14538 RUNTIME_FUNCTION(Runtime_AbortJS) { |
14539 HandleScope scope(isolate); | 14539 HandleScope scope(isolate); |
14540 ASSERT(args.length() == 1); | 14540 DCHECK(args.length() == 1); |
14541 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); | 14541 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); |
14542 base::OS::PrintError("abort: %s\n", message->ToCString().get()); | 14542 base::OS::PrintError("abort: %s\n", message->ToCString().get()); |
14543 isolate->PrintStack(stderr); | 14543 isolate->PrintStack(stderr); |
14544 base::OS::Abort(); | 14544 base::OS::Abort(); |
14545 UNREACHABLE(); | 14545 UNREACHABLE(); |
14546 return NULL; | 14546 return NULL; |
14547 } | 14547 } |
14548 | 14548 |
14549 | 14549 |
14550 RUNTIME_FUNCTION(Runtime_FlattenString) { | 14550 RUNTIME_FUNCTION(Runtime_FlattenString) { |
14551 HandleScope scope(isolate); | 14551 HandleScope scope(isolate); |
14552 ASSERT(args.length() == 1); | 14552 DCHECK(args.length() == 1); |
14553 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 14553 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
14554 return *String::Flatten(str); | 14554 return *String::Flatten(str); |
14555 } | 14555 } |
14556 | 14556 |
14557 | 14557 |
14558 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { | 14558 RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) { |
14559 HandleScope scope(isolate); | 14559 HandleScope scope(isolate); |
14560 ASSERT(args.length() == 0); | 14560 DCHECK(args.length() == 0); |
14561 isolate->heap()->NotifyContextDisposed(); | 14561 isolate->heap()->NotifyContextDisposed(); |
14562 return isolate->heap()->undefined_value(); | 14562 return isolate->heap()->undefined_value(); |
14563 } | 14563 } |
14564 | 14564 |
14565 | 14565 |
14566 RUNTIME_FUNCTION(Runtime_LoadMutableDouble) { | 14566 RUNTIME_FUNCTION(Runtime_LoadMutableDouble) { |
14567 HandleScope scope(isolate); | 14567 HandleScope scope(isolate); |
14568 ASSERT(args.length() == 2); | 14568 DCHECK(args.length() == 2); |
14569 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 14569 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
14570 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); | 14570 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); |
14571 RUNTIME_ASSERT((index->value() & 1) == 1); | 14571 RUNTIME_ASSERT((index->value() & 1) == 1); |
14572 FieldIndex field_index = | 14572 FieldIndex field_index = |
14573 FieldIndex::ForLoadByFieldIndex(object->map(), index->value()); | 14573 FieldIndex::ForLoadByFieldIndex(object->map(), index->value()); |
14574 if (field_index.is_inobject()) { | 14574 if (field_index.is_inobject()) { |
14575 RUNTIME_ASSERT(field_index.property_index() < | 14575 RUNTIME_ASSERT(field_index.property_index() < |
14576 object->map()->inobject_properties()); | 14576 object->map()->inobject_properties()); |
14577 } else { | 14577 } else { |
14578 RUNTIME_ASSERT(field_index.outobject_array_index() < | 14578 RUNTIME_ASSERT(field_index.outobject_array_index() < |
14579 object->properties()->length()); | 14579 object->properties()->length()); |
14580 } | 14580 } |
14581 Handle<Object> raw_value(object->RawFastPropertyAt(field_index), isolate); | 14581 Handle<Object> raw_value(object->RawFastPropertyAt(field_index), isolate); |
14582 RUNTIME_ASSERT(raw_value->IsMutableHeapNumber()); | 14582 RUNTIME_ASSERT(raw_value->IsMutableHeapNumber()); |
14583 return *Object::WrapForRead(isolate, raw_value, Representation::Double()); | 14583 return *Object::WrapForRead(isolate, raw_value, Representation::Double()); |
14584 } | 14584 } |
14585 | 14585 |
14586 | 14586 |
14587 RUNTIME_FUNCTION(Runtime_TryMigrateInstance) { | 14587 RUNTIME_FUNCTION(Runtime_TryMigrateInstance) { |
14588 HandleScope scope(isolate); | 14588 HandleScope scope(isolate); |
14589 ASSERT(args.length() == 1); | 14589 DCHECK(args.length() == 1); |
14590 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 14590 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
14591 if (!object->IsJSObject()) return Smi::FromInt(0); | 14591 if (!object->IsJSObject()) return Smi::FromInt(0); |
14592 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 14592 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
14593 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); | 14593 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); |
14594 // This call must not cause lazy deopts, because it's called from deferred | 14594 // This call must not cause lazy deopts, because it's called from deferred |
14595 // code where we can't handle lazy deopts for lack of a suitable bailout | 14595 // code where we can't handle lazy deopts for lack of a suitable bailout |
14596 // ID. So we just try migration and signal failure if necessary, | 14596 // ID. So we just try migration and signal failure if necessary, |
14597 // which will also trigger a deopt. | 14597 // which will also trigger a deopt. |
14598 if (!JSObject::TryMigrateInstance(js_object)) return Smi::FromInt(0); | 14598 if (!JSObject::TryMigrateInstance(js_object)) return Smi::FromInt(0); |
14599 return *object; | 14599 return *object; |
(...skipping 20 matching lines...) Expand all Loading... |
14620 i >= JSFunctionResultCache::kEntriesIndex; | 14620 i >= JSFunctionResultCache::kEntriesIndex; |
14621 i -= 2) { | 14621 i -= 2) { |
14622 o = cache->get(i); | 14622 o = cache->get(i); |
14623 if (o == key) { | 14623 if (o == key) { |
14624 cache->set_finger_index(i); | 14624 cache->set_finger_index(i); |
14625 return cache->get(i + 1); | 14625 return cache->get(i + 1); |
14626 } | 14626 } |
14627 } | 14627 } |
14628 | 14628 |
14629 int size = cache->size(); | 14629 int size = cache->size(); |
14630 ASSERT(size <= cache->length()); | 14630 DCHECK(size <= cache->length()); |
14631 | 14631 |
14632 for (int i = size - 2; i > finger_index; i -= 2) { | 14632 for (int i = size - 2; i > finger_index; i -= 2) { |
14633 o = cache->get(i); | 14633 o = cache->get(i); |
14634 if (o == key) { | 14634 if (o == key) { |
14635 cache->set_finger_index(i); | 14635 cache->set_finger_index(i); |
14636 return cache->get(i + 1); | 14636 return cache->get(i + 1); |
14637 } | 14637 } |
14638 } | 14638 } |
14639 } | 14639 } |
14640 | 14640 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14672 if (size < cache_handle->length()) { | 14672 if (size < cache_handle->length()) { |
14673 cache_handle->set_size(size + JSFunctionResultCache::kEntrySize); | 14673 cache_handle->set_size(size + JSFunctionResultCache::kEntrySize); |
14674 index = size; | 14674 index = size; |
14675 } else { | 14675 } else { |
14676 index = finger_index + JSFunctionResultCache::kEntrySize; | 14676 index = finger_index + JSFunctionResultCache::kEntrySize; |
14677 if (index == cache_handle->length()) { | 14677 if (index == cache_handle->length()) { |
14678 index = JSFunctionResultCache::kEntriesIndex; | 14678 index = JSFunctionResultCache::kEntriesIndex; |
14679 } | 14679 } |
14680 } | 14680 } |
14681 | 14681 |
14682 ASSERT(index % 2 == 0); | 14682 DCHECK(index % 2 == 0); |
14683 ASSERT(index >= JSFunctionResultCache::kEntriesIndex); | 14683 DCHECK(index >= JSFunctionResultCache::kEntriesIndex); |
14684 ASSERT(index < cache_handle->length()); | 14684 DCHECK(index < cache_handle->length()); |
14685 | 14685 |
14686 cache_handle->set(index, *key_handle); | 14686 cache_handle->set(index, *key_handle); |
14687 cache_handle->set(index + 1, *value); | 14687 cache_handle->set(index + 1, *value); |
14688 cache_handle->set_finger_index(index); | 14688 cache_handle->set_finger_index(index); |
14689 | 14689 |
14690 #ifdef VERIFY_HEAP | 14690 #ifdef VERIFY_HEAP |
14691 if (FLAG_verify_heap) { | 14691 if (FLAG_verify_heap) { |
14692 cache_handle->JSFunctionResultCacheVerify(); | 14692 cache_handle->JSFunctionResultCacheVerify(); |
14693 } | 14693 } |
14694 #endif | 14694 #endif |
14695 | 14695 |
14696 return *value; | 14696 return *value; |
14697 } | 14697 } |
14698 | 14698 |
14699 | 14699 |
14700 RUNTIME_FUNCTION(Runtime_MessageGetStartPosition) { | 14700 RUNTIME_FUNCTION(Runtime_MessageGetStartPosition) { |
14701 SealHandleScope shs(isolate); | 14701 SealHandleScope shs(isolate); |
14702 ASSERT(args.length() == 1); | 14702 DCHECK(args.length() == 1); |
14703 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 14703 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
14704 return Smi::FromInt(message->start_position()); | 14704 return Smi::FromInt(message->start_position()); |
14705 } | 14705 } |
14706 | 14706 |
14707 | 14707 |
14708 RUNTIME_FUNCTION(Runtime_MessageGetScript) { | 14708 RUNTIME_FUNCTION(Runtime_MessageGetScript) { |
14709 SealHandleScope shs(isolate); | 14709 SealHandleScope shs(isolate); |
14710 ASSERT(args.length() == 1); | 14710 DCHECK(args.length() == 1); |
14711 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 14711 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
14712 return message->script(); | 14712 return message->script(); |
14713 } | 14713 } |
14714 | 14714 |
14715 | 14715 |
14716 #ifdef DEBUG | 14716 #ifdef DEBUG |
14717 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 14717 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
14718 // Exclude the code in release mode. | 14718 // Exclude the code in release mode. |
14719 RUNTIME_FUNCTION(Runtime_ListNatives) { | 14719 RUNTIME_FUNCTION(Runtime_ListNatives) { |
14720 HandleScope scope(isolate); | 14720 HandleScope scope(isolate); |
14721 ASSERT(args.length() == 0); | 14721 DCHECK(args.length() == 0); |
14722 #define COUNT_ENTRY(Name, argc, ressize) + 1 | 14722 #define COUNT_ENTRY(Name, argc, ressize) + 1 |
14723 int entry_count = 0 | 14723 int entry_count = 0 |
14724 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) | 14724 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
14725 INLINE_FUNCTION_LIST(COUNT_ENTRY) | 14725 INLINE_FUNCTION_LIST(COUNT_ENTRY) |
14726 INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY); | 14726 INLINE_OPTIMIZED_FUNCTION_LIST(COUNT_ENTRY); |
14727 #undef COUNT_ENTRY | 14727 #undef COUNT_ENTRY |
14728 Factory* factory = isolate->factory(); | 14728 Factory* factory = isolate->factory(); |
14729 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 14729 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
14730 int index = 0; | 14730 int index = 0; |
14731 bool inline_runtime_functions = false; | 14731 bool inline_runtime_functions = false; |
(...skipping 12 matching lines...) Expand all Loading... |
14744 pair_elements->set(1, Smi::FromInt(argc)); \ | 14744 pair_elements->set(1, Smi::FromInt(argc)); \ |
14745 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ | 14745 Handle<JSArray> pair = factory->NewJSArrayWithElements(pair_elements); \ |
14746 elements->set(index++, *pair); \ | 14746 elements->set(index++, *pair); \ |
14747 } | 14747 } |
14748 inline_runtime_functions = false; | 14748 inline_runtime_functions = false; |
14749 RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 14749 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
14750 INLINE_OPTIMIZED_FUNCTION_LIST(ADD_ENTRY) | 14750 INLINE_OPTIMIZED_FUNCTION_LIST(ADD_ENTRY) |
14751 inline_runtime_functions = true; | 14751 inline_runtime_functions = true; |
14752 INLINE_FUNCTION_LIST(ADD_ENTRY) | 14752 INLINE_FUNCTION_LIST(ADD_ENTRY) |
14753 #undef ADD_ENTRY | 14753 #undef ADD_ENTRY |
14754 ASSERT_EQ(index, entry_count); | 14754 DCHECK_EQ(index, entry_count); |
14755 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 14755 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
14756 return *result; | 14756 return *result; |
14757 } | 14757 } |
14758 #endif | 14758 #endif |
14759 | 14759 |
14760 | 14760 |
14761 RUNTIME_FUNCTION(Runtime_IS_VAR) { | 14761 RUNTIME_FUNCTION(Runtime_IS_VAR) { |
14762 UNREACHABLE(); // implemented as macro in the parser | 14762 UNREACHABLE(); // implemented as macro in the parser |
14763 return NULL; | 14763 return NULL; |
14764 } | 14764 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14801 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ | 14801 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
14802 } | 14802 } |
14803 | 14803 |
14804 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14804 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
14805 | 14805 |
14806 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14806 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
14807 | 14807 |
14808 | 14808 |
14809 RUNTIME_FUNCTION(Runtime_HaveSameMap) { | 14809 RUNTIME_FUNCTION(Runtime_HaveSameMap) { |
14810 SealHandleScope shs(isolate); | 14810 SealHandleScope shs(isolate); |
14811 ASSERT(args.length() == 2); | 14811 DCHECK(args.length() == 2); |
14812 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 14812 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
14813 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 14813 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
14814 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 14814 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
14815 } | 14815 } |
14816 | 14816 |
14817 | 14817 |
14818 RUNTIME_FUNCTION(Runtime_IsJSGlobalProxy) { | 14818 RUNTIME_FUNCTION(Runtime_IsJSGlobalProxy) { |
14819 SealHandleScope shs(isolate); | 14819 SealHandleScope shs(isolate); |
14820 ASSERT(args.length() == 1); | 14820 DCHECK(args.length() == 1); |
14821 CONVERT_ARG_CHECKED(Object, obj, 0); | 14821 CONVERT_ARG_CHECKED(Object, obj, 0); |
14822 return isolate->heap()->ToBoolean(obj->IsJSGlobalProxy()); | 14822 return isolate->heap()->ToBoolean(obj->IsJSGlobalProxy()); |
14823 } | 14823 } |
14824 | 14824 |
14825 | 14825 |
14826 RUNTIME_FUNCTION(Runtime_IsObserved) { | 14826 RUNTIME_FUNCTION(Runtime_IsObserved) { |
14827 SealHandleScope shs(isolate); | 14827 SealHandleScope shs(isolate); |
14828 ASSERT(args.length() == 1); | 14828 DCHECK(args.length() == 1); |
14829 | 14829 |
14830 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); | 14830 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); |
14831 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 14831 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
14832 ASSERT(!obj->IsJSGlobalProxy() || !obj->map()->is_observed()); | 14832 DCHECK(!obj->IsJSGlobalProxy() || !obj->map()->is_observed()); |
14833 return isolate->heap()->ToBoolean(obj->map()->is_observed()); | 14833 return isolate->heap()->ToBoolean(obj->map()->is_observed()); |
14834 } | 14834 } |
14835 | 14835 |
14836 | 14836 |
14837 RUNTIME_FUNCTION(Runtime_SetIsObserved) { | 14837 RUNTIME_FUNCTION(Runtime_SetIsObserved) { |
14838 HandleScope scope(isolate); | 14838 HandleScope scope(isolate); |
14839 ASSERT(args.length() == 1); | 14839 DCHECK(args.length() == 1); |
14840 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | 14840 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); |
14841 RUNTIME_ASSERT(!obj->IsJSGlobalProxy()); | 14841 RUNTIME_ASSERT(!obj->IsJSGlobalProxy()); |
14842 if (obj->IsJSProxy()) return isolate->heap()->undefined_value(); | 14842 if (obj->IsJSProxy()) return isolate->heap()->undefined_value(); |
14843 RUNTIME_ASSERT(!obj->map()->is_observed()); | 14843 RUNTIME_ASSERT(!obj->map()->is_observed()); |
14844 | 14844 |
14845 ASSERT(obj->IsJSObject()); | 14845 DCHECK(obj->IsJSObject()); |
14846 JSObject::SetObserved(Handle<JSObject>::cast(obj)); | 14846 JSObject::SetObserved(Handle<JSObject>::cast(obj)); |
14847 return isolate->heap()->undefined_value(); | 14847 return isolate->heap()->undefined_value(); |
14848 } | 14848 } |
14849 | 14849 |
14850 | 14850 |
14851 RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) { | 14851 RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) { |
14852 HandleScope scope(isolate); | 14852 HandleScope scope(isolate); |
14853 ASSERT(args.length() == 1); | 14853 DCHECK(args.length() == 1); |
14854 CONVERT_ARG_HANDLE_CHECKED(JSFunction, microtask, 0); | 14854 CONVERT_ARG_HANDLE_CHECKED(JSFunction, microtask, 0); |
14855 isolate->EnqueueMicrotask(microtask); | 14855 isolate->EnqueueMicrotask(microtask); |
14856 return isolate->heap()->undefined_value(); | 14856 return isolate->heap()->undefined_value(); |
14857 } | 14857 } |
14858 | 14858 |
14859 | 14859 |
14860 RUNTIME_FUNCTION(Runtime_RunMicrotasks) { | 14860 RUNTIME_FUNCTION(Runtime_RunMicrotasks) { |
14861 HandleScope scope(isolate); | 14861 HandleScope scope(isolate); |
14862 ASSERT(args.length() == 0); | 14862 DCHECK(args.length() == 0); |
14863 isolate->RunMicrotasks(); | 14863 isolate->RunMicrotasks(); |
14864 return isolate->heap()->undefined_value(); | 14864 return isolate->heap()->undefined_value(); |
14865 } | 14865 } |
14866 | 14866 |
14867 | 14867 |
14868 RUNTIME_FUNCTION(Runtime_GetObservationState) { | 14868 RUNTIME_FUNCTION(Runtime_GetObservationState) { |
14869 SealHandleScope shs(isolate); | 14869 SealHandleScope shs(isolate); |
14870 ASSERT(args.length() == 0); | 14870 DCHECK(args.length() == 0); |
14871 return isolate->heap()->observation_state(); | 14871 return isolate->heap()->observation_state(); |
14872 } | 14872 } |
14873 | 14873 |
14874 | 14874 |
14875 RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) { | 14875 RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) { |
14876 HandleScope scope(isolate); | 14876 HandleScope scope(isolate); |
14877 ASSERT(args.length() == 0); | 14877 DCHECK(args.length() == 0); |
14878 // TODO(adamk): Currently this runtime function is only called three times per | 14878 // TODO(adamk): Currently this runtime function is only called three times per |
14879 // isolate. If it's called more often, the map should be moved into the | 14879 // isolate. If it's called more often, the map should be moved into the |
14880 // strong root list. | 14880 // strong root list. |
14881 Handle<Map> map = | 14881 Handle<Map> map = |
14882 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); | 14882 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
14883 Handle<JSWeakMap> weakmap = | 14883 Handle<JSWeakMap> weakmap = |
14884 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); | 14884 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); |
14885 return *WeakCollectionInitialize(isolate, weakmap); | 14885 return *WeakCollectionInitialize(isolate, weakmap); |
14886 } | 14886 } |
14887 | 14887 |
14888 | 14888 |
14889 static bool ContextsHaveSameOrigin(Handle<Context> context1, | 14889 static bool ContextsHaveSameOrigin(Handle<Context> context1, |
14890 Handle<Context> context2) { | 14890 Handle<Context> context2) { |
14891 return context1->security_token() == context2->security_token(); | 14891 return context1->security_token() == context2->security_token(); |
14892 } | 14892 } |
14893 | 14893 |
14894 | 14894 |
14895 RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) { | 14895 RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) { |
14896 HandleScope scope(isolate); | 14896 HandleScope scope(isolate); |
14897 ASSERT(args.length() == 3); | 14897 DCHECK(args.length() == 3); |
14898 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); | 14898 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); |
14899 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); | 14899 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); |
14900 CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); | 14900 CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); |
14901 | 14901 |
14902 Handle<Context> observer_context(observer->context()->native_context()); | 14902 Handle<Context> observer_context(observer->context()->native_context()); |
14903 Handle<Context> object_context(object->GetCreationContext()); | 14903 Handle<Context> object_context(object->GetCreationContext()); |
14904 Handle<Context> record_context(record->GetCreationContext()); | 14904 Handle<Context> record_context(record->GetCreationContext()); |
14905 | 14905 |
14906 return isolate->heap()->ToBoolean( | 14906 return isolate->heap()->ToBoolean( |
14907 ContextsHaveSameOrigin(object_context, observer_context) && | 14907 ContextsHaveSameOrigin(object_context, observer_context) && |
14908 ContextsHaveSameOrigin(object_context, record_context)); | 14908 ContextsHaveSameOrigin(object_context, record_context)); |
14909 } | 14909 } |
14910 | 14910 |
14911 | 14911 |
14912 RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) { | 14912 RUNTIME_FUNCTION(Runtime_ObjectWasCreatedInCurrentOrigin) { |
14913 HandleScope scope(isolate); | 14913 HandleScope scope(isolate); |
14914 ASSERT(args.length() == 1); | 14914 DCHECK(args.length() == 1); |
14915 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 14915 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
14916 | 14916 |
14917 Handle<Context> creation_context(object->GetCreationContext(), isolate); | 14917 Handle<Context> creation_context(object->GetCreationContext(), isolate); |
14918 return isolate->heap()->ToBoolean( | 14918 return isolate->heap()->ToBoolean( |
14919 ContextsHaveSameOrigin(creation_context, isolate->native_context())); | 14919 ContextsHaveSameOrigin(creation_context, isolate->native_context())); |
14920 } | 14920 } |
14921 | 14921 |
14922 | 14922 |
14923 RUNTIME_FUNCTION(Runtime_GetObjectContextObjectObserve) { | 14923 RUNTIME_FUNCTION(Runtime_GetObjectContextObjectObserve) { |
14924 HandleScope scope(isolate); | 14924 HandleScope scope(isolate); |
14925 ASSERT(args.length() == 1); | 14925 DCHECK(args.length() == 1); |
14926 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 14926 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
14927 | 14927 |
14928 Handle<Context> context(object->GetCreationContext(), isolate); | 14928 Handle<Context> context(object->GetCreationContext(), isolate); |
14929 return context->native_object_observe(); | 14929 return context->native_object_observe(); |
14930 } | 14930 } |
14931 | 14931 |
14932 | 14932 |
14933 RUNTIME_FUNCTION(Runtime_GetObjectContextObjectGetNotifier) { | 14933 RUNTIME_FUNCTION(Runtime_GetObjectContextObjectGetNotifier) { |
14934 HandleScope scope(isolate); | 14934 HandleScope scope(isolate); |
14935 ASSERT(args.length() == 1); | 14935 DCHECK(args.length() == 1); |
14936 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 14936 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
14937 | 14937 |
14938 Handle<Context> context(object->GetCreationContext(), isolate); | 14938 Handle<Context> context(object->GetCreationContext(), isolate); |
14939 return context->native_object_get_notifier(); | 14939 return context->native_object_get_notifier(); |
14940 } | 14940 } |
14941 | 14941 |
14942 | 14942 |
14943 RUNTIME_FUNCTION(Runtime_GetObjectContextNotifierPerformChange) { | 14943 RUNTIME_FUNCTION(Runtime_GetObjectContextNotifierPerformChange) { |
14944 HandleScope scope(isolate); | 14944 HandleScope scope(isolate); |
14945 ASSERT(args.length() == 1); | 14945 DCHECK(args.length() == 1); |
14946 CONVERT_ARG_HANDLE_CHECKED(JSObject, object_info, 0); | 14946 CONVERT_ARG_HANDLE_CHECKED(JSObject, object_info, 0); |
14947 | 14947 |
14948 Handle<Context> context(object_info->GetCreationContext(), isolate); | 14948 Handle<Context> context(object_info->GetCreationContext(), isolate); |
14949 return context->native_object_notifier_perform_change(); | 14949 return context->native_object_notifier_perform_change(); |
14950 } | 14950 } |
14951 | 14951 |
14952 | 14952 |
14953 static Object* ArrayConstructorCommon(Isolate* isolate, | 14953 static Object* ArrayConstructorCommon(Isolate* isolate, |
14954 Handle<JSFunction> constructor, | 14954 Handle<JSFunction> constructor, |
14955 Handle<AllocationSite> site, | 14955 Handle<AllocationSite> site, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15030 | 15030 |
15031 RUNTIME_FUNCTION(Runtime_ArrayConstructor) { | 15031 RUNTIME_FUNCTION(Runtime_ArrayConstructor) { |
15032 HandleScope scope(isolate); | 15032 HandleScope scope(isolate); |
15033 // If we get 2 arguments then they are the stub parameters (constructor, type | 15033 // If we get 2 arguments then they are the stub parameters (constructor, type |
15034 // info). If we get 4, then the first one is a pointer to the arguments | 15034 // info). If we get 4, then the first one is a pointer to the arguments |
15035 // passed by the caller, and the last one is the length of the arguments | 15035 // passed by the caller, and the last one is the length of the arguments |
15036 // passed to the caller (redundant, but useful to check on the deoptimizer | 15036 // passed to the caller (redundant, but useful to check on the deoptimizer |
15037 // with an assert). | 15037 // with an assert). |
15038 Arguments empty_args(0, NULL); | 15038 Arguments empty_args(0, NULL); |
15039 bool no_caller_args = args.length() == 2; | 15039 bool no_caller_args = args.length() == 2; |
15040 ASSERT(no_caller_args || args.length() == 4); | 15040 DCHECK(no_caller_args || args.length() == 4); |
15041 int parameters_start = no_caller_args ? 0 : 1; | 15041 int parameters_start = no_caller_args ? 0 : 1; |
15042 Arguments* caller_args = no_caller_args | 15042 Arguments* caller_args = no_caller_args |
15043 ? &empty_args | 15043 ? &empty_args |
15044 : reinterpret_cast<Arguments*>(args[0]); | 15044 : reinterpret_cast<Arguments*>(args[0]); |
15045 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | 15045 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); |
15046 CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1); | 15046 CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1); |
15047 #ifdef DEBUG | 15047 #ifdef DEBUG |
15048 if (!no_caller_args) { | 15048 if (!no_caller_args) { |
15049 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2); | 15049 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2); |
15050 ASSERT(arg_count == caller_args->length()); | 15050 DCHECK(arg_count == caller_args->length()); |
15051 } | 15051 } |
15052 #endif | 15052 #endif |
15053 | 15053 |
15054 Handle<AllocationSite> site; | 15054 Handle<AllocationSite> site; |
15055 if (!type_info.is_null() && | 15055 if (!type_info.is_null() && |
15056 *type_info != isolate->heap()->undefined_value()) { | 15056 *type_info != isolate->heap()->undefined_value()) { |
15057 site = Handle<AllocationSite>::cast(type_info); | 15057 site = Handle<AllocationSite>::cast(type_info); |
15058 ASSERT(!site->SitePointsToLiteral()); | 15058 DCHECK(!site->SitePointsToLiteral()); |
15059 } | 15059 } |
15060 | 15060 |
15061 return ArrayConstructorCommon(isolate, | 15061 return ArrayConstructorCommon(isolate, |
15062 constructor, | 15062 constructor, |
15063 site, | 15063 site, |
15064 caller_args); | 15064 caller_args); |
15065 } | 15065 } |
15066 | 15066 |
15067 | 15067 |
15068 RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) { | 15068 RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) { |
15069 HandleScope scope(isolate); | 15069 HandleScope scope(isolate); |
15070 Arguments empty_args(0, NULL); | 15070 Arguments empty_args(0, NULL); |
15071 bool no_caller_args = args.length() == 1; | 15071 bool no_caller_args = args.length() == 1; |
15072 ASSERT(no_caller_args || args.length() == 3); | 15072 DCHECK(no_caller_args || args.length() == 3); |
15073 int parameters_start = no_caller_args ? 0 : 1; | 15073 int parameters_start = no_caller_args ? 0 : 1; |
15074 Arguments* caller_args = no_caller_args | 15074 Arguments* caller_args = no_caller_args |
15075 ? &empty_args | 15075 ? &empty_args |
15076 : reinterpret_cast<Arguments*>(args[0]); | 15076 : reinterpret_cast<Arguments*>(args[0]); |
15077 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | 15077 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); |
15078 #ifdef DEBUG | 15078 #ifdef DEBUG |
15079 if (!no_caller_args) { | 15079 if (!no_caller_args) { |
15080 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); | 15080 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); |
15081 ASSERT(arg_count == caller_args->length()); | 15081 DCHECK(arg_count == caller_args->length()); |
15082 } | 15082 } |
15083 #endif | 15083 #endif |
15084 return ArrayConstructorCommon(isolate, | 15084 return ArrayConstructorCommon(isolate, |
15085 constructor, | 15085 constructor, |
15086 Handle<AllocationSite>::null(), | 15086 Handle<AllocationSite>::null(), |
15087 caller_args); | 15087 caller_args); |
15088 } | 15088 } |
15089 | 15089 |
15090 | 15090 |
15091 RUNTIME_FUNCTION(Runtime_NormalizeElements) { | 15091 RUNTIME_FUNCTION(Runtime_NormalizeElements) { |
15092 HandleScope scope(isolate); | 15092 HandleScope scope(isolate); |
15093 ASSERT(args.length() == 1); | 15093 DCHECK(args.length() == 1); |
15094 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 15094 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
15095 RUNTIME_ASSERT(!array->HasExternalArrayElements() && | 15095 RUNTIME_ASSERT(!array->HasExternalArrayElements() && |
15096 !array->HasFixedTypedArrayElements()); | 15096 !array->HasFixedTypedArrayElements()); |
15097 JSObject::NormalizeElements(array); | 15097 JSObject::NormalizeElements(array); |
15098 return *array; | 15098 return *array; |
15099 } | 15099 } |
15100 | 15100 |
15101 | 15101 |
15102 RUNTIME_FUNCTION(Runtime_MaxSmi) { | 15102 RUNTIME_FUNCTION(Runtime_MaxSmi) { |
15103 SealHandleScope shs(isolate); | 15103 SealHandleScope shs(isolate); |
15104 ASSERT(args.length() == 0); | 15104 DCHECK(args.length() == 0); |
15105 return Smi::FromInt(Smi::kMaxValue); | 15105 return Smi::FromInt(Smi::kMaxValue); |
15106 } | 15106 } |
15107 | 15107 |
15108 | 15108 |
15109 // TODO(dcarney): remove this function when TurboFan supports it. | 15109 // TODO(dcarney): remove this function when TurboFan supports it. |
15110 // Takes the object to be iterated over and the result of GetPropertyNamesFast | 15110 // Takes the object to be iterated over and the result of GetPropertyNamesFast |
15111 // Returns pair (cache_array, cache_type). | 15111 // Returns pair (cache_array, cache_type). |
15112 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInInit) { | 15112 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInInit) { |
15113 SealHandleScope scope(isolate); | 15113 SealHandleScope scope(isolate); |
15114 ASSERT(args.length() == 2); | 15114 DCHECK(args.length() == 2); |
15115 // This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs. | 15115 // This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs. |
15116 // Not worth creating a macro atm as this function should be removed. | 15116 // Not worth creating a macro atm as this function should be removed. |
15117 if (!args[0]->IsJSReceiver() || !args[1]->IsObject()) { | 15117 if (!args[0]->IsJSReceiver() || !args[1]->IsObject()) { |
15118 Object* error = isolate->ThrowIllegalOperation(); | 15118 Object* error = isolate->ThrowIllegalOperation(); |
15119 return MakePair(error, isolate->heap()->undefined_value()); | 15119 return MakePair(error, isolate->heap()->undefined_value()); |
15120 } | 15120 } |
15121 Handle<JSReceiver> object = args.at<JSReceiver>(0); | 15121 Handle<JSReceiver> object = args.at<JSReceiver>(0); |
15122 Handle<Object> cache_type = args.at<Object>(1); | 15122 Handle<Object> cache_type = args.at<Object>(1); |
15123 if (cache_type->IsMap()) { | 15123 if (cache_type->IsMap()) { |
15124 // Enum cache case. | 15124 // Enum cache case. |
(...skipping 10 matching lines...) Expand all Loading... |
15135 // FixedArray case. | 15135 // FixedArray case. |
15136 Smi* new_cache_type = Smi::FromInt(object->IsJSProxy() ? 0 : 1); | 15136 Smi* new_cache_type = Smi::FromInt(object->IsJSProxy() ? 0 : 1); |
15137 return MakePair(*Handle<FixedArray>::cast(cache_type), new_cache_type); | 15137 return MakePair(*Handle<FixedArray>::cast(cache_type), new_cache_type); |
15138 } | 15138 } |
15139 } | 15139 } |
15140 | 15140 |
15141 | 15141 |
15142 // TODO(dcarney): remove this function when TurboFan supports it. | 15142 // TODO(dcarney): remove this function when TurboFan supports it. |
15143 RUNTIME_FUNCTION(Runtime_ForInCacheArrayLength) { | 15143 RUNTIME_FUNCTION(Runtime_ForInCacheArrayLength) { |
15144 SealHandleScope shs(isolate); | 15144 SealHandleScope shs(isolate); |
15145 ASSERT(args.length() == 2); | 15145 DCHECK(args.length() == 2); |
15146 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 0); | 15146 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 0); |
15147 CONVERT_ARG_HANDLE_CHECKED(FixedArray, array, 1); | 15147 CONVERT_ARG_HANDLE_CHECKED(FixedArray, array, 1); |
15148 int length = 0; | 15148 int length = 0; |
15149 if (cache_type->IsMap()) { | 15149 if (cache_type->IsMap()) { |
15150 length = Map::cast(*cache_type)->EnumLength(); | 15150 length = Map::cast(*cache_type)->EnumLength(); |
15151 } else { | 15151 } else { |
15152 ASSERT(cache_type->IsSmi()); | 15152 DCHECK(cache_type->IsSmi()); |
15153 length = array->length(); | 15153 length = array->length(); |
15154 } | 15154 } |
15155 return Smi::FromInt(length); | 15155 return Smi::FromInt(length); |
15156 } | 15156 } |
15157 | 15157 |
15158 | 15158 |
15159 // TODO(dcarney): remove this function when TurboFan supports it. | 15159 // TODO(dcarney): remove this function when TurboFan supports it. |
15160 // Takes (the object to be iterated over, | 15160 // Takes (the object to be iterated over, |
15161 // cache_array from ForInInit, | 15161 // cache_array from ForInInit, |
15162 // cache_type from ForInInit, | 15162 // cache_type from ForInInit, |
15163 // the current index) | 15163 // the current index) |
15164 // Returns pair (array[index], needs_filtering). | 15164 // Returns pair (array[index], needs_filtering). |
15165 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInNext) { | 15165 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInNext) { |
15166 SealHandleScope scope(isolate); | 15166 SealHandleScope scope(isolate); |
15167 ASSERT(args.length() == 4); | 15167 DCHECK(args.length() == 4); |
15168 // This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs. | 15168 // This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs. |
15169 // Not worth creating a macro atm as this function should be removed. | 15169 // Not worth creating a macro atm as this function should be removed. |
15170 if (!args[0]->IsJSReceiver() || !args[1]->IsFixedArray() || | 15170 if (!args[0]->IsJSReceiver() || !args[1]->IsFixedArray() || |
15171 !args[2]->IsObject() || !args[3]->IsSmi()) { | 15171 !args[2]->IsObject() || !args[3]->IsSmi()) { |
15172 Object* error = isolate->ThrowIllegalOperation(); | 15172 Object* error = isolate->ThrowIllegalOperation(); |
15173 return MakePair(error, isolate->heap()->undefined_value()); | 15173 return MakePair(error, isolate->heap()->undefined_value()); |
15174 } | 15174 } |
15175 Handle<JSReceiver> object = args.at<JSReceiver>(0); | 15175 Handle<JSReceiver> object = args.at<JSReceiver>(0); |
15176 Handle<FixedArray> array = args.at<FixedArray>(1); | 15176 Handle<FixedArray> array = args.at<FixedArray>(1); |
15177 Handle<Object> cache_type = args.at<Object>(2); | 15177 Handle<Object> cache_type = args.at<Object>(2); |
(...skipping 30 matching lines...) Expand all Loading... |
15208 U(IsStringWrapperSafeForDefaultValueOf) | 15208 U(IsStringWrapperSafeForDefaultValueOf) |
15209 U(GeneratorNext) | 15209 U(GeneratorNext) |
15210 U(GeneratorThrow) | 15210 U(GeneratorThrow) |
15211 U(DebugBreakInOptimizedCode) | 15211 U(DebugBreakInOptimizedCode) |
15212 | 15212 |
15213 #undef U | 15213 #undef U |
15214 | 15214 |
15215 | 15215 |
15216 RUNTIME_FUNCTION(RuntimeReference_IsSmi) { | 15216 RUNTIME_FUNCTION(RuntimeReference_IsSmi) { |
15217 SealHandleScope shs(isolate); | 15217 SealHandleScope shs(isolate); |
15218 ASSERT(args.length() == 1); | 15218 DCHECK(args.length() == 1); |
15219 CONVERT_ARG_CHECKED(Object, obj, 0); | 15219 CONVERT_ARG_CHECKED(Object, obj, 0); |
15220 return isolate->heap()->ToBoolean(obj->IsSmi()); | 15220 return isolate->heap()->ToBoolean(obj->IsSmi()); |
15221 } | 15221 } |
15222 | 15222 |
15223 | 15223 |
15224 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) { | 15224 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) { |
15225 SealHandleScope shs(isolate); | 15225 SealHandleScope shs(isolate); |
15226 ASSERT(args.length() == 1); | 15226 DCHECK(args.length() == 1); |
15227 CONVERT_ARG_CHECKED(Object, obj, 0); | 15227 CONVERT_ARG_CHECKED(Object, obj, 0); |
15228 return isolate->heap()->ToBoolean(obj->IsSmi() && | 15228 return isolate->heap()->ToBoolean(obj->IsSmi() && |
15229 Smi::cast(obj)->value() >= 0); | 15229 Smi::cast(obj)->value() >= 0); |
15230 } | 15230 } |
15231 | 15231 |
15232 | 15232 |
15233 RUNTIME_FUNCTION(RuntimeReference_IsArray) { | 15233 RUNTIME_FUNCTION(RuntimeReference_IsArray) { |
15234 SealHandleScope shs(isolate); | 15234 SealHandleScope shs(isolate); |
15235 ASSERT(args.length() == 1); | 15235 DCHECK(args.length() == 1); |
15236 CONVERT_ARG_CHECKED(Object, obj, 0); | 15236 CONVERT_ARG_CHECKED(Object, obj, 0); |
15237 return isolate->heap()->ToBoolean(obj->IsJSArray()); | 15237 return isolate->heap()->ToBoolean(obj->IsJSArray()); |
15238 } | 15238 } |
15239 | 15239 |
15240 | 15240 |
15241 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { | 15241 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { |
15242 SealHandleScope shs(isolate); | 15242 SealHandleScope shs(isolate); |
15243 ASSERT(args.length() == 1); | 15243 DCHECK(args.length() == 1); |
15244 CONVERT_ARG_CHECKED(Object, obj, 0); | 15244 CONVERT_ARG_CHECKED(Object, obj, 0); |
15245 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); | 15245 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
15246 } | 15246 } |
15247 | 15247 |
15248 | 15248 |
15249 RUNTIME_FUNCTION(RuntimeReference_IsConstructCall) { | 15249 RUNTIME_FUNCTION(RuntimeReference_IsConstructCall) { |
15250 SealHandleScope shs(isolate); | 15250 SealHandleScope shs(isolate); |
15251 ASSERT(args.length() == 0); | 15251 DCHECK(args.length() == 0); |
15252 JavaScriptFrameIterator it(isolate); | 15252 JavaScriptFrameIterator it(isolate); |
15253 JavaScriptFrame* frame = it.frame(); | 15253 JavaScriptFrame* frame = it.frame(); |
15254 return isolate->heap()->ToBoolean(frame->IsConstructor()); | 15254 return isolate->heap()->ToBoolean(frame->IsConstructor()); |
15255 } | 15255 } |
15256 | 15256 |
15257 | 15257 |
15258 RUNTIME_FUNCTION(RuntimeReference_CallFunction) { | 15258 RUNTIME_FUNCTION(RuntimeReference_CallFunction) { |
15259 SealHandleScope shs(isolate); | 15259 SealHandleScope shs(isolate); |
15260 return __RT_impl_Runtime_Call(args, isolate); | 15260 return __RT_impl_Runtime_Call(args, isolate); |
15261 } | 15261 } |
15262 | 15262 |
15263 | 15263 |
15264 RUNTIME_FUNCTION(RuntimeReference_ArgumentsLength) { | 15264 RUNTIME_FUNCTION(RuntimeReference_ArgumentsLength) { |
15265 SealHandleScope shs(isolate); | 15265 SealHandleScope shs(isolate); |
15266 ASSERT(args.length() == 0); | 15266 DCHECK(args.length() == 0); |
15267 JavaScriptFrameIterator it(isolate); | 15267 JavaScriptFrameIterator it(isolate); |
15268 JavaScriptFrame* frame = it.frame(); | 15268 JavaScriptFrame* frame = it.frame(); |
15269 return Smi::FromInt(frame->GetArgumentsLength()); | 15269 return Smi::FromInt(frame->GetArgumentsLength()); |
15270 } | 15270 } |
15271 | 15271 |
15272 | 15272 |
15273 RUNTIME_FUNCTION(RuntimeReference_Arguments) { | 15273 RUNTIME_FUNCTION(RuntimeReference_Arguments) { |
15274 SealHandleScope shs(isolate); | 15274 SealHandleScope shs(isolate); |
15275 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); | 15275 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
15276 } | 15276 } |
15277 | 15277 |
15278 | 15278 |
15279 RUNTIME_FUNCTION(RuntimeReference_ValueOf) { | 15279 RUNTIME_FUNCTION(RuntimeReference_ValueOf) { |
15280 SealHandleScope shs(isolate); | 15280 SealHandleScope shs(isolate); |
15281 ASSERT(args.length() == 1); | 15281 DCHECK(args.length() == 1); |
15282 CONVERT_ARG_CHECKED(Object, obj, 0); | 15282 CONVERT_ARG_CHECKED(Object, obj, 0); |
15283 if (!obj->IsJSValue()) return obj; | 15283 if (!obj->IsJSValue()) return obj; |
15284 return JSValue::cast(obj)->value(); | 15284 return JSValue::cast(obj)->value(); |
15285 } | 15285 } |
15286 | 15286 |
15287 | 15287 |
15288 RUNTIME_FUNCTION(RuntimeReference_SetValueOf) { | 15288 RUNTIME_FUNCTION(RuntimeReference_SetValueOf) { |
15289 SealHandleScope shs(isolate); | 15289 SealHandleScope shs(isolate); |
15290 ASSERT(args.length() == 2); | 15290 DCHECK(args.length() == 2); |
15291 CONVERT_ARG_CHECKED(Object, obj, 0); | 15291 CONVERT_ARG_CHECKED(Object, obj, 0); |
15292 CONVERT_ARG_CHECKED(Object, value, 1); | 15292 CONVERT_ARG_CHECKED(Object, value, 1); |
15293 if (!obj->IsJSValue()) return value; | 15293 if (!obj->IsJSValue()) return value; |
15294 JSValue::cast(obj)->set_value(value); | 15294 JSValue::cast(obj)->set_value(value); |
15295 return value; | 15295 return value; |
15296 } | 15296 } |
15297 | 15297 |
15298 | 15298 |
15299 RUNTIME_FUNCTION(RuntimeReference_DateField) { | 15299 RUNTIME_FUNCTION(RuntimeReference_DateField) { |
15300 SealHandleScope shs(isolate); | 15300 SealHandleScope shs(isolate); |
15301 ASSERT(args.length() == 2); | 15301 DCHECK(args.length() == 2); |
15302 CONVERT_ARG_CHECKED(Object, obj, 0); | 15302 CONVERT_ARG_CHECKED(Object, obj, 0); |
15303 CONVERT_SMI_ARG_CHECKED(index, 1); | 15303 CONVERT_SMI_ARG_CHECKED(index, 1); |
15304 if (!obj->IsJSDate()) { | 15304 if (!obj->IsJSDate()) { |
15305 HandleScope scope(isolate); | 15305 HandleScope scope(isolate); |
15306 return isolate->Throw(*isolate->factory()->NewTypeError( | 15306 return isolate->Throw(*isolate->factory()->NewTypeError( |
15307 "not_date_object", HandleVector<Object>(NULL, 0))); | 15307 "not_date_object", HandleVector<Object>(NULL, 0))); |
15308 } | 15308 } |
15309 JSDate* date = JSDate::cast(obj); | 15309 JSDate* date = JSDate::cast(obj); |
15310 if (index == 0) return date->value(); | 15310 if (index == 0) return date->value(); |
15311 return JSDate::GetField(date, Smi::FromInt(index)); | 15311 return JSDate::GetField(date, Smi::FromInt(index)); |
15312 } | 15312 } |
15313 | 15313 |
15314 | 15314 |
15315 RUNTIME_FUNCTION(RuntimeReference_StringCharFromCode) { | 15315 RUNTIME_FUNCTION(RuntimeReference_StringCharFromCode) { |
15316 SealHandleScope shs(isolate); | 15316 SealHandleScope shs(isolate); |
15317 return __RT_impl_Runtime_CharFromCode(args, isolate); | 15317 return __RT_impl_Runtime_CharFromCode(args, isolate); |
15318 } | 15318 } |
15319 | 15319 |
15320 | 15320 |
15321 RUNTIME_FUNCTION(RuntimeReference_StringCharAt) { | 15321 RUNTIME_FUNCTION(RuntimeReference_StringCharAt) { |
15322 SealHandleScope shs(isolate); | 15322 SealHandleScope shs(isolate); |
15323 ASSERT(args.length() == 2); | 15323 DCHECK(args.length() == 2); |
15324 if (!args[0]->IsString()) return Smi::FromInt(0); | 15324 if (!args[0]->IsString()) return Smi::FromInt(0); |
15325 if (!args[1]->IsNumber()) return Smi::FromInt(0); | 15325 if (!args[1]->IsNumber()) return Smi::FromInt(0); |
15326 if (std::isinf(args.number_at(1))) return isolate->heap()->empty_string(); | 15326 if (std::isinf(args.number_at(1))) return isolate->heap()->empty_string(); |
15327 Object* code = __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 15327 Object* code = __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
15328 if (code->IsNaN()) return isolate->heap()->empty_string(); | 15328 if (code->IsNaN()) return isolate->heap()->empty_string(); |
15329 return __RT_impl_Runtime_CharFromCode(Arguments(1, &code), isolate); | 15329 return __RT_impl_Runtime_CharFromCode(Arguments(1, &code), isolate); |
15330 } | 15330 } |
15331 | 15331 |
15332 | 15332 |
15333 RUNTIME_FUNCTION(RuntimeReference_OneByteSeqStringSetChar) { | 15333 RUNTIME_FUNCTION(RuntimeReference_OneByteSeqStringSetChar) { |
15334 SealHandleScope shs(isolate); | 15334 SealHandleScope shs(isolate); |
15335 ASSERT(args.length() == 3); | 15335 DCHECK(args.length() == 3); |
15336 CONVERT_ARG_CHECKED(SeqOneByteString, string, 0); | 15336 CONVERT_ARG_CHECKED(SeqOneByteString, string, 0); |
15337 CONVERT_SMI_ARG_CHECKED(index, 1); | 15337 CONVERT_SMI_ARG_CHECKED(index, 1); |
15338 CONVERT_SMI_ARG_CHECKED(value, 2); | 15338 CONVERT_SMI_ARG_CHECKED(value, 2); |
15339 string->SeqOneByteStringSet(index, value); | 15339 string->SeqOneByteStringSet(index, value); |
15340 return string; | 15340 return string; |
15341 } | 15341 } |
15342 | 15342 |
15343 | 15343 |
15344 RUNTIME_FUNCTION(RuntimeReference_TwoByteSeqStringSetChar) { | 15344 RUNTIME_FUNCTION(RuntimeReference_TwoByteSeqStringSetChar) { |
15345 SealHandleScope shs(isolate); | 15345 SealHandleScope shs(isolate); |
15346 ASSERT(args.length() == 3); | 15346 DCHECK(args.length() == 3); |
15347 CONVERT_ARG_CHECKED(SeqTwoByteString, string, 0); | 15347 CONVERT_ARG_CHECKED(SeqTwoByteString, string, 0); |
15348 CONVERT_SMI_ARG_CHECKED(index, 1); | 15348 CONVERT_SMI_ARG_CHECKED(index, 1); |
15349 CONVERT_SMI_ARG_CHECKED(value, 2); | 15349 CONVERT_SMI_ARG_CHECKED(value, 2); |
15350 string->SeqTwoByteStringSet(index, value); | 15350 string->SeqTwoByteStringSet(index, value); |
15351 return string; | 15351 return string; |
15352 } | 15352 } |
15353 | 15353 |
15354 | 15354 |
15355 RUNTIME_FUNCTION(RuntimeReference_ObjectEquals) { | 15355 RUNTIME_FUNCTION(RuntimeReference_ObjectEquals) { |
15356 SealHandleScope shs(isolate); | 15356 SealHandleScope shs(isolate); |
15357 ASSERT(args.length() == 2); | 15357 DCHECK(args.length() == 2); |
15358 CONVERT_ARG_CHECKED(Object, obj1, 0); | 15358 CONVERT_ARG_CHECKED(Object, obj1, 0); |
15359 CONVERT_ARG_CHECKED(Object, obj2, 1); | 15359 CONVERT_ARG_CHECKED(Object, obj2, 1); |
15360 return isolate->heap()->ToBoolean(obj1 == obj2); | 15360 return isolate->heap()->ToBoolean(obj1 == obj2); |
15361 } | 15361 } |
15362 | 15362 |
15363 | 15363 |
15364 RUNTIME_FUNCTION(RuntimeReference_IsObject) { | 15364 RUNTIME_FUNCTION(RuntimeReference_IsObject) { |
15365 SealHandleScope shs(isolate); | 15365 SealHandleScope shs(isolate); |
15366 ASSERT(args.length() == 1); | 15366 DCHECK(args.length() == 1); |
15367 CONVERT_ARG_CHECKED(Object, obj, 0); | 15367 CONVERT_ARG_CHECKED(Object, obj, 0); |
15368 if (!obj->IsHeapObject()) return isolate->heap()->false_value(); | 15368 if (!obj->IsHeapObject()) return isolate->heap()->false_value(); |
15369 if (obj->IsNull()) return isolate->heap()->true_value(); | 15369 if (obj->IsNull()) return isolate->heap()->true_value(); |
15370 if (obj->IsUndetectableObject()) return isolate->heap()->false_value(); | 15370 if (obj->IsUndetectableObject()) return isolate->heap()->false_value(); |
15371 Map* map = HeapObject::cast(obj)->map(); | 15371 Map* map = HeapObject::cast(obj)->map(); |
15372 bool is_non_callable_spec_object = | 15372 bool is_non_callable_spec_object = |
15373 map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && | 15373 map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && |
15374 map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE; | 15374 map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE; |
15375 return isolate->heap()->ToBoolean(is_non_callable_spec_object); | 15375 return isolate->heap()->ToBoolean(is_non_callable_spec_object); |
15376 } | 15376 } |
15377 | 15377 |
15378 | 15378 |
15379 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { | 15379 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { |
15380 SealHandleScope shs(isolate); | 15380 SealHandleScope shs(isolate); |
15381 ASSERT(args.length() == 1); | 15381 DCHECK(args.length() == 1); |
15382 CONVERT_ARG_CHECKED(Object, obj, 0); | 15382 CONVERT_ARG_CHECKED(Object, obj, 0); |
15383 return isolate->heap()->ToBoolean(obj->IsJSFunction()); | 15383 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
15384 } | 15384 } |
15385 | 15385 |
15386 | 15386 |
15387 RUNTIME_FUNCTION(RuntimeReference_IsUndetectableObject) { | 15387 RUNTIME_FUNCTION(RuntimeReference_IsUndetectableObject) { |
15388 SealHandleScope shs(isolate); | 15388 SealHandleScope shs(isolate); |
15389 ASSERT(args.length() == 1); | 15389 DCHECK(args.length() == 1); |
15390 CONVERT_ARG_CHECKED(Object, obj, 0); | 15390 CONVERT_ARG_CHECKED(Object, obj, 0); |
15391 return isolate->heap()->ToBoolean(obj->IsUndetectableObject()); | 15391 return isolate->heap()->ToBoolean(obj->IsUndetectableObject()); |
15392 } | 15392 } |
15393 | 15393 |
15394 | 15394 |
15395 RUNTIME_FUNCTION(RuntimeReference_IsSpecObject) { | 15395 RUNTIME_FUNCTION(RuntimeReference_IsSpecObject) { |
15396 SealHandleScope shs(isolate); | 15396 SealHandleScope shs(isolate); |
15397 ASSERT(args.length() == 1); | 15397 DCHECK(args.length() == 1); |
15398 CONVERT_ARG_CHECKED(Object, obj, 0); | 15398 CONVERT_ARG_CHECKED(Object, obj, 0); |
15399 return isolate->heap()->ToBoolean(obj->IsSpecObject()); | 15399 return isolate->heap()->ToBoolean(obj->IsSpecObject()); |
15400 } | 15400 } |
15401 | 15401 |
15402 | 15402 |
15403 RUNTIME_FUNCTION(RuntimeReference_MathPow) { | 15403 RUNTIME_FUNCTION(RuntimeReference_MathPow) { |
15404 SealHandleScope shs(isolate); | 15404 SealHandleScope shs(isolate); |
15405 return __RT_impl_Runtime_MathPowSlow(args, isolate); | 15405 return __RT_impl_Runtime_MathPowSlow(args, isolate); |
15406 } | 15406 } |
15407 | 15407 |
15408 | 15408 |
15409 RUNTIME_FUNCTION(RuntimeReference_IsMinusZero) { | 15409 RUNTIME_FUNCTION(RuntimeReference_IsMinusZero) { |
15410 SealHandleScope shs(isolate); | 15410 SealHandleScope shs(isolate); |
15411 ASSERT(args.length() == 1); | 15411 DCHECK(args.length() == 1); |
15412 CONVERT_ARG_CHECKED(Object, obj, 0); | 15412 CONVERT_ARG_CHECKED(Object, obj, 0); |
15413 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); | 15413 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); |
15414 HeapNumber* number = HeapNumber::cast(obj); | 15414 HeapNumber* number = HeapNumber::cast(obj); |
15415 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); | 15415 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); |
15416 } | 15416 } |
15417 | 15417 |
15418 | 15418 |
15419 RUNTIME_FUNCTION(RuntimeReference_HasCachedArrayIndex) { | 15419 RUNTIME_FUNCTION(RuntimeReference_HasCachedArrayIndex) { |
15420 SealHandleScope shs(isolate); | 15420 SealHandleScope shs(isolate); |
15421 ASSERT(args.length() == 1); | 15421 DCHECK(args.length() == 1); |
15422 return isolate->heap()->false_value(); | 15422 return isolate->heap()->false_value(); |
15423 } | 15423 } |
15424 | 15424 |
15425 | 15425 |
15426 RUNTIME_FUNCTION(RuntimeReference_GetCachedArrayIndex) { | 15426 RUNTIME_FUNCTION(RuntimeReference_GetCachedArrayIndex) { |
15427 SealHandleScope shs(isolate); | 15427 SealHandleScope shs(isolate); |
15428 ASSERT(args.length() == 1); | 15428 DCHECK(args.length() == 1); |
15429 return isolate->heap()->undefined_value(); | 15429 return isolate->heap()->undefined_value(); |
15430 } | 15430 } |
15431 | 15431 |
15432 | 15432 |
15433 RUNTIME_FUNCTION(RuntimeReference_FastAsciiArrayJoin) { | 15433 RUNTIME_FUNCTION(RuntimeReference_FastAsciiArrayJoin) { |
15434 SealHandleScope shs(isolate); | 15434 SealHandleScope shs(isolate); |
15435 ASSERT(args.length() == 2); | 15435 DCHECK(args.length() == 2); |
15436 return isolate->heap()->undefined_value(); | 15436 return isolate->heap()->undefined_value(); |
15437 } | 15437 } |
15438 | 15438 |
15439 | 15439 |
15440 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { | 15440 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { |
15441 SealHandleScope shs(isolate); | 15441 SealHandleScope shs(isolate); |
15442 ASSERT(args.length() == 1); | 15442 DCHECK(args.length() == 1); |
15443 CONVERT_ARG_CHECKED(Object, obj, 0); | 15443 CONVERT_ARG_CHECKED(Object, obj, 0); |
15444 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); | 15444 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); |
15445 return JSReceiver::cast(obj)->class_name(); | 15445 return JSReceiver::cast(obj)->class_name(); |
15446 } | 15446 } |
15447 | 15447 |
15448 | 15448 |
15449 RUNTIME_FUNCTION(RuntimeReference_StringCharCodeAt) { | 15449 RUNTIME_FUNCTION(RuntimeReference_StringCharCodeAt) { |
15450 SealHandleScope shs(isolate); | 15450 SealHandleScope shs(isolate); |
15451 ASSERT(args.length() == 2); | 15451 DCHECK(args.length() == 2); |
15452 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 15452 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
15453 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 15453 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
15454 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 15454 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
15455 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 15455 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
15456 } | 15456 } |
15457 | 15457 |
15458 | 15458 |
15459 RUNTIME_FUNCTION(RuntimeReference_StringAdd) { | 15459 RUNTIME_FUNCTION(RuntimeReference_StringAdd) { |
15460 SealHandleScope shs(isolate); | 15460 SealHandleScope shs(isolate); |
15461 return __RT_impl_Runtime_StringAdd(args, isolate); | 15461 return __RT_impl_Runtime_StringAdd(args, isolate); |
(...skipping 19 matching lines...) Expand all Loading... |
15481 | 15481 |
15482 | 15482 |
15483 RUNTIME_FUNCTION(RuntimeReference_RegExpConstructResult) { | 15483 RUNTIME_FUNCTION(RuntimeReference_RegExpConstructResult) { |
15484 SealHandleScope shs(isolate); | 15484 SealHandleScope shs(isolate); |
15485 return __RT_impl_Runtime_RegExpConstructResult(args, isolate); | 15485 return __RT_impl_Runtime_RegExpConstructResult(args, isolate); |
15486 } | 15486 } |
15487 | 15487 |
15488 | 15488 |
15489 RUNTIME_FUNCTION(RuntimeReference_GetFromCache) { | 15489 RUNTIME_FUNCTION(RuntimeReference_GetFromCache) { |
15490 HandleScope scope(isolate); | 15490 HandleScope scope(isolate); |
15491 ASSERT(args.length() == 2); | 15491 DCHECK(args.length() == 2); |
15492 CONVERT_SMI_ARG_CHECKED(id, 0); | 15492 CONVERT_SMI_ARG_CHECKED(id, 0); |
15493 args[0] = isolate->native_context()->jsfunction_result_caches()->get(id); | 15493 args[0] = isolate->native_context()->jsfunction_result_caches()->get(id); |
15494 return __RT_impl_Runtime_GetFromCache(args, isolate); | 15494 return __RT_impl_Runtime_GetFromCache(args, isolate); |
15495 } | 15495 } |
15496 | 15496 |
15497 | 15497 |
15498 RUNTIME_FUNCTION(RuntimeReference_NumberToString) { | 15498 RUNTIME_FUNCTION(RuntimeReference_NumberToString) { |
15499 SealHandleScope shs(isolate); | 15499 SealHandleScope shs(isolate); |
15500 return __RT_impl_Runtime_NumberToStringRT(args, isolate); | 15500 return __RT_impl_Runtime_NumberToStringRT(args, isolate); |
15501 } | 15501 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15541 INLINE_OPTIMIZED_FUNCTION_LIST(IO) | 15541 INLINE_OPTIMIZED_FUNCTION_LIST(IO) |
15542 }; | 15542 }; |
15543 | 15543 |
15544 #undef IO | 15544 #undef IO |
15545 #undef I | 15545 #undef I |
15546 #undef F | 15546 #undef F |
15547 | 15547 |
15548 | 15548 |
15549 void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, | 15549 void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate, |
15550 Handle<NameDictionary> dict) { | 15550 Handle<NameDictionary> dict) { |
15551 ASSERT(dict->NumberOfElements() == 0); | 15551 DCHECK(dict->NumberOfElements() == 0); |
15552 HandleScope scope(isolate); | 15552 HandleScope scope(isolate); |
15553 for (int i = 0; i < kNumFunctions; ++i) { | 15553 for (int i = 0; i < kNumFunctions; ++i) { |
15554 const char* name = kIntrinsicFunctions[i].name; | 15554 const char* name = kIntrinsicFunctions[i].name; |
15555 if (name == NULL) continue; | 15555 if (name == NULL) continue; |
15556 Handle<NameDictionary> new_dict = NameDictionary::Add( | 15556 Handle<NameDictionary> new_dict = NameDictionary::Add( |
15557 dict, | 15557 dict, |
15558 isolate->factory()->InternalizeUtf8String(name), | 15558 isolate->factory()->InternalizeUtf8String(name), |
15559 Handle<Smi>(Smi::FromInt(i), isolate), | 15559 Handle<Smi>(Smi::FromInt(i), isolate), |
15560 PropertyDetails(NONE, NORMAL, Representation::None())); | 15560 PropertyDetails(NONE, NORMAL, Representation::None())); |
15561 // The dictionary does not need to grow. | 15561 // The dictionary does not need to grow. |
(...skipping 22 matching lines...) Expand all Loading... |
15584 } | 15584 } |
15585 return NULL; | 15585 return NULL; |
15586 } | 15586 } |
15587 | 15587 |
15588 | 15588 |
15589 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15589 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15590 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15590 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15591 } | 15591 } |
15592 | 15592 |
15593 } } // namespace v8::internal | 15593 } } // namespace v8::internal |
OLD | NEW |