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

Side by Side Diff: src/runtime.cc

Issue 7003114: Added two convenience methods to access an int/double argument from within a (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ic.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 RUNTIME_ASSERT(args[index]->Is##Type()); \ 74 RUNTIME_ASSERT(args[index]->Is##Type()); \
75 Handle<Type> name = args.at<Type>(index); 75 Handle<Type> name = args.at<Type>(index);
76 76
77 // Cast the given object to a boolean and store it in a variable with 77 // Cast the given object to a boolean and store it in a variable with
78 // the given name. If the object is not a boolean call IllegalOperation 78 // the given name. If the object is not a boolean call IllegalOperation
79 // and return. 79 // and return.
80 #define CONVERT_BOOLEAN_CHECKED(name, obj) \ 80 #define CONVERT_BOOLEAN_CHECKED(name, obj) \
81 RUNTIME_ASSERT(obj->IsBoolean()); \ 81 RUNTIME_ASSERT(obj->IsBoolean()); \
82 bool name = (obj)->IsTrue(); 82 bool name = (obj)->IsTrue();
83 83
84 // Cast the given object to a Smi and store its value in an int variable 84 // Cast the given argument to a Smi and store its value in an int variable
85 // with the given name. If the object is not a Smi call IllegalOperation 85 // with the given name. If the argument is not a Smi call IllegalOperation
86 // and return. 86 // and return.
87 #define CONVERT_SMI_CHECKED(name, obj) \ 87 #define CONVERT_SMI_ARG_CHECKED(name, index) \
88 RUNTIME_ASSERT(obj->IsSmi()); \ 88 RUNTIME_ASSERT(args[index]->IsSmi()); \
89 int name = Smi::cast(obj)->value(); 89 int name = args.smi_at(index);
90 90
91 // Cast the given object to a double and store it in a variable with 91 // Cast the given argument to a double and store it in a variable with
92 // the given name. If the object is not a number (as opposed to 92 // the given name. If the argument is not a number (as opposed to
93 // the number not-a-number) call IllegalOperation and return. 93 // the number not-a-number) call IllegalOperation and return.
94 #define CONVERT_DOUBLE_CHECKED(name, obj) \ 94 #define CONVERT_DOUBLE_ARG_CHECKED(name, index) \
95 RUNTIME_ASSERT(obj->IsNumber()); \ 95 RUNTIME_ASSERT(args[index]->IsNumber()); \
96 double name = (obj)->Number(); 96 double name = args.number_at(index);
97 97
98 // Call the specified converter on the object *comand store the result in 98 // Call the specified converter on the object *comand store the result in
99 // a variable of the specified type with the given name. If the 99 // a variable of the specified type with the given name. If the
100 // object is not a Number call IllegalOperation and return. 100 // object is not a Number call IllegalOperation and return.
101 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ 101 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
102 RUNTIME_ASSERT(obj->IsNumber()); \ 102 RUNTIME_ASSERT(obj->IsNumber()); \
103 type name = NumberTo##Type(obj); 103 type name = NumberTo##Type(obj);
104 104
105 105
106 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, 106 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 475
476 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralBoilerplate) { 476 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralBoilerplate) {
477 // Takes a FixedArray of elements containing the literal elements of 477 // Takes a FixedArray of elements containing the literal elements of
478 // the array literal and produces JSArray with those elements. 478 // the array literal and produces JSArray with those elements.
479 // Additionally takes the literals array of the surrounding function 479 // Additionally takes the literals array of the surrounding function
480 // which contains the context from which to get the Array function 480 // which contains the context from which to get the Array function
481 // to use for creating the array literal. 481 // to use for creating the array literal.
482 HandleScope scope(isolate); 482 HandleScope scope(isolate);
483 ASSERT(args.length() == 3); 483 ASSERT(args.length() == 3);
484 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 484 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
485 CONVERT_SMI_CHECKED(literals_index, args[1]); 485 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
486 CONVERT_ARG_CHECKED(FixedArray, elements, 2); 486 CONVERT_ARG_CHECKED(FixedArray, elements, 2);
487 487
488 Handle<Object> object = 488 Handle<Object> object =
489 CreateArrayLiteralBoilerplate(isolate, literals, elements); 489 CreateArrayLiteralBoilerplate(isolate, literals, elements);
490 if (object.is_null()) return Failure::Exception(); 490 if (object.is_null()) return Failure::Exception();
491 491
492 // Update the functions literal and return the boilerplate. 492 // Update the functions literal and return the boilerplate.
493 literals->set(literals_index, *object); 493 literals->set(literals_index, *object);
494 return *object; 494 return *object;
495 } 495 }
496 496
497 497
498 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) { 498 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
499 HandleScope scope(isolate); 499 HandleScope scope(isolate);
500 ASSERT(args.length() == 4); 500 ASSERT(args.length() == 4);
501 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 501 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
502 CONVERT_SMI_CHECKED(literals_index, args[1]); 502 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
503 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); 503 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2);
504 CONVERT_SMI_CHECKED(flags, args[3]); 504 CONVERT_SMI_ARG_CHECKED(flags, 3);
505 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 505 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
506 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 506 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
507 507
508 // Check if boilerplate exists. If not, create it first. 508 // Check if boilerplate exists. If not, create it first.
509 Handle<Object> boilerplate(literals->get(literals_index), isolate); 509 Handle<Object> boilerplate(literals->get(literals_index), isolate);
510 if (*boilerplate == isolate->heap()->undefined_value()) { 510 if (*boilerplate == isolate->heap()->undefined_value()) {
511 boilerplate = CreateObjectLiteralBoilerplate(isolate, 511 boilerplate = CreateObjectLiteralBoilerplate(isolate,
512 literals, 512 literals,
513 constant_properties, 513 constant_properties,
514 should_have_fast_elements, 514 should_have_fast_elements,
515 has_function_literal); 515 has_function_literal);
516 if (boilerplate.is_null()) return Failure::Exception(); 516 if (boilerplate.is_null()) return Failure::Exception();
517 // Update the functions literal and return the boilerplate. 517 // Update the functions literal and return the boilerplate.
518 literals->set(literals_index, *boilerplate); 518 literals->set(literals_index, *boilerplate);
519 } 519 }
520 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); 520 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
521 } 521 }
522 522
523 523
524 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { 524 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
525 HandleScope scope(isolate); 525 HandleScope scope(isolate);
526 ASSERT(args.length() == 4); 526 ASSERT(args.length() == 4);
527 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 527 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
528 CONVERT_SMI_CHECKED(literals_index, args[1]); 528 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
529 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); 529 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2);
530 CONVERT_SMI_CHECKED(flags, args[3]); 530 CONVERT_SMI_ARG_CHECKED(flags, 3);
531 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 531 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
532 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 532 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
533 533
534 // Check if boilerplate exists. If not, create it first. 534 // Check if boilerplate exists. If not, create it first.
535 Handle<Object> boilerplate(literals->get(literals_index), isolate); 535 Handle<Object> boilerplate(literals->get(literals_index), isolate);
536 if (*boilerplate == isolate->heap()->undefined_value()) { 536 if (*boilerplate == isolate->heap()->undefined_value()) {
537 boilerplate = CreateObjectLiteralBoilerplate(isolate, 537 boilerplate = CreateObjectLiteralBoilerplate(isolate,
538 literals, 538 literals,
539 constant_properties, 539 constant_properties,
540 should_have_fast_elements, 540 should_have_fast_elements,
541 has_function_literal); 541 has_function_literal);
542 if (boilerplate.is_null()) return Failure::Exception(); 542 if (boilerplate.is_null()) return Failure::Exception();
543 // Update the functions literal and return the boilerplate. 543 // Update the functions literal and return the boilerplate.
544 literals->set(literals_index, *boilerplate); 544 literals->set(literals_index, *boilerplate);
545 } 545 }
546 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); 546 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
547 } 547 }
548 548
549 549
550 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { 550 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
551 HandleScope scope(isolate); 551 HandleScope scope(isolate);
552 ASSERT(args.length() == 3); 552 ASSERT(args.length() == 3);
553 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 553 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
554 CONVERT_SMI_CHECKED(literals_index, args[1]); 554 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
555 CONVERT_ARG_CHECKED(FixedArray, elements, 2); 555 CONVERT_ARG_CHECKED(FixedArray, elements, 2);
556 556
557 // Check if boilerplate exists. If not, create it first. 557 // Check if boilerplate exists. If not, create it first.
558 Handle<Object> boilerplate(literals->get(literals_index), isolate); 558 Handle<Object> boilerplate(literals->get(literals_index), isolate);
559 if (*boilerplate == isolate->heap()->undefined_value()) { 559 if (*boilerplate == isolate->heap()->undefined_value()) {
560 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements); 560 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements);
561 if (boilerplate.is_null()) return Failure::Exception(); 561 if (boilerplate.is_null()) return Failure::Exception();
562 // Update the functions literal and return the boilerplate. 562 // Update the functions literal and return the boilerplate.
563 literals->set(literals_index, *boilerplate); 563 literals->set(literals_index, *boilerplate);
564 } 564 }
565 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); 565 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
566 } 566 }
567 567
568 568
569 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { 569 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
570 HandleScope scope(isolate); 570 HandleScope scope(isolate);
571 ASSERT(args.length() == 3); 571 ASSERT(args.length() == 3);
572 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 572 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
573 CONVERT_SMI_CHECKED(literals_index, args[1]); 573 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
574 CONVERT_ARG_CHECKED(FixedArray, elements, 2); 574 CONVERT_ARG_CHECKED(FixedArray, elements, 2);
575 575
576 // Check if boilerplate exists. If not, create it first. 576 // Check if boilerplate exists. If not, create it first.
577 Handle<Object> boilerplate(literals->get(literals_index), isolate); 577 Handle<Object> boilerplate(literals->get(literals_index), isolate);
578 if (*boilerplate == isolate->heap()->undefined_value()) { 578 if (*boilerplate == isolate->heap()->undefined_value()) {
579 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements); 579 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements);
580 if (boilerplate.is_null()) return Failure::Exception(); 580 if (boilerplate.is_null()) return Failure::Exception();
581 // Update the functions literal and return the boilerplate. 581 // Update the functions literal and return the boilerplate.
582 literals->set(literals_index, *boilerplate); 582 literals->set(literals_index, *boilerplate);
583 } 583 }
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 1104
1105 1105
1106 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { 1106 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) {
1107 ASSERT(args.length() == 4); 1107 ASSERT(args.length() == 4);
1108 HandleScope scope(isolate); 1108 HandleScope scope(isolate);
1109 Handle<GlobalObject> global = Handle<GlobalObject>( 1109 Handle<GlobalObject> global = Handle<GlobalObject>(
1110 isolate->context()->global()); 1110 isolate->context()->global());
1111 1111
1112 Handle<Context> context = args.at<Context>(0); 1112 Handle<Context> context = args.at<Context>(0);
1113 CONVERT_ARG_CHECKED(FixedArray, pairs, 1); 1113 CONVERT_ARG_CHECKED(FixedArray, pairs, 1);
1114 bool is_eval = Smi::cast(args[2])->value() == 1; 1114 bool is_eval = args.smi_at(2) == 1;
1115 StrictModeFlag strict_mode = 1115 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(args.smi_at(3));
1116 static_cast<StrictModeFlag>(Smi::cast(args[3])->value());
1117 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); 1116 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode);
1118 1117
1119 // Compute the property attributes. According to ECMA-262, section 1118 // Compute the property attributes. According to ECMA-262, section
1120 // 13, page 71, the property must be read-only and 1119 // 13, page 71, the property must be read-only and
1121 // non-deletable. However, neither SpiderMonkey nor KJS creates the 1120 // non-deletable. However, neither SpiderMonkey nor KJS creates the
1122 // property as read-only, so we don't either. 1121 // property as read-only, so we don't either.
1123 PropertyAttributes base = is_eval ? NONE : DONT_DELETE; 1122 PropertyAttributes base = is_eval ? NONE : DONT_DELETE;
1124 1123
1125 // Traverse the name/value pairs and set the properties. 1124 // Traverse the name/value pairs and set the properties.
1126 int length = pairs->length(); 1125 int length = pairs->length();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 return isolate->heap()->undefined_value(); 1244 return isolate->heap()->undefined_value();
1246 } 1245 }
1247 1246
1248 1247
1249 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { 1248 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
1250 HandleScope scope(isolate); 1249 HandleScope scope(isolate);
1251 ASSERT(args.length() == 4); 1250 ASSERT(args.length() == 4);
1252 1251
1253 CONVERT_ARG_CHECKED(Context, context, 0); 1252 CONVERT_ARG_CHECKED(Context, context, 0);
1254 Handle<String> name(String::cast(args[1])); 1253 Handle<String> name(String::cast(args[1]));
1255 PropertyAttributes mode = 1254 PropertyAttributes mode = static_cast<PropertyAttributes>(args.smi_at(2));
1256 static_cast<PropertyAttributes>(Smi::cast(args[2])->value());
1257 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE); 1255 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE);
1258 Handle<Object> initial_value(args[3], isolate); 1256 Handle<Object> initial_value(args[3], isolate);
1259 1257
1260 // Declarations are always done in the function context. 1258 // Declarations are always done in the function context.
1261 context = Handle<Context>(context->fcontext()); 1259 context = Handle<Context>(context->fcontext());
1262 1260
1263 int index; 1261 int index;
1264 PropertyAttributes attributes; 1262 PropertyAttributes attributes;
1265 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; 1263 ContextLookupFlags flags = DONT_FOLLOW_CHAINS;
1266 Handle<Object> holder = 1264 Handle<Object> holder =
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 // args[2] == value (optional) 1357 // args[2] == value (optional)
1360 1358
1361 // Determine if we need to assign to the variable if it already 1359 // Determine if we need to assign to the variable if it already
1362 // exists (based on the number of arguments). 1360 // exists (based on the number of arguments).
1363 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 1361 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
1364 bool assign = args.length() == 3; 1362 bool assign = args.length() == 3;
1365 1363
1366 CONVERT_ARG_CHECKED(String, name, 0); 1364 CONVERT_ARG_CHECKED(String, name, 0);
1367 GlobalObject* global = isolate->context()->global(); 1365 GlobalObject* global = isolate->context()->global();
1368 RUNTIME_ASSERT(args[1]->IsSmi()); 1366 RUNTIME_ASSERT(args[1]->IsSmi());
1369 StrictModeFlag strict_mode = 1367 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(args.smi_at(1));
1370 static_cast<StrictModeFlag>(Smi::cast(args[1])->value());
1371 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); 1368 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode);
1372 1369
1373 // According to ECMA-262, section 12.2, page 62, the property must 1370 // According to ECMA-262, section 12.2, page 62, the property must
1374 // not be deletable. 1371 // not be deletable.
1375 PropertyAttributes attributes = DONT_DELETE; 1372 PropertyAttributes attributes = DONT_DELETE;
1376 1373
1377 // Lookup the property locally in the global object. If it isn't 1374 // Lookup the property locally in the global object. If it isn't
1378 // there, there is a property with this name in the prototype chain. 1375 // there, there is a property with this name in the prototype chain.
1379 // We follow Safari and Firefox behavior and only set the property 1376 // We follow Safari and Firefox behavior and only set the property
1380 // locally if there is an explicit initialization value that we have 1377 // locally if there is an explicit initialization value that we have
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 1639
1643 return *value; 1640 return *value;
1644 } 1641 }
1645 1642
1646 1643
1647 RUNTIME_FUNCTION(MaybeObject*, 1644 RUNTIME_FUNCTION(MaybeObject*,
1648 Runtime_OptimizeObjectForAddingMultipleProperties) { 1645 Runtime_OptimizeObjectForAddingMultipleProperties) {
1649 HandleScope scope(isolate); 1646 HandleScope scope(isolate);
1650 ASSERT(args.length() == 2); 1647 ASSERT(args.length() == 2);
1651 CONVERT_ARG_CHECKED(JSObject, object, 0); 1648 CONVERT_ARG_CHECKED(JSObject, object, 0);
1652 CONVERT_SMI_CHECKED(properties, args[1]); 1649 CONVERT_SMI_ARG_CHECKED(properties, 1);
1653 if (object->HasFastProperties()) { 1650 if (object->HasFastProperties()) {
1654 NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); 1651 NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties);
1655 } 1652 }
1656 return *object; 1653 return *object;
1657 } 1654 }
1658 1655
1659 1656
1660 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { 1657 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) {
1661 HandleScope scope(isolate); 1658 HandleScope scope(isolate);
1662 ASSERT(args.length() == 4); 1659 ASSERT(args.length() == 4);
1663 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); 1660 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
1664 CONVERT_ARG_CHECKED(String, subject, 1); 1661 CONVERT_ARG_CHECKED(String, subject, 1);
1665 // Due to the way the JS calls are constructed this must be less than the 1662 // Due to the way the JS calls are constructed this must be less than the
1666 // length of a string, i.e. it is always a Smi. We check anyway for security. 1663 // length of a string, i.e. it is always a Smi. We check anyway for security.
1667 CONVERT_SMI_CHECKED(index, args[2]); 1664 CONVERT_SMI_ARG_CHECKED(index, 2);
1668 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); 1665 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3);
1669 RUNTIME_ASSERT(last_match_info->HasFastElements()); 1666 RUNTIME_ASSERT(last_match_info->HasFastElements());
1670 RUNTIME_ASSERT(index >= 0); 1667 RUNTIME_ASSERT(index >= 0);
1671 RUNTIME_ASSERT(index <= subject->length()); 1668 RUNTIME_ASSERT(index <= subject->length());
1672 isolate->counters()->regexp_entry_runtime()->Increment(); 1669 isolate->counters()->regexp_entry_runtime()->Increment();
1673 Handle<Object> result = RegExpImpl::Exec(regexp, 1670 Handle<Object> result = RegExpImpl::Exec(regexp,
1674 subject, 1671 subject,
1675 index, 1672 index,
1676 last_match_info); 1673 last_match_info);
1677 if (result.is_null()) return Failure::Exception(); 1674 if (result.is_null()) return Failure::Exception();
1678 return *result; 1675 return *result;
1679 } 1676 }
1680 1677
1681 1678
1682 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { 1679 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) {
1683 ASSERT(args.length() == 3); 1680 ASSERT(args.length() == 3);
1684 CONVERT_SMI_CHECKED(elements_count, args[0]); 1681 CONVERT_SMI_ARG_CHECKED(elements_count, 0);
1685 if (elements_count > JSArray::kMaxFastElementsLength) { 1682 if (elements_count > JSArray::kMaxFastElementsLength) {
1686 return isolate->ThrowIllegalOperation(); 1683 return isolate->ThrowIllegalOperation();
1687 } 1684 }
1688 Object* new_object; 1685 Object* new_object;
1689 { MaybeObject* maybe_new_object = 1686 { MaybeObject* maybe_new_object =
1690 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); 1687 isolate->heap()->AllocateFixedArrayWithHoles(elements_count);
1691 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; 1688 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
1692 } 1689 }
1693 FixedArray* elements = FixedArray::cast(new_object); 1690 FixedArray* elements = FixedArray::cast(new_object);
1694 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( 1691 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw(
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 Context* global_context = 1826 Context* global_context =
1830 isolate->context()->global()->global_context(); 1827 isolate->context()->global()->global_context();
1831 return global_context->global()->global_receiver(); 1828 return global_context->global()->global_receiver();
1832 } 1829 }
1833 1830
1834 1831
1835 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaterializeRegExpLiteral) { 1832 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaterializeRegExpLiteral) {
1836 HandleScope scope(isolate); 1833 HandleScope scope(isolate);
1837 ASSERT(args.length() == 4); 1834 ASSERT(args.length() == 4);
1838 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 1835 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
1839 int index = Smi::cast(args[1])->value(); 1836 int index = args.smi_at(1);
1840 Handle<String> pattern = args.at<String>(2); 1837 Handle<String> pattern = args.at<String>(2);
1841 Handle<String> flags = args.at<String>(3); 1838 Handle<String> flags = args.at<String>(3);
1842 1839
1843 // Get the RegExp function from the context in the literals array. 1840 // Get the RegExp function from the context in the literals array.
1844 // This is the RegExp function from the context in which the 1841 // This is the RegExp function from the context in which the
1845 // function was created. We do not use the RegExp function from the 1842 // function was created. We do not use the RegExp function from the
1846 // current global context because this might be the RegExp function 1843 // current global context because this might be the RegExp function
1847 // from another context which we should not have access to. 1844 // from another context which we should not have access to.
1848 Handle<JSFunction> constructor = 1845 Handle<JSFunction> constructor =
1849 Handle<JSFunction>( 1846 Handle<JSFunction>(
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 2052
2056 target->set_context(*context); 2053 target->set_context(*context);
2057 return *target; 2054 return *target;
2058 } 2055 }
2059 2056
2060 2057
2061 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { 2058 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) {
2062 HandleScope scope(isolate); 2059 HandleScope scope(isolate);
2063 ASSERT(args.length() == 2); 2060 ASSERT(args.length() == 2);
2064 CONVERT_ARG_CHECKED(JSFunction, function, 0); 2061 CONVERT_ARG_CHECKED(JSFunction, function, 0);
2065 CONVERT_SMI_CHECKED(num, args[1]); 2062 CONVERT_SMI_ARG_CHECKED(num, 1);
2066 RUNTIME_ASSERT(num >= 0); 2063 RUNTIME_ASSERT(num >= 0);
2067 SetExpectedNofProperties(function, num); 2064 SetExpectedNofProperties(function, num);
2068 return isolate->heap()->undefined_value(); 2065 return isolate->heap()->undefined_value();
2069 } 2066 }
2070 2067
2071 2068
2072 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, 2069 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate,
2073 Object* char_code) { 2070 Object* char_code) {
2074 uint32_t code; 2071 uint32_t code;
2075 if (char_code->ToArrayIndex(&code)) { 2072 if (char_code->ToArrayIndex(&code)) {
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 3106
3110 return Smi::FromInt(str1_length - str2_length); 3107 return Smi::FromInt(str1_length - str2_length);
3111 } 3108 }
3112 3109
3113 3110
3114 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { 3111 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) {
3115 NoHandleAllocation ha; 3112 NoHandleAllocation ha;
3116 ASSERT(args.length() == 3); 3113 ASSERT(args.length() == 3);
3117 3114
3118 CONVERT_CHECKED(String, value, args[0]); 3115 CONVERT_CHECKED(String, value, args[0]);
3119 Object* from = args[1];
3120 Object* to = args[2];
3121 int start, end; 3116 int start, end;
3122 // We have a fast integer-only case here to avoid a conversion to double in 3117 // We have a fast integer-only case here to avoid a conversion to double in
3123 // the common case where from and to are Smis. 3118 // the common case where from and to are Smis.
3124 if (from->IsSmi() && to->IsSmi()) { 3119 if (args[1]->IsSmi() && args[2]->IsSmi()) {
3125 start = Smi::cast(from)->value(); 3120 CONVERT_SMI_ARG_CHECKED(from_number, 1);
3126 end = Smi::cast(to)->value(); 3121 CONVERT_SMI_ARG_CHECKED(to_number, 2);
3122 start = from_number;
3123 end = to_number;
3127 } else { 3124 } else {
3128 CONVERT_DOUBLE_CHECKED(from_number, from); 3125 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1);
3129 CONVERT_DOUBLE_CHECKED(to_number, to); 3126 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2);
3130 start = FastD2I(from_number); 3127 start = FastD2I(from_number);
3131 end = FastD2I(to_number); 3128 end = FastD2I(to_number);
3132 } 3129 }
3133 RUNTIME_ASSERT(end >= start); 3130 RUNTIME_ASSERT(end >= start);
3134 RUNTIME_ASSERT(start >= 0); 3131 RUNTIME_ASSERT(start >= 0);
3135 RUNTIME_ASSERT(end <= value->length()); 3132 RUNTIME_ASSERT(end <= value->length());
3136 isolate->counters()->sub_string_runtime()->Increment(); 3133 isolate->counters()->sub_string_runtime()->Increment();
3137 return value->SubString(start, end); 3134 return value->SubString(start, end);
3138 } 3135 }
3139 3136
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array); 3552 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array);
3556 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value(); 3553 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value();
3557 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION); 3554 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION);
3558 return Failure::Exception(); 3555 return Failure::Exception();
3559 } 3556 }
3560 3557
3561 3558
3562 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { 3559 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) {
3563 NoHandleAllocation ha; 3560 NoHandleAllocation ha;
3564 ASSERT(args.length() == 2); 3561 ASSERT(args.length() == 2);
3565 CONVERT_SMI_CHECKED(radix, args[1]); 3562 CONVERT_SMI_ARG_CHECKED(radix, 1);
3566 RUNTIME_ASSERT(2 <= radix && radix <= 36); 3563 RUNTIME_ASSERT(2 <= radix && radix <= 36);
3567 3564
3568 // Fast case where the result is a one character string. 3565 // Fast case where the result is a one character string.
3569 if (args[0]->IsSmi()) { 3566 if (args[0]->IsSmi()) {
3570 int value = Smi::cast(args[0])->value(); 3567 int value = args.smi_at(0);
3571 if (value >= 0 && value < radix) { 3568 if (value >= 0 && value < radix) {
3572 // Character array used for conversion. 3569 // Character array used for conversion.
3573 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; 3570 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz";
3574 return isolate->heap()-> 3571 return isolate->heap()->
3575 LookupSingleCharacterStringFromCode(kCharTable[value]); 3572 LookupSingleCharacterStringFromCode(kCharTable[value]);
3576 } 3573 }
3577 } 3574 }
3578 3575
3579 // Slow case. 3576 // Slow case.
3580 CONVERT_DOUBLE_CHECKED(value, args[0]); 3577 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3581 if (isnan(value)) { 3578 if (isnan(value)) {
3582 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 3579 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
3583 } 3580 }
3584 if (isinf(value)) { 3581 if (isinf(value)) {
3585 if (value < 0) { 3582 if (value < 0) {
3586 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 3583 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
3587 } 3584 }
3588 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 3585 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
3589 } 3586 }
3590 char* str = DoubleToRadixCString(value, radix); 3587 char* str = DoubleToRadixCString(value, radix);
3591 MaybeObject* result = 3588 MaybeObject* result =
3592 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 3589 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
3593 DeleteArray(str); 3590 DeleteArray(str);
3594 return result; 3591 return result;
3595 } 3592 }
3596 3593
3597 3594
3598 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { 3595 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) {
3599 NoHandleAllocation ha; 3596 NoHandleAllocation ha;
3600 ASSERT(args.length() == 2); 3597 ASSERT(args.length() == 2);
3601 3598
3602 CONVERT_DOUBLE_CHECKED(value, args[0]); 3599 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3603 if (isnan(value)) { 3600 if (isnan(value)) {
3604 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 3601 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
3605 } 3602 }
3606 if (isinf(value)) { 3603 if (isinf(value)) {
3607 if (value < 0) { 3604 if (value < 0) {
3608 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 3605 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
3609 } 3606 }
3610 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 3607 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
3611 } 3608 }
3612 CONVERT_DOUBLE_CHECKED(f_number, args[1]); 3609 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3613 int f = FastD2I(f_number); 3610 int f = FastD2I(f_number);
3614 RUNTIME_ASSERT(f >= 0); 3611 RUNTIME_ASSERT(f >= 0);
3615 char* str = DoubleToFixedCString(value, f); 3612 char* str = DoubleToFixedCString(value, f);
3616 MaybeObject* res = 3613 MaybeObject* res =
3617 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 3614 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
3618 DeleteArray(str); 3615 DeleteArray(str);
3619 return res; 3616 return res;
3620 } 3617 }
3621 3618
3622 3619
3623 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { 3620 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) {
3624 NoHandleAllocation ha; 3621 NoHandleAllocation ha;
3625 ASSERT(args.length() == 2); 3622 ASSERT(args.length() == 2);
3626 3623
3627 CONVERT_DOUBLE_CHECKED(value, args[0]); 3624 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3628 if (isnan(value)) { 3625 if (isnan(value)) {
3629 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 3626 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
3630 } 3627 }
3631 if (isinf(value)) { 3628 if (isinf(value)) {
3632 if (value < 0) { 3629 if (value < 0) {
3633 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 3630 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
3634 } 3631 }
3635 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 3632 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
3636 } 3633 }
3637 CONVERT_DOUBLE_CHECKED(f_number, args[1]); 3634 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3638 int f = FastD2I(f_number); 3635 int f = FastD2I(f_number);
3639 RUNTIME_ASSERT(f >= -1 && f <= 20); 3636 RUNTIME_ASSERT(f >= -1 && f <= 20);
3640 char* str = DoubleToExponentialCString(value, f); 3637 char* str = DoubleToExponentialCString(value, f);
3641 MaybeObject* res = 3638 MaybeObject* res =
3642 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 3639 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
3643 DeleteArray(str); 3640 DeleteArray(str);
3644 return res; 3641 return res;
3645 } 3642 }
3646 3643
3647 3644
3648 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { 3645 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) {
3649 NoHandleAllocation ha; 3646 NoHandleAllocation ha;
3650 ASSERT(args.length() == 2); 3647 ASSERT(args.length() == 2);
3651 3648
3652 CONVERT_DOUBLE_CHECKED(value, args[0]); 3649 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3653 if (isnan(value)) { 3650 if (isnan(value)) {
3654 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); 3651 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN"));
3655 } 3652 }
3656 if (isinf(value)) { 3653 if (isinf(value)) {
3657 if (value < 0) { 3654 if (value < 0) {
3658 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); 3655 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity"));
3659 } 3656 }
3660 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); 3657 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity"));
3661 } 3658 }
3662 CONVERT_DOUBLE_CHECKED(f_number, args[1]); 3659 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
3663 int f = FastD2I(f_number); 3660 int f = FastD2I(f_number);
3664 RUNTIME_ASSERT(f >= 1 && f <= 21); 3661 RUNTIME_ASSERT(f >= 1 && f <= 21);
3665 char* str = DoubleToPrecisionCString(value, f); 3662 char* str = DoubleToPrecisionCString(value, f);
3666 MaybeObject* res = 3663 MaybeObject* res =
3667 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); 3664 isolate->heap()->AllocateStringFromAscii(CStrVector(str));
3668 DeleteArray(str); 3665 DeleteArray(str);
3669 return res; 3666 return res;
3670 } 3667 }
3671 3668
3672 3669
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3814 if (!receiver->IsGlobalObject()) return value; 3811 if (!receiver->IsGlobalObject()) return value;
3815 value = JSGlobalPropertyCell::cast(value)->value(); 3812 value = JSGlobalPropertyCell::cast(value)->value();
3816 if (!value->IsTheHole()) return value; 3813 if (!value->IsTheHole()) return value;
3817 // If value is the hole do the general lookup. 3814 // If value is the hole do the general lookup.
3818 } 3815 }
3819 } 3816 }
3820 } else if (args[0]->IsString() && args[1]->IsSmi()) { 3817 } else if (args[0]->IsString() && args[1]->IsSmi()) {
3821 // Fast case for string indexing using [] with a smi index. 3818 // Fast case for string indexing using [] with a smi index.
3822 HandleScope scope(isolate); 3819 HandleScope scope(isolate);
3823 Handle<String> str = args.at<String>(0); 3820 Handle<String> str = args.at<String>(0);
3824 int index = Smi::cast(args[1])->value(); 3821 int index = args.smi_at(1);
3825 if (index >= 0 && index < str->length()) { 3822 if (index >= 0 && index < str->length()) {
3826 Handle<Object> result = GetCharAt(str, index); 3823 Handle<Object> result = GetCharAt(str, index);
3827 return *result; 3824 return *result;
3828 } 3825 }
3829 } 3826 }
3830 3827
3831 // Fall back to GetObjectProperty. 3828 // Fall back to GetObjectProperty.
3832 return Runtime::GetObjectProperty(isolate, 3829 return Runtime::GetObjectProperty(isolate,
3833 args.at<Object>(0), 3830 args.at<Object>(0),
3834 args.at<Object>(1)); 3831 args.at<Object>(1));
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
4117 } 4114 }
4118 4115
4119 4116
4120 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { 4117 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) {
4121 NoHandleAllocation ha; 4118 NoHandleAllocation ha;
4122 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); 4119 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
4123 4120
4124 Handle<Object> object = args.at<Object>(0); 4121 Handle<Object> object = args.at<Object>(0);
4125 Handle<Object> key = args.at<Object>(1); 4122 Handle<Object> key = args.at<Object>(1);
4126 Handle<Object> value = args.at<Object>(2); 4123 Handle<Object> value = args.at<Object>(2);
4127 CONVERT_SMI_CHECKED(unchecked_attributes, args[3]); 4124 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
4128 RUNTIME_ASSERT( 4125 RUNTIME_ASSERT(
4129 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4126 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4130 // Compute attributes. 4127 // Compute attributes.
4131 PropertyAttributes attributes = 4128 PropertyAttributes attributes =
4132 static_cast<PropertyAttributes>(unchecked_attributes); 4129 static_cast<PropertyAttributes>(unchecked_attributes);
4133 4130
4134 StrictModeFlag strict_mode = kNonStrictMode; 4131 StrictModeFlag strict_mode = kNonStrictMode;
4135 if (args.length() == 5) { 4132 if (args.length() == 5) {
4136 CONVERT_SMI_CHECKED(strict_unchecked, args[4]); 4133 CONVERT_SMI_ARG_CHECKED(strict_unchecked, 4);
4137 RUNTIME_ASSERT(strict_unchecked == kStrictMode || 4134 RUNTIME_ASSERT(strict_unchecked == kStrictMode ||
4138 strict_unchecked == kNonStrictMode); 4135 strict_unchecked == kNonStrictMode);
4139 strict_mode = static_cast<StrictModeFlag>(strict_unchecked); 4136 strict_mode = static_cast<StrictModeFlag>(strict_unchecked);
4140 } 4137 }
4141 4138
4142 return Runtime::SetObjectProperty(isolate, 4139 return Runtime::SetObjectProperty(isolate,
4143 object, 4140 object,
4144 key, 4141 key,
4145 value, 4142 value,
4146 attributes, 4143 attributes,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); 4184 SetLocalPropertyIgnoreAttributes(name, args[2], attributes);
4188 } 4185 }
4189 4186
4190 4187
4191 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { 4188 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) {
4192 NoHandleAllocation ha; 4189 NoHandleAllocation ha;
4193 ASSERT(args.length() == 3); 4190 ASSERT(args.length() == 3);
4194 4191
4195 CONVERT_CHECKED(JSObject, object, args[0]); 4192 CONVERT_CHECKED(JSObject, object, args[0]);
4196 CONVERT_CHECKED(String, key, args[1]); 4193 CONVERT_CHECKED(String, key, args[1]);
4197 CONVERT_SMI_CHECKED(strict, args[2]); 4194 CONVERT_SMI_ARG_CHECKED(strict, 2);
4198 return object->DeleteProperty(key, (strict == kStrictMode) 4195 return object->DeleteProperty(key, (strict == kStrictMode)
4199 ? JSObject::STRICT_DELETION 4196 ? JSObject::STRICT_DELETION
4200 : JSObject::NORMAL_DELETION); 4197 : JSObject::NORMAL_DELETION);
4201 } 4198 }
4202 4199
4203 4200
4204 static Object* HasLocalPropertyImplementation(Isolate* isolate, 4201 static Object* HasLocalPropertyImplementation(Isolate* isolate,
4205 Handle<JSObject> object, 4202 Handle<JSObject> object,
4206 Handle<String> key) { 4203 Handle<String> key) {
4207 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); 4204 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value();
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
5345 elements, 5342 elements,
5346 worst_case_length); 5343 worst_case_length);
5347 } 5344 }
5348 } 5345 }
5349 5346
5350 5347
5351 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { 5348 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) {
5352 NoHandleAllocation ha; 5349 NoHandleAllocation ha;
5353 5350
5354 CONVERT_CHECKED(String, s, args[0]); 5351 CONVERT_CHECKED(String, s, args[0]);
5355 CONVERT_SMI_CHECKED(radix, args[1]); 5352 CONVERT_SMI_ARG_CHECKED(radix, 1);
5356 5353
5357 s->TryFlatten(); 5354 s->TryFlatten();
5358 5355
5359 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); 5356 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36));
5360 double value = StringToInt(isolate->unicode_cache(), s, radix); 5357 double value = StringToInt(isolate->unicode_cache(), s, radix);
5361 return isolate->heap()->NumberFromDouble(value); 5358 return isolate->heap()->NumberFromDouble(value);
5362 } 5359 }
5363 5360
5364 5361
5365 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { 5362 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) {
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
5934 RUNTIME_ASSERT(number->IsNumber()); 5931 RUNTIME_ASSERT(number->IsNumber());
5935 5932
5936 return isolate->heap()->NumberToString(number, false); 5933 return isolate->heap()->NumberToString(number, false);
5937 } 5934 }
5938 5935
5939 5936
5940 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { 5937 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) {
5941 NoHandleAllocation ha; 5938 NoHandleAllocation ha;
5942 ASSERT(args.length() == 1); 5939 ASSERT(args.length() == 1);
5943 5940
5944 CONVERT_DOUBLE_CHECKED(number, args[0]); 5941 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
5945 5942
5946 // We do not include 0 so that we don't have to treat +0 / -0 cases. 5943 // We do not include 0 so that we don't have to treat +0 / -0 cases.
5947 if (number > 0 && number <= Smi::kMaxValue) { 5944 if (number > 0 && number <= Smi::kMaxValue) {
5948 return Smi::FromInt(static_cast<int>(number)); 5945 return Smi::FromInt(static_cast<int>(number));
5949 } 5946 }
5950 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); 5947 return isolate->heap()->NumberFromDouble(DoubleToInteger(number));
5951 } 5948 }
5952 5949
5953 5950
5954 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { 5951 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) {
5955 NoHandleAllocation ha; 5952 NoHandleAllocation ha;
5956 ASSERT(args.length() == 1); 5953 ASSERT(args.length() == 1);
5957 5954
5958 CONVERT_DOUBLE_CHECKED(number, args[0]); 5955 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
5959 5956
5960 // We do not include 0 so that we don't have to treat +0 / -0 cases. 5957 // We do not include 0 so that we don't have to treat +0 / -0 cases.
5961 if (number > 0 && number <= Smi::kMaxValue) { 5958 if (number > 0 && number <= Smi::kMaxValue) {
5962 return Smi::FromInt(static_cast<int>(number)); 5959 return Smi::FromInt(static_cast<int>(number));
5963 } 5960 }
5964 5961
5965 double double_value = DoubleToInteger(number); 5962 double double_value = DoubleToInteger(number);
5966 // Map both -0 and +0 to +0. 5963 // Map both -0 and +0 to +0.
5967 if (double_value == 0) double_value = 0; 5964 if (double_value == 0) double_value = 0;
5968 5965
5969 return isolate->heap()->NumberFromDouble(double_value); 5966 return isolate->heap()->NumberFromDouble(double_value);
5970 } 5967 }
5971 5968
5972 5969
5973 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { 5970 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) {
5974 NoHandleAllocation ha; 5971 NoHandleAllocation ha;
5975 ASSERT(args.length() == 1); 5972 ASSERT(args.length() == 1);
5976 5973
5977 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); 5974 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]);
5978 return isolate->heap()->NumberFromUint32(number); 5975 return isolate->heap()->NumberFromUint32(number);
5979 } 5976 }
5980 5977
5981 5978
5982 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { 5979 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) {
5983 NoHandleAllocation ha; 5980 NoHandleAllocation ha;
5984 ASSERT(args.length() == 1); 5981 ASSERT(args.length() == 1);
5985 5982
5986 CONVERT_DOUBLE_CHECKED(number, args[0]); 5983 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
5987 5984
5988 // We do not include 0 so that we don't have to treat +0 / -0 cases. 5985 // We do not include 0 so that we don't have to treat +0 / -0 cases.
5989 if (number > 0 && number <= Smi::kMaxValue) { 5986 if (number > 0 && number <= Smi::kMaxValue) {
5990 return Smi::FromInt(static_cast<int>(number)); 5987 return Smi::FromInt(static_cast<int>(number));
5991 } 5988 }
5992 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); 5989 return isolate->heap()->NumberFromInt32(DoubleToInt32(number));
5993 } 5990 }
5994 5991
5995 5992
5996 // Converts a Number to a Smi, if possible. Returns NaN if the number is not 5993 // Converts a Number to a Smi, if possible. Returns NaN if the number is not
(...skipping 21 matching lines...) Expand all
6018 NoHandleAllocation ha; 6015 NoHandleAllocation ha;
6019 ASSERT(args.length() == 0); 6016 ASSERT(args.length() == 0);
6020 return isolate->heap()->AllocateHeapNumber(0); 6017 return isolate->heap()->AllocateHeapNumber(0);
6021 } 6018 }
6022 6019
6023 6020
6024 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { 6021 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) {
6025 NoHandleAllocation ha; 6022 NoHandleAllocation ha;
6026 ASSERT(args.length() == 2); 6023 ASSERT(args.length() == 2);
6027 6024
6028 CONVERT_DOUBLE_CHECKED(x, args[0]); 6025 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6029 CONVERT_DOUBLE_CHECKED(y, args[1]); 6026 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6030 return isolate->heap()->NumberFromDouble(x + y); 6027 return isolate->heap()->NumberFromDouble(x + y);
6031 } 6028 }
6032 6029
6033 6030
6034 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { 6031 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) {
6035 NoHandleAllocation ha; 6032 NoHandleAllocation ha;
6036 ASSERT(args.length() == 2); 6033 ASSERT(args.length() == 2);
6037 6034
6038 CONVERT_DOUBLE_CHECKED(x, args[0]); 6035 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6039 CONVERT_DOUBLE_CHECKED(y, args[1]); 6036 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6040 return isolate->heap()->NumberFromDouble(x - y); 6037 return isolate->heap()->NumberFromDouble(x - y);
6041 } 6038 }
6042 6039
6043 6040
6044 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { 6041 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) {
6045 NoHandleAllocation ha; 6042 NoHandleAllocation ha;
6046 ASSERT(args.length() == 2); 6043 ASSERT(args.length() == 2);
6047 6044
6048 CONVERT_DOUBLE_CHECKED(x, args[0]); 6045 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6049 CONVERT_DOUBLE_CHECKED(y, args[1]); 6046 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6050 return isolate->heap()->NumberFromDouble(x * y); 6047 return isolate->heap()->NumberFromDouble(x * y);
6051 } 6048 }
6052 6049
6053 6050
6054 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { 6051 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) {
6055 NoHandleAllocation ha; 6052 NoHandleAllocation ha;
6056 ASSERT(args.length() == 1); 6053 ASSERT(args.length() == 1);
6057 6054
6058 CONVERT_DOUBLE_CHECKED(x, args[0]); 6055 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6059 return isolate->heap()->NumberFromDouble(-x); 6056 return isolate->heap()->NumberFromDouble(-x);
6060 } 6057 }
6061 6058
6062 6059
6063 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { 6060 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) {
6064 NoHandleAllocation ha; 6061 NoHandleAllocation ha;
6065 ASSERT(args.length() == 0); 6062 ASSERT(args.length() == 0);
6066 6063
6067 return isolate->heap()->NumberFromDouble(9876543210.0); 6064 return isolate->heap()->NumberFromDouble(9876543210.0);
6068 } 6065 }
6069 6066
6070 6067
6071 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { 6068 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) {
6072 NoHandleAllocation ha; 6069 NoHandleAllocation ha;
6073 ASSERT(args.length() == 2); 6070 ASSERT(args.length() == 2);
6074 6071
6075 CONVERT_DOUBLE_CHECKED(x, args[0]); 6072 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6076 CONVERT_DOUBLE_CHECKED(y, args[1]); 6073 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6077 return isolate->heap()->NumberFromDouble(x / y); 6074 return isolate->heap()->NumberFromDouble(x / y);
6078 } 6075 }
6079 6076
6080 6077
6081 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { 6078 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) {
6082 NoHandleAllocation ha; 6079 NoHandleAllocation ha;
6083 ASSERT(args.length() == 2); 6080 ASSERT(args.length() == 2);
6084 6081
6085 CONVERT_DOUBLE_CHECKED(x, args[0]); 6082 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6086 CONVERT_DOUBLE_CHECKED(y, args[1]); 6083 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6087 6084
6088 x = modulo(x, y); 6085 x = modulo(x, y);
6089 // NumberFromDouble may return a Smi instead of a Number object 6086 // NumberFromDouble may return a Smi instead of a Number object
6090 return isolate->heap()->NumberFromDouble(x); 6087 return isolate->heap()->NumberFromDouble(x);
6091 } 6088 }
6092 6089
6093 6090
6094 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { 6091 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) {
6095 NoHandleAllocation ha; 6092 NoHandleAllocation ha;
6096 ASSERT(args.length() == 2); 6093 ASSERT(args.length() == 2);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6141 6138
6142 6139
6143 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { 6140 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
6144 NoHandleAllocation ha; 6141 NoHandleAllocation ha;
6145 ASSERT(args.length() == 3); 6142 ASSERT(args.length() == 3);
6146 CONVERT_CHECKED(JSArray, array, args[0]); 6143 CONVERT_CHECKED(JSArray, array, args[0]);
6147 if (!args[1]->IsSmi()) { 6144 if (!args[1]->IsSmi()) {
6148 isolate->context()->mark_out_of_memory(); 6145 isolate->context()->mark_out_of_memory();
6149 return Failure::OutOfMemoryException(); 6146 return Failure::OutOfMemoryException();
6150 } 6147 }
6151 int array_length = Smi::cast(args[1])->value(); 6148 int array_length = args.smi_at(1);
6152 CONVERT_CHECKED(String, special, args[2]); 6149 CONVERT_CHECKED(String, special, args[2]);
6153 6150
6154 // This assumption is used by the slice encoding in one or two smis. 6151 // This assumption is used by the slice encoding in one or two smis.
6155 ASSERT(Smi::kMaxValue >= String::kMaxLength); 6152 ASSERT(Smi::kMaxValue >= String::kMaxLength);
6156 6153
6157 int special_length = special->length(); 6154 int special_length = special->length();
6158 if (!array->HasFastElements()) { 6155 if (!array->HasFastElements()) {
6159 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6156 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6160 } 6157 }
6161 FixedArray* fixed_array = FixedArray::cast(array->elements()); 6158 FixedArray* fixed_array = FixedArray::cast(array->elements());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
6254 6251
6255 6252
6256 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { 6253 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) {
6257 NoHandleAllocation ha; 6254 NoHandleAllocation ha;
6258 ASSERT(args.length() == 3); 6255 ASSERT(args.length() == 3);
6259 CONVERT_CHECKED(JSArray, array, args[0]); 6256 CONVERT_CHECKED(JSArray, array, args[0]);
6260 if (!args[1]->IsSmi()) { 6257 if (!args[1]->IsSmi()) {
6261 isolate->context()->mark_out_of_memory(); 6258 isolate->context()->mark_out_of_memory();
6262 return Failure::OutOfMemoryException(); 6259 return Failure::OutOfMemoryException();
6263 } 6260 }
6264 int array_length = Smi::cast(args[1])->value(); 6261 int array_length = args.smi_at(1);
6265 CONVERT_CHECKED(String, separator, args[2]); 6262 CONVERT_CHECKED(String, separator, args[2]);
6266 6263
6267 if (!array->HasFastElements()) { 6264 if (!array->HasFastElements()) {
6268 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6265 return isolate->Throw(isolate->heap()->illegal_argument_symbol());
6269 } 6266 }
6270 FixedArray* fixed_array = FixedArray::cast(array->elements()); 6267 FixedArray* fixed_array = FixedArray::cast(array->elements());
6271 if (fixed_array->length() < array_length) { 6268 if (fixed_array->length() < array_length) {
6272 array_length = fixed_array->length(); 6269 array_length = fixed_array->length();
6273 } 6270 }
6274 6271
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
6532 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 6529 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
6533 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 6530 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
6534 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); 6531 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f));
6535 } 6532 }
6536 6533
6537 6534
6538 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { 6535 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) {
6539 NoHandleAllocation ha; 6536 NoHandleAllocation ha;
6540 ASSERT(args.length() == 2); 6537 ASSERT(args.length() == 2);
6541 6538
6542 CONVERT_DOUBLE_CHECKED(x, args[0]); 6539 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6543 CONVERT_DOUBLE_CHECKED(y, args[1]); 6540 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6544 if (isnan(x)) return Smi::FromInt(NOT_EQUAL); 6541 if (isnan(x)) return Smi::FromInt(NOT_EQUAL);
6545 if (isnan(y)) return Smi::FromInt(NOT_EQUAL); 6542 if (isnan(y)) return Smi::FromInt(NOT_EQUAL);
6546 if (x == y) return Smi::FromInt(EQUAL); 6543 if (x == y) return Smi::FromInt(EQUAL);
6547 Object* result; 6544 Object* result;
6548 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { 6545 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) {
6549 result = Smi::FromInt(EQUAL); 6546 result = Smi::FromInt(EQUAL);
6550 } else { 6547 } else {
6551 result = Smi::FromInt(NOT_EQUAL); 6548 result = Smi::FromInt(NOT_EQUAL);
6552 } 6549 }
6553 return result; 6550 return result;
(...skipping 15 matching lines...) Expand all
6569 STATIC_CHECK(EQUAL == 0); 6566 STATIC_CHECK(EQUAL == 0);
6570 STATIC_CHECK(NOT_EQUAL == 1); 6567 STATIC_CHECK(NOT_EQUAL == 1);
6571 return Smi::FromInt(not_equal); 6568 return Smi::FromInt(not_equal);
6572 } 6569 }
6573 6570
6574 6571
6575 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { 6572 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) {
6576 NoHandleAllocation ha; 6573 NoHandleAllocation ha;
6577 ASSERT(args.length() == 3); 6574 ASSERT(args.length() == 3);
6578 6575
6579 CONVERT_DOUBLE_CHECKED(x, args[0]); 6576 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6580 CONVERT_DOUBLE_CHECKED(y, args[1]); 6577 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6581 if (isnan(x) || isnan(y)) return args[2]; 6578 if (isnan(x) || isnan(y)) return args[2];
6582 if (x == y) return Smi::FromInt(EQUAL); 6579 if (x == y) return Smi::FromInt(EQUAL);
6583 if (isless(x, y)) return Smi::FromInt(LESS); 6580 if (isless(x, y)) return Smi::FromInt(LESS);
6584 return Smi::FromInt(GREATER); 6581 return Smi::FromInt(GREATER);
6585 } 6582 }
6586 6583
6587 6584
6588 // Compare two Smis as if they were converted to strings and then 6585 // Compare two Smis as if they were converted to strings and then
6589 // compared lexicographically. 6586 // compared lexicographically.
6590 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { 6587 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
6743 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) 6740 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y)
6744 : StringInputBufferCompare(isolate->runtime_state(), x, y); 6741 : StringInputBufferCompare(isolate->runtime_state(), x, y);
6745 } 6742 }
6746 6743
6747 6744
6748 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { 6745 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) {
6749 NoHandleAllocation ha; 6746 NoHandleAllocation ha;
6750 ASSERT(args.length() == 1); 6747 ASSERT(args.length() == 1);
6751 isolate->counters()->math_acos()->Increment(); 6748 isolate->counters()->math_acos()->Increment();
6752 6749
6753 CONVERT_DOUBLE_CHECKED(x, args[0]); 6750 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6754 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); 6751 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x);
6755 } 6752 }
6756 6753
6757 6754
6758 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { 6755 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) {
6759 NoHandleAllocation ha; 6756 NoHandleAllocation ha;
6760 ASSERT(args.length() == 1); 6757 ASSERT(args.length() == 1);
6761 isolate->counters()->math_asin()->Increment(); 6758 isolate->counters()->math_asin()->Increment();
6762 6759
6763 CONVERT_DOUBLE_CHECKED(x, args[0]); 6760 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6764 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); 6761 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x);
6765 } 6762 }
6766 6763
6767 6764
6768 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { 6765 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) {
6769 NoHandleAllocation ha; 6766 NoHandleAllocation ha;
6770 ASSERT(args.length() == 1); 6767 ASSERT(args.length() == 1);
6771 isolate->counters()->math_atan()->Increment(); 6768 isolate->counters()->math_atan()->Increment();
6772 6769
6773 CONVERT_DOUBLE_CHECKED(x, args[0]); 6770 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6774 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); 6771 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x);
6775 } 6772 }
6776 6773
6777 6774
6778 static const double kPiDividedBy4 = 0.78539816339744830962; 6775 static const double kPiDividedBy4 = 0.78539816339744830962;
6779 6776
6780 6777
6781 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { 6778 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) {
6782 NoHandleAllocation ha; 6779 NoHandleAllocation ha;
6783 ASSERT(args.length() == 2); 6780 ASSERT(args.length() == 2);
6784 isolate->counters()->math_atan2()->Increment(); 6781 isolate->counters()->math_atan2()->Increment();
6785 6782
6786 CONVERT_DOUBLE_CHECKED(x, args[0]); 6783 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6787 CONVERT_DOUBLE_CHECKED(y, args[1]); 6784 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6788 double result; 6785 double result;
6789 if (isinf(x) && isinf(y)) { 6786 if (isinf(x) && isinf(y)) {
6790 // Make sure that the result in case of two infinite arguments 6787 // Make sure that the result in case of two infinite arguments
6791 // is a multiple of Pi / 4. The sign of the result is determined 6788 // is a multiple of Pi / 4. The sign of the result is determined
6792 // by the first argument (x) and the sign of the second argument 6789 // by the first argument (x) and the sign of the second argument
6793 // determines the multiplier: one or three. 6790 // determines the multiplier: one or three.
6794 int multiplier = (x < 0) ? -1 : 1; 6791 int multiplier = (x < 0) ? -1 : 1;
6795 if (y < 0) multiplier *= 3; 6792 if (y < 0) multiplier *= 3;
6796 result = multiplier * kPiDividedBy4; 6793 result = multiplier * kPiDividedBy4;
6797 } else { 6794 } else {
6798 result = atan2(x, y); 6795 result = atan2(x, y);
6799 } 6796 }
6800 return isolate->heap()->AllocateHeapNumber(result); 6797 return isolate->heap()->AllocateHeapNumber(result);
6801 } 6798 }
6802 6799
6803 6800
6804 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { 6801 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) {
6805 NoHandleAllocation ha; 6802 NoHandleAllocation ha;
6806 ASSERT(args.length() == 1); 6803 ASSERT(args.length() == 1);
6807 isolate->counters()->math_ceil()->Increment(); 6804 isolate->counters()->math_ceil()->Increment();
6808 6805
6809 CONVERT_DOUBLE_CHECKED(x, args[0]); 6806 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6810 return isolate->heap()->NumberFromDouble(ceiling(x)); 6807 return isolate->heap()->NumberFromDouble(ceiling(x));
6811 } 6808 }
6812 6809
6813 6810
6814 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { 6811 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) {
6815 NoHandleAllocation ha; 6812 NoHandleAllocation ha;
6816 ASSERT(args.length() == 1); 6813 ASSERT(args.length() == 1);
6817 isolate->counters()->math_cos()->Increment(); 6814 isolate->counters()->math_cos()->Increment();
6818 6815
6819 CONVERT_DOUBLE_CHECKED(x, args[0]); 6816 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6820 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); 6817 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x);
6821 } 6818 }
6822 6819
6823 6820
6824 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { 6821 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) {
6825 NoHandleAllocation ha; 6822 NoHandleAllocation ha;
6826 ASSERT(args.length() == 1); 6823 ASSERT(args.length() == 1);
6827 isolate->counters()->math_exp()->Increment(); 6824 isolate->counters()->math_exp()->Increment();
6828 6825
6829 CONVERT_DOUBLE_CHECKED(x, args[0]); 6826 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6830 return isolate->transcendental_cache()->Get(TranscendentalCache::EXP, x); 6827 return isolate->transcendental_cache()->Get(TranscendentalCache::EXP, x);
6831 } 6828 }
6832 6829
6833 6830
6834 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { 6831 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) {
6835 NoHandleAllocation ha; 6832 NoHandleAllocation ha;
6836 ASSERT(args.length() == 1); 6833 ASSERT(args.length() == 1);
6837 isolate->counters()->math_floor()->Increment(); 6834 isolate->counters()->math_floor()->Increment();
6838 6835
6839 CONVERT_DOUBLE_CHECKED(x, args[0]); 6836 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6840 return isolate->heap()->NumberFromDouble(floor(x)); 6837 return isolate->heap()->NumberFromDouble(floor(x));
6841 } 6838 }
6842 6839
6843 6840
6844 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { 6841 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) {
6845 NoHandleAllocation ha; 6842 NoHandleAllocation ha;
6846 ASSERT(args.length() == 1); 6843 ASSERT(args.length() == 1);
6847 isolate->counters()->math_log()->Increment(); 6844 isolate->counters()->math_log()->Increment();
6848 6845
6849 CONVERT_DOUBLE_CHECKED(x, args[0]); 6846 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6850 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); 6847 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x);
6851 } 6848 }
6852 6849
6853 6850
6854 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { 6851 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) {
6855 NoHandleAllocation ha; 6852 NoHandleAllocation ha;
6856 ASSERT(args.length() == 2); 6853 ASSERT(args.length() == 2);
6857 isolate->counters()->math_pow()->Increment(); 6854 isolate->counters()->math_pow()->Increment();
6858 6855
6859 CONVERT_DOUBLE_CHECKED(x, args[0]); 6856 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6860 6857
6861 // If the second argument is a smi, it is much faster to call the 6858 // If the second argument is a smi, it is much faster to call the
6862 // custom powi() function than the generic pow(). 6859 // custom powi() function than the generic pow().
6863 if (args[1]->IsSmi()) { 6860 if (args[1]->IsSmi()) {
6864 int y = Smi::cast(args[1])->value(); 6861 int y = args.smi_at(1);
6865 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); 6862 return isolate->heap()->NumberFromDouble(power_double_int(x, y));
6866 } 6863 }
6867 6864
6868 CONVERT_DOUBLE_CHECKED(y, args[1]); 6865 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6869 return isolate->heap()->AllocateHeapNumber(power_double_double(x, y)); 6866 return isolate->heap()->AllocateHeapNumber(power_double_double(x, y));
6870 } 6867 }
6871 6868
6872 // Fast version of Math.pow if we know that y is not an integer and 6869 // Fast version of Math.pow if we know that y is not an integer and
6873 // y is not -0.5 or 0.5. Used as slowcase from codegen. 6870 // y is not -0.5 or 0.5. Used as slowcase from codegen.
6874 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { 6871 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) {
6875 NoHandleAllocation ha; 6872 NoHandleAllocation ha;
6876 ASSERT(args.length() == 2); 6873 ASSERT(args.length() == 2);
6877 CONVERT_DOUBLE_CHECKED(x, args[0]); 6874 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6878 CONVERT_DOUBLE_CHECKED(y, args[1]); 6875 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6879 if (y == 0) { 6876 if (y == 0) {
6880 return Smi::FromInt(1); 6877 return Smi::FromInt(1);
6881 } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { 6878 } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) {
6882 return isolate->heap()->nan_value(); 6879 return isolate->heap()->nan_value();
6883 } else { 6880 } else {
6884 return isolate->heap()->AllocateHeapNumber(pow(x, y)); 6881 return isolate->heap()->AllocateHeapNumber(pow(x, y));
6885 } 6882 }
6886 } 6883 }
6887 6884
6888 6885
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6927 // Do not call NumberFromDouble() to avoid extra checks. 6924 // Do not call NumberFromDouble() to avoid extra checks.
6928 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); 6925 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5));
6929 } 6926 }
6930 6927
6931 6928
6932 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { 6929 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) {
6933 NoHandleAllocation ha; 6930 NoHandleAllocation ha;
6934 ASSERT(args.length() == 1); 6931 ASSERT(args.length() == 1);
6935 isolate->counters()->math_sin()->Increment(); 6932 isolate->counters()->math_sin()->Increment();
6936 6933
6937 CONVERT_DOUBLE_CHECKED(x, args[0]); 6934 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6938 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); 6935 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x);
6939 } 6936 }
6940 6937
6941 6938
6942 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { 6939 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) {
6943 NoHandleAllocation ha; 6940 NoHandleAllocation ha;
6944 ASSERT(args.length() == 1); 6941 ASSERT(args.length() == 1);
6945 isolate->counters()->math_sqrt()->Increment(); 6942 isolate->counters()->math_sqrt()->Increment();
6946 6943
6947 CONVERT_DOUBLE_CHECKED(x, args[0]); 6944 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6948 return isolate->heap()->AllocateHeapNumber(sqrt(x)); 6945 return isolate->heap()->AllocateHeapNumber(sqrt(x));
6949 } 6946 }
6950 6947
6951 6948
6952 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { 6949 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) {
6953 NoHandleAllocation ha; 6950 NoHandleAllocation ha;
6954 ASSERT(args.length() == 1); 6951 ASSERT(args.length() == 1);
6955 isolate->counters()->math_tan()->Increment(); 6952 isolate->counters()->math_tan()->Increment();
6956 6953
6957 CONVERT_DOUBLE_CHECKED(x, args[0]); 6954 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6958 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); 6955 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x);
6959 } 6956 }
6960 6957
6961 6958
6962 static int MakeDay(int year, int month, int day) { 6959 static int MakeDay(int year, int month, int day) {
6963 static const int day_from_month[] = {0, 31, 59, 90, 120, 151, 6960 static const int day_from_month[] = {0, 31, 59, 90, 120, 151,
6964 181, 212, 243, 273, 304, 334}; 6961 181, 212, 243, 273, 304, 334};
6965 static const int day_from_month_leap[] = {0, 31, 60, 91, 121, 152, 6962 static const int day_from_month_leap[] = {0, 31, 60, 91, 121, 152,
6966 182, 213, 244, 274, 305, 335}; 6963 182, 213, 244, 274, 305, 335};
6967 6964
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
7001 } 6998 }
7002 6999
7003 return day_from_year + day_from_month_leap[month] + day - 1; 7000 return day_from_year + day_from_month_leap[month] + day - 1;
7004 } 7001 }
7005 7002
7006 7003
7007 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { 7004 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
7008 NoHandleAllocation ha; 7005 NoHandleAllocation ha;
7009 ASSERT(args.length() == 3); 7006 ASSERT(args.length() == 3);
7010 7007
7011 CONVERT_SMI_CHECKED(year, args[0]); 7008 CONVERT_SMI_ARG_CHECKED(year, 0);
7012 CONVERT_SMI_CHECKED(month, args[1]); 7009 CONVERT_SMI_ARG_CHECKED(month, 1);
7013 CONVERT_SMI_CHECKED(date, args[2]); 7010 CONVERT_SMI_ARG_CHECKED(date, 2);
7014 7011
7015 return Smi::FromInt(MakeDay(year, month, date)); 7012 return Smi::FromInt(MakeDay(year, month, date));
7016 } 7013 }
7017 7014
7018 7015
7019 static const int kDays4Years[] = {0, 365, 2 * 365, 3 * 365 + 1}; 7016 static const int kDays4Years[] = {0, 365, 2 * 365, 3 * 365 + 1};
7020 static const int kDaysIn4Years = 4 * 365 + 1; 7017 static const int kDaysIn4Years = 4 * 365 + 1;
7021 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1; 7018 static const int kDaysIn100Years = 25 * kDaysIn4Years - 1;
7022 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1; 7019 static const int kDaysIn400Years = 4 * kDaysIn100Years + 1;
7023 static const int kDays1970to2000 = 30 * 365 + 7; 7020 static const int kDays1970to2000 = 30 * 365 + 7;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
7300 } else { 7297 } else {
7301 DateYMDFromTimeSlow(date, year, month, day); 7298 DateYMDFromTimeSlow(date, year, month, day);
7302 } 7299 }
7303 } 7300 }
7304 7301
7305 7302
7306 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) { 7303 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) {
7307 NoHandleAllocation ha; 7304 NoHandleAllocation ha;
7308 ASSERT(args.length() == 2); 7305 ASSERT(args.length() == 2);
7309 7306
7310 CONVERT_DOUBLE_CHECKED(t, args[0]); 7307 CONVERT_DOUBLE_ARG_CHECKED(t, 0);
7311 CONVERT_CHECKED(JSArray, res_array, args[1]); 7308 CONVERT_CHECKED(JSArray, res_array, args[1]);
7312 7309
7313 int year, month, day; 7310 int year, month, day;
7314 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); 7311 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day);
7315 7312
7316 RUNTIME_ASSERT(res_array->elements()->map() == 7313 RUNTIME_ASSERT(res_array->elements()->map() ==
7317 isolate->heap()->fixed_array_map()); 7314 isolate->heap()->fixed_array_map());
7318 FixedArray* elms = FixedArray::cast(res_array->elements()); 7315 FixedArray* elms = FixedArray::cast(res_array->elements());
7319 RUNTIME_ASSERT(elms->length() == 3); 7316 RUNTIME_ASSERT(elms->length() == 3);
7320 7317
7321 elms->set(0, Smi::FromInt(year)); 7318 elms->set(0, Smi::FromInt(year));
7322 elms->set(1, Smi::FromInt(month)); 7319 elms->set(1, Smi::FromInt(month));
7323 elms->set(2, Smi::FromInt(day)); 7320 elms->set(2, Smi::FromInt(day));
7324 7321
7325 return isolate->heap()->undefined_value(); 7322 return isolate->heap()->undefined_value();
7326 } 7323 }
7327 7324
7328 7325
7329 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewArgumentsFast) { 7326 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewArgumentsFast) {
7330 NoHandleAllocation ha; 7327 NoHandleAllocation ha;
7331 ASSERT(args.length() == 3); 7328 ASSERT(args.length() == 3);
7332 7329
7333 JSFunction* callee = JSFunction::cast(args[0]); 7330 JSFunction* callee = JSFunction::cast(args[0]);
7334 Object** parameters = reinterpret_cast<Object**>(args[1]); 7331 Object** parameters = reinterpret_cast<Object**>(args[1]);
7335 const int length = Smi::cast(args[2])->value(); 7332 const int length = args.smi_at(2);
7336 7333
7337 Object* result; 7334 Object* result;
7338 { MaybeObject* maybe_result = 7335 { MaybeObject* maybe_result =
7339 isolate->heap()->AllocateArgumentsObject(callee, length); 7336 isolate->heap()->AllocateArgumentsObject(callee, length);
7340 if (!maybe_result->ToObject(&result)) return maybe_result; 7337 if (!maybe_result->ToObject(&result)) return maybe_result;
7341 } 7338 }
7342 // Allocate the elements if needed. 7339 // Allocate the elements if needed.
7343 if (length > 0) { 7340 if (length > 0) {
7344 // Allocate the fixed array. 7341 // Allocate the fixed array.
7345 Object* obj; 7342 Object* obj;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
7626 function->ReplaceCode(function->shared()->code()); 7623 function->ReplaceCode(function->shared()->code());
7627 return function->code(); 7624 return function->code();
7628 } 7625 }
7629 7626
7630 7627
7631 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { 7628 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
7632 HandleScope scope(isolate); 7629 HandleScope scope(isolate);
7633 ASSERT(args.length() == 1); 7630 ASSERT(args.length() == 1);
7634 RUNTIME_ASSERT(args[0]->IsSmi()); 7631 RUNTIME_ASSERT(args[0]->IsSmi());
7635 Deoptimizer::BailoutType type = 7632 Deoptimizer::BailoutType type =
7636 static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value()); 7633 static_cast<Deoptimizer::BailoutType>(args.smi_at(0));
7637 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); 7634 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate);
7638 ASSERT(isolate->heap()->IsAllocationAllowed()); 7635 ASSERT(isolate->heap()->IsAllocationAllowed());
7639 int frames = deoptimizer->output_count(); 7636 int frames = deoptimizer->output_count();
7640 7637
7641 deoptimizer->MaterializeHeapNumbers(); 7638 deoptimizer->MaterializeHeapNumbers();
7642 delete deoptimizer; 7639 delete deoptimizer;
7643 7640
7644 JavaScriptFrameIterator it(isolate); 7641 JavaScriptFrameIterator it(isolate);
7645 JavaScriptFrame* frame = NULL; 7642 JavaScriptFrame* frame = NULL;
7646 for (int i = 0; i < frames - 1; i++) it.Advance(); 7643 for (int i = 0; i < frames - 1; i++) it.Advance();
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
8136 } 8133 }
8137 8134
8138 8135
8139 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { 8136 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
8140 HandleScope scope(isolate); 8137 HandleScope scope(isolate);
8141 ASSERT(args.length() == 4); 8138 ASSERT(args.length() == 4);
8142 8139
8143 Handle<Object> value(args[0], isolate); 8140 Handle<Object> value(args[0], isolate);
8144 CONVERT_ARG_CHECKED(Context, context, 1); 8141 CONVERT_ARG_CHECKED(Context, context, 1);
8145 CONVERT_ARG_CHECKED(String, name, 2); 8142 CONVERT_ARG_CHECKED(String, name, 2);
8146 CONVERT_SMI_CHECKED(strict_unchecked, args[3]); 8143 CONVERT_SMI_ARG_CHECKED(strict_unchecked, 3);
8147 RUNTIME_ASSERT(strict_unchecked == kStrictMode || 8144 RUNTIME_ASSERT(strict_unchecked == kStrictMode ||
8148 strict_unchecked == kNonStrictMode); 8145 strict_unchecked == kNonStrictMode);
8149 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(strict_unchecked); 8146 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(strict_unchecked);
8150 8147
8151 int index; 8148 int index;
8152 PropertyAttributes attributes; 8149 PropertyAttributes attributes;
8153 ContextLookupFlags flags = FOLLOW_CHAINS; 8150 ContextLookupFlags flags = FOLLOW_CHAINS;
8154 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); 8151 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes);
8155 8152
8156 if (index >= 0) { 8153 if (index >= 0) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
8450 } else { 8447 } else {
8451 return isolate->heap()->null_value(); 8448 return isolate->heap()->null_value();
8452 } 8449 }
8453 } 8450 }
8454 8451
8455 8452
8456 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { 8453 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) {
8457 NoHandleAllocation ha; 8454 NoHandleAllocation ha;
8458 ASSERT(args.length() == 1); 8455 ASSERT(args.length() == 1);
8459 8456
8460 CONVERT_DOUBLE_CHECKED(x, args[0]); 8457 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
8461 const char* zone = OS::LocalTimezone(x); 8458 const char* zone = OS::LocalTimezone(x);
8462 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); 8459 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone));
8463 } 8460 }
8464 8461
8465 8462
8466 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimeOffset) { 8463 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimeOffset) {
8467 NoHandleAllocation ha; 8464 NoHandleAllocation ha;
8468 ASSERT(args.length() == 0); 8465 ASSERT(args.length() == 0);
8469 8466
8470 return isolate->heap()->NumberFromDouble(OS::LocalTimeOffset()); 8467 return isolate->heap()->NumberFromDouble(OS::LocalTimeOffset());
8471 } 8468 }
8472 8469
8473 8470
8474 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateDaylightSavingsOffset) { 8471 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateDaylightSavingsOffset) {
8475 NoHandleAllocation ha; 8472 NoHandleAllocation ha;
8476 ASSERT(args.length() == 1); 8473 ASSERT(args.length() == 1);
8477 8474
8478 CONVERT_DOUBLE_CHECKED(x, args[0]); 8475 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
8479 return isolate->heap()->NumberFromDouble(OS::DaylightSavingsOffset(x)); 8476 return isolate->heap()->NumberFromDouble(OS::DaylightSavingsOffset(x));
8480 } 8477 }
8481 8478
8482 8479
8483 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { 8480 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) {
8484 ASSERT(args.length() == 1); 8481 ASSERT(args.length() == 1);
8485 Object* global = args[0]; 8482 Object* global = args[0];
8486 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); 8483 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
8487 return JSGlobalObject::cast(global)->global_receiver(); 8484 return JSGlobalObject::cast(global)->global_receiver();
8488 } 8485 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
8642 // Compare it to the builtin 'GlobalEval' function to make sure. 8639 // Compare it to the builtin 'GlobalEval' function to make sure.
8643 if (*callee != isolate->global_context()->global_eval_fun() || 8640 if (*callee != isolate->global_context()->global_eval_fun() ||
8644 !args[1]->IsString()) { 8641 !args[1]->IsString()) {
8645 return MakePair(*callee, isolate->heap()->the_hole_value()); 8642 return MakePair(*callee, isolate->heap()->the_hole_value());
8646 } 8643 }
8647 8644
8648 ASSERT(args[3]->IsSmi()); 8645 ASSERT(args[3]->IsSmi());
8649 return CompileGlobalEval(isolate, 8646 return CompileGlobalEval(isolate,
8650 args.at<String>(1), 8647 args.at<String>(1),
8651 args.at<Object>(2), 8648 args.at<Object>(2),
8652 static_cast<StrictModeFlag>( 8649 static_cast<StrictModeFlag>(args.smi_at(3)));
8653 Smi::cast(args[3])->value()));
8654 } 8650 }
8655 8651
8656 8652
8657 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEvalNoLookup) { 8653 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEvalNoLookup) {
8658 ASSERT(args.length() == 4); 8654 ASSERT(args.length() == 4);
8659 8655
8660 HandleScope scope(isolate); 8656 HandleScope scope(isolate);
8661 Handle<Object> callee = args.at<Object>(0); 8657 Handle<Object> callee = args.at<Object>(0);
8662 8658
8663 // 'eval' is bound in the global context, but it may have been overwritten. 8659 // 'eval' is bound in the global context, but it may have been overwritten.
8664 // Compare it to the builtin 'GlobalEval' function to make sure. 8660 // Compare it to the builtin 'GlobalEval' function to make sure.
8665 if (*callee != isolate->global_context()->global_eval_fun() || 8661 if (*callee != isolate->global_context()->global_eval_fun() ||
8666 !args[1]->IsString()) { 8662 !args[1]->IsString()) {
8667 return MakePair(*callee, isolate->heap()->the_hole_value()); 8663 return MakePair(*callee, isolate->heap()->the_hole_value());
8668 } 8664 }
8669 8665
8670 ASSERT(args[3]->IsSmi()); 8666 ASSERT(args[3]->IsSmi());
8671 return CompileGlobalEval(isolate, 8667 return CompileGlobalEval(isolate,
8672 args.at<String>(1), 8668 args.at<String>(1),
8673 args.at<Object>(2), 8669 args.at<Object>(2),
8674 static_cast<StrictModeFlag>( 8670 static_cast<StrictModeFlag>(args.smi_at(3)));
8675 Smi::cast(args[3])->value()));
8676 } 8671 }
8677 8672
8678 8673
8679 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { 8674 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) {
8680 // This utility adjusts the property attributes for newly created Function 8675 // This utility adjusts the property attributes for newly created Function
8681 // object ("new Function(...)") by changing the map. 8676 // object ("new Function(...)") by changing the map.
8682 // All it does is changing the prototype property to enumerable 8677 // All it does is changing the prototype property to enumerable
8683 // as specified in ECMA262, 15.3.5.2. 8678 // as specified in ECMA262, 15.3.5.2.
8684 HandleScope scope(isolate); 8679 HandleScope scope(isolate);
8685 ASSERT(args.length() == 1); 8680 ASSERT(args.length() == 1);
(...skipping 3038 matching lines...) Expand 10 before | Expand all | Expand 10 after
11724 return LiveObjectList::Capture(); 11719 return LiveObjectList::Capture();
11725 #else 11720 #else
11726 return isolate->heap()->undefined_value(); 11721 return isolate->heap()->undefined_value();
11727 #endif 11722 #endif
11728 } 11723 }
11729 11724
11730 11725
11731 // Deletes the specified live object list. 11726 // Deletes the specified live object list.
11732 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { 11727 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) {
11733 #ifdef LIVE_OBJECT_LIST 11728 #ifdef LIVE_OBJECT_LIST
11734 CONVERT_SMI_CHECKED(id, args[0]); 11729 CONVERT_SMI_ARG_CHECKED(id, 0);
11735 bool success = LiveObjectList::Delete(id); 11730 bool success = LiveObjectList::Delete(id);
11736 return success ? isolate->heap()->true_value() : 11731 return success ? isolate->heap()->true_value() :
11737 isolate->heap()->false_value(); 11732 isolate->heap()->false_value();
11738 #else 11733 #else
11739 return isolate->heap()->undefined_value(); 11734 return isolate->heap()->undefined_value();
11740 #endif 11735 #endif
11741 } 11736 }
11742 11737
11743 11738
11744 // Generates the response to a debugger request for a dump of the objects 11739 // Generates the response to a debugger request for a dump of the objects
11745 // contained in the difference between the captured live object lists 11740 // contained in the difference between the captured live object lists
11746 // specified by id1 and id2. 11741 // specified by id1 and id2.
11747 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be 11742 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
11748 // dumped. 11743 // dumped.
11749 RUNTIME_FUNCTION(MaybeObject*, Runtime_DumpLOL) { 11744 RUNTIME_FUNCTION(MaybeObject*, Runtime_DumpLOL) {
11750 #ifdef LIVE_OBJECT_LIST 11745 #ifdef LIVE_OBJECT_LIST
11751 HandleScope scope; 11746 HandleScope scope;
11752 CONVERT_SMI_CHECKED(id1, args[0]); 11747 CONVERT_SMI_ARG_CHECKED(id1, 0);
11753 CONVERT_SMI_CHECKED(id2, args[1]); 11748 CONVERT_SMI_ARG_CHECKED(id2, 1);
11754 CONVERT_SMI_CHECKED(start, args[2]); 11749 CONVERT_SMI_ARG_CHECKED(start, 2);
11755 CONVERT_SMI_CHECKED(count, args[3]); 11750 CONVERT_SMI_ARG_CHECKED(count, 3);
11756 CONVERT_ARG_CHECKED(JSObject, filter_obj, 4); 11751 CONVERT_ARG_CHECKED(JSObject, filter_obj, 4);
11757 EnterDebugger enter_debugger; 11752 EnterDebugger enter_debugger;
11758 return LiveObjectList::Dump(id1, id2, start, count, filter_obj); 11753 return LiveObjectList::Dump(id1, id2, start, count, filter_obj);
11759 #else 11754 #else
11760 return isolate->heap()->undefined_value(); 11755 return isolate->heap()->undefined_value();
11761 #endif 11756 #endif
11762 } 11757 }
11763 11758
11764 11759
11765 // Gets the specified object as requested by the debugger. 11760 // Gets the specified object as requested by the debugger.
11766 // This is only used for obj ids shown in live object lists. 11761 // This is only used for obj ids shown in live object lists.
11767 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObj) { 11762 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObj) {
11768 #ifdef LIVE_OBJECT_LIST 11763 #ifdef LIVE_OBJECT_LIST
11769 CONVERT_SMI_CHECKED(obj_id, args[0]); 11764 CONVERT_SMI_ARG_CHECKED(obj_id, 0);
11770 Object* result = LiveObjectList::GetObj(obj_id); 11765 Object* result = LiveObjectList::GetObj(obj_id);
11771 return result; 11766 return result;
11772 #else 11767 #else
11773 return isolate->heap()->undefined_value(); 11768 return isolate->heap()->undefined_value();
11774 #endif 11769 #endif
11775 } 11770 }
11776 11771
11777 11772
11778 // Gets the obj id for the specified address if valid. 11773 // Gets the obj id for the specified address if valid.
11779 // This is only used for obj ids shown in live object lists. 11774 // This is only used for obj ids shown in live object lists.
11780 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjId) { 11775 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjId) {
11781 #ifdef LIVE_OBJECT_LIST 11776 #ifdef LIVE_OBJECT_LIST
11782 HandleScope scope; 11777 HandleScope scope;
11783 CONVERT_ARG_CHECKED(String, address, 0); 11778 CONVERT_ARG_CHECKED(String, address, 0);
11784 Object* result = LiveObjectList::GetObjId(address); 11779 Object* result = LiveObjectList::GetObjId(address);
11785 return result; 11780 return result;
11786 #else 11781 #else
11787 return isolate->heap()->undefined_value(); 11782 return isolate->heap()->undefined_value();
11788 #endif 11783 #endif
11789 } 11784 }
11790 11785
11791 11786
11792 // Gets the retainers that references the specified object alive. 11787 // Gets the retainers that references the specified object alive.
11793 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjRetainers) { 11788 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjRetainers) {
11794 #ifdef LIVE_OBJECT_LIST 11789 #ifdef LIVE_OBJECT_LIST
11795 HandleScope scope; 11790 HandleScope scope;
11796 CONVERT_SMI_CHECKED(obj_id, args[0]); 11791 CONVERT_SMI_ARG_CHECKED(obj_id, 0);
11797 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject()); 11792 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject());
11798 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean()); 11793 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean());
11799 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi()); 11794 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi());
11800 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi()); 11795 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi());
11801 CONVERT_ARG_CHECKED(JSObject, filter_obj, 5); 11796 CONVERT_ARG_CHECKED(JSObject, filter_obj, 5);
11802 11797
11803 Handle<JSObject> instance_filter; 11798 Handle<JSObject> instance_filter;
11804 if (args[1]->IsJSObject()) { 11799 if (args[1]->IsJSObject()) {
11805 instance_filter = args.at<JSObject>(1); 11800 instance_filter = args.at<JSObject>(1);
11806 } 11801 }
11807 bool verbose = false; 11802 bool verbose = false;
11808 if (args[2]->IsBoolean()) { 11803 if (args[2]->IsBoolean()) {
11809 verbose = args[2]->IsTrue(); 11804 verbose = args[2]->IsTrue();
11810 } 11805 }
11811 int start = 0; 11806 int start = 0;
11812 if (args[3]->IsSmi()) { 11807 if (args[3]->IsSmi()) {
11813 start = Smi::cast(args[3])->value(); 11808 start = args.smi_at(3);
11814 } 11809 }
11815 int limit = Smi::kMaxValue; 11810 int limit = Smi::kMaxValue;
11816 if (args[4]->IsSmi()) { 11811 if (args[4]->IsSmi()) {
11817 limit = Smi::cast(args[4])->value(); 11812 limit = args.smi_at(4);
11818 } 11813 }
11819 11814
11820 return LiveObjectList::GetObjRetainers(obj_id, 11815 return LiveObjectList::GetObjRetainers(obj_id,
11821 instance_filter, 11816 instance_filter,
11822 verbose, 11817 verbose,
11823 start, 11818 start,
11824 limit, 11819 limit,
11825 filter_obj); 11820 filter_obj);
11826 #else 11821 #else
11827 return isolate->heap()->undefined_value(); 11822 return isolate->heap()->undefined_value();
11828 #endif 11823 #endif
11829 } 11824 }
11830 11825
11831 11826
11832 // Gets the reference path between 2 objects. 11827 // Gets the reference path between 2 objects.
11833 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLPath) { 11828 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLPath) {
11834 #ifdef LIVE_OBJECT_LIST 11829 #ifdef LIVE_OBJECT_LIST
11835 HandleScope scope; 11830 HandleScope scope;
11836 CONVERT_SMI_CHECKED(obj_id1, args[0]); 11831 CONVERT_SMI_ARG_CHECKED(obj_id1, 0);
11837 CONVERT_SMI_CHECKED(obj_id2, args[1]); 11832 CONVERT_SMI_ARG_CHECKED(obj_id2, 1);
11838 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject()); 11833 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject());
11839 11834
11840 Handle<JSObject> instance_filter; 11835 Handle<JSObject> instance_filter;
11841 if (args[2]->IsJSObject()) { 11836 if (args[2]->IsJSObject()) {
11842 instance_filter = args.at<JSObject>(2); 11837 instance_filter = args.at<JSObject>(2);
11843 } 11838 }
11844 11839
11845 Object* result = 11840 Object* result =
11846 LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter); 11841 LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter);
11847 return result; 11842 return result;
11848 #else 11843 #else
11849 return isolate->heap()->undefined_value(); 11844 return isolate->heap()->undefined_value();
11850 #endif 11845 #endif
11851 } 11846 }
11852 11847
11853 11848
11854 // Generates the response to a debugger request for a list of all 11849 // Generates the response to a debugger request for a list of all
11855 // previously captured live object lists. 11850 // previously captured live object lists.
11856 RUNTIME_FUNCTION(MaybeObject*, Runtime_InfoLOL) { 11851 RUNTIME_FUNCTION(MaybeObject*, Runtime_InfoLOL) {
11857 #ifdef LIVE_OBJECT_LIST 11852 #ifdef LIVE_OBJECT_LIST
11858 CONVERT_SMI_CHECKED(start, args[0]); 11853 CONVERT_SMI_ARG_CHECKED(start, 0);
11859 CONVERT_SMI_CHECKED(count, args[1]); 11854 CONVERT_SMI_ARG_CHECKED(count, 1);
11860 return LiveObjectList::Info(start, count); 11855 return LiveObjectList::Info(start, count);
11861 #else 11856 #else
11862 return isolate->heap()->undefined_value(); 11857 return isolate->heap()->undefined_value();
11863 #endif 11858 #endif
11864 } 11859 }
11865 11860
11866 11861
11867 // Gets a dump of the specified object as requested by the debugger. 11862 // Gets a dump of the specified object as requested by the debugger.
11868 // This is only used for obj ids shown in live object lists. 11863 // This is only used for obj ids shown in live object lists.
11869 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrintLOLObj) { 11864 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrintLOLObj) {
11870 #ifdef LIVE_OBJECT_LIST 11865 #ifdef LIVE_OBJECT_LIST
11871 HandleScope scope; 11866 HandleScope scope;
11872 CONVERT_SMI_CHECKED(obj_id, args[0]); 11867 CONVERT_SMI_ARG_CHECKED(obj_id, 0);
11873 Object* result = LiveObjectList::PrintObj(obj_id); 11868 Object* result = LiveObjectList::PrintObj(obj_id);
11874 return result; 11869 return result;
11875 #else 11870 #else
11876 return isolate->heap()->undefined_value(); 11871 return isolate->heap()->undefined_value();
11877 #endif 11872 #endif
11878 } 11873 }
11879 11874
11880 11875
11881 // Resets and releases all previously captured live object lists. 11876 // Resets and releases all previously captured live object lists.
11882 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResetLOL) { 11877 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResetLOL) {
11883 #ifdef LIVE_OBJECT_LIST 11878 #ifdef LIVE_OBJECT_LIST
11884 LiveObjectList::Reset(); 11879 LiveObjectList::Reset();
11885 return isolate->heap()->undefined_value(); 11880 return isolate->heap()->undefined_value();
11886 #else 11881 #else
11887 return isolate->heap()->undefined_value(); 11882 return isolate->heap()->undefined_value();
11888 #endif 11883 #endif
11889 } 11884 }
11890 11885
11891 11886
11892 // Generates the response to a debugger request for a summary of the types 11887 // Generates the response to a debugger request for a summary of the types
11893 // of objects in the difference between the captured live object lists 11888 // of objects in the difference between the captured live object lists
11894 // specified by id1 and id2. 11889 // specified by id1 and id2.
11895 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be 11890 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
11896 // summarized. 11891 // summarized.
11897 RUNTIME_FUNCTION(MaybeObject*, Runtime_SummarizeLOL) { 11892 RUNTIME_FUNCTION(MaybeObject*, Runtime_SummarizeLOL) {
11898 #ifdef LIVE_OBJECT_LIST 11893 #ifdef LIVE_OBJECT_LIST
11899 HandleScope scope; 11894 HandleScope scope;
11900 CONVERT_SMI_CHECKED(id1, args[0]); 11895 CONVERT_SMI_ARG_CHECKED(id1, 0);
11901 CONVERT_SMI_CHECKED(id2, args[1]); 11896 CONVERT_SMI_ARG_CHECKED(id2, 1);
11902 CONVERT_ARG_CHECKED(JSObject, filter_obj, 2); 11897 CONVERT_ARG_CHECKED(JSObject, filter_obj, 2);
11903 11898
11904 EnterDebugger enter_debugger; 11899 EnterDebugger enter_debugger;
11905 return LiveObjectList::Summarize(id1, id2, filter_obj); 11900 return LiveObjectList::Summarize(id1, id2, filter_obj);
11906 #else 11901 #else
11907 return isolate->heap()->undefined_value(); 11902 return isolate->heap()->undefined_value();
11908 #endif 11903 #endif
11909 } 11904 }
11910 11905
11911 #endif // ENABLE_DEBUGGER_SUPPORT 11906 #endif // ENABLE_DEBUGGER_SUPPORT
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
12081 12076
12082 const char* version_string = v8::V8::GetVersion(); 12077 const char* version_string = v8::V8::GetVersion();
12083 12078
12084 return isolate->heap()->AllocateStringFromAscii(CStrVector(version_string), 12079 return isolate->heap()->AllocateStringFromAscii(CStrVector(version_string),
12085 NOT_TENURED); 12080 NOT_TENURED);
12086 } 12081 }
12087 12082
12088 12083
12089 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { 12084 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) {
12090 ASSERT(args.length() == 2); 12085 ASSERT(args.length() == 2);
12091 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + 12086 OS::PrintError("abort: %s\n",
12092 Smi::cast(args[1])->value()); 12087 reinterpret_cast<char*>(args[0]) + args.smi_at(1));
12093 isolate->PrintStack(); 12088 isolate->PrintStack();
12094 OS::Abort(); 12089 OS::Abort();
12095 UNREACHABLE(); 12090 UNREACHABLE();
12096 return NULL; 12091 return NULL;
12097 } 12092 }
12098 12093
12099 12094
12100 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { 12095 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) {
12101 // This is only called from codegen, so checks might be more lax. 12096 // This is only called from codegen, so checks might be more lax.
12102 CONVERT_CHECKED(JSFunctionResultCache, cache, args[0]); 12097 CONVERT_CHECKED(JSFunctionResultCache, cache, args[0]);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
12364 } else { 12359 } else {
12365 // Handle last resort GC and make sure to allow future allocations 12360 // Handle last resort GC and make sure to allow future allocations
12366 // to grow the heap without causing GCs (if possible). 12361 // to grow the heap without causing GCs (if possible).
12367 isolate->counters()->gc_last_resort_from_js()->Increment(); 12362 isolate->counters()->gc_last_resort_from_js()->Increment();
12368 isolate->heap()->CollectAllGarbage(false); 12363 isolate->heap()->CollectAllGarbage(false);
12369 } 12364 }
12370 } 12365 }
12371 12366
12372 12367
12373 } } // namespace v8::internal 12368 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698