| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 561 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
| 562 Symbol* symbol; | 562 Symbol* symbol; |
| 563 MaybeObject* maybe = isolate->heap()->AllocateSymbol(); | 563 MaybeObject* maybe = isolate->heap()->AllocateSymbol(); |
| 564 if (!maybe->To(&symbol)) return maybe; | 564 if (!maybe->To(&symbol)) return maybe; |
| 565 if (name->IsString()) symbol->set_name(*name); | 565 if (name->IsString()) symbol->set_name(*name); |
| 566 return symbol; | 566 return symbol; |
| 567 } | 567 } |
| 568 | 568 |
| 569 | 569 |
| 570 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolName) { | 570 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolName) { |
| 571 NoHandleAllocation ha(isolate); | 571 RequireNewHandleScope rnhs(isolate); |
| 572 ASSERT(args.length() == 1); | 572 ASSERT(args.length() == 1); |
| 573 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 573 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
| 574 return symbol->name(); | 574 return symbol->name(); |
| 575 } | 575 } |
| 576 | 576 |
| 577 | 577 |
| 578 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { | 578 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { |
| 579 NoHandleAllocation ha(isolate); | 579 RequireNewHandleScope rnhs(isolate); |
| 580 ASSERT(args.length() == 2); | 580 ASSERT(args.length() == 2); |
| 581 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); | 581 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); |
| 582 Object* prototype = args[1]; | 582 Object* prototype = args[1]; |
| 583 Object* used_prototype = | 583 Object* used_prototype = |
| 584 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); | 584 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
| 585 return isolate->heap()->AllocateJSProxy(handler, used_prototype); | 585 return isolate->heap()->AllocateJSProxy(handler, used_prototype); |
| 586 } | 586 } |
| 587 | 587 |
| 588 | 588 |
| 589 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) { | 589 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) { |
| 590 NoHandleAllocation ha(isolate); | 590 RequireNewHandleScope rnhs(isolate); |
| 591 ASSERT(args.length() == 4); | 591 ASSERT(args.length() == 4); |
| 592 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); | 592 CONVERT_ARG_CHECKED(JSReceiver, handler, 0); |
| 593 Object* call_trap = args[1]; | 593 Object* call_trap = args[1]; |
| 594 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); | 594 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); |
| 595 CONVERT_ARG_CHECKED(JSFunction, construct_trap, 2); | 595 CONVERT_ARG_CHECKED(JSFunction, construct_trap, 2); |
| 596 Object* prototype = args[3]; | 596 Object* prototype = args[3]; |
| 597 Object* used_prototype = | 597 Object* used_prototype = |
| 598 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); | 598 prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
| 599 return isolate->heap()->AllocateJSFunctionProxy( | 599 return isolate->heap()->AllocateJSFunctionProxy( |
| 600 handler, call_trap, construct_trap, used_prototype); | 600 handler, call_trap, construct_trap, used_prototype); |
| 601 } | 601 } |
| 602 | 602 |
| 603 | 603 |
| 604 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { | 604 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { |
| 605 NoHandleAllocation ha(isolate); | 605 RequireNewHandleScope rnhs(isolate); |
| 606 ASSERT(args.length() == 1); | 606 ASSERT(args.length() == 1); |
| 607 Object* obj = args[0]; | 607 Object* obj = args[0]; |
| 608 return isolate->heap()->ToBoolean(obj->IsJSProxy()); | 608 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
| 609 } | 609 } |
| 610 | 610 |
| 611 | 611 |
| 612 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { | 612 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { |
| 613 NoHandleAllocation ha(isolate); | 613 RequireNewHandleScope rnhs(isolate); |
| 614 ASSERT(args.length() == 1); | 614 ASSERT(args.length() == 1); |
| 615 Object* obj = args[0]; | 615 Object* obj = args[0]; |
| 616 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); | 616 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); |
| 617 } | 617 } |
| 618 | 618 |
| 619 | 619 |
| 620 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | 620 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { |
| 621 NoHandleAllocation ha(isolate); | 621 RequireNewHandleScope rnhs(isolate); |
| 622 ASSERT(args.length() == 1); | 622 ASSERT(args.length() == 1); |
| 623 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); | 623 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); |
| 624 return proxy->handler(); | 624 return proxy->handler(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 | 627 |
| 628 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { | 628 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { |
| 629 NoHandleAllocation ha(isolate); | 629 RequireNewHandleScope rnhs(isolate); |
| 630 ASSERT(args.length() == 1); | 630 ASSERT(args.length() == 1); |
| 631 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 631 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
| 632 return proxy->call_trap(); | 632 return proxy->call_trap(); |
| 633 } | 633 } |
| 634 | 634 |
| 635 | 635 |
| 636 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { | 636 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { |
| 637 NoHandleAllocation ha(isolate); | 637 RequireNewHandleScope rnhs(isolate); |
| 638 ASSERT(args.length() == 1); | 638 ASSERT(args.length() == 1); |
| 639 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 639 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
| 640 return proxy->construct_trap(); | 640 return proxy->construct_trap(); |
| 641 } | 641 } |
| 642 | 642 |
| 643 | 643 |
| 644 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { | 644 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { |
| 645 NoHandleAllocation ha(isolate); | 645 RequireNewHandleScope rnhs(isolate); |
| 646 ASSERT(args.length() == 1); | 646 ASSERT(args.length() == 1); |
| 647 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); | 647 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); |
| 648 proxy->Fix(); | 648 proxy->Fix(); |
| 649 return isolate->heap()->undefined_value(); | 649 return isolate->heap()->undefined_value(); |
| 650 } | 650 } |
| 651 | 651 |
| 652 | 652 |
| 653 static void ArrayBufferWeakCallback(v8::Isolate* external_isolate, | 653 static void ArrayBufferWeakCallback(v8::Isolate* external_isolate, |
| 654 Persistent<Value>* object, | 654 Persistent<Value>* object, |
| 655 void* data) { | 655 void* data) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 return isolate->Throw(*isolate->factory()-> | 744 return isolate->Throw(*isolate->factory()-> |
| 745 NewRangeError("invalid_array_buffer_length", | 745 NewRangeError("invalid_array_buffer_length", |
| 746 HandleVector<Object>(NULL, 0))); | 746 HandleVector<Object>(NULL, 0))); |
| 747 } | 747 } |
| 748 | 748 |
| 749 return *holder; | 749 return *holder; |
| 750 } | 750 } |
| 751 | 751 |
| 752 | 752 |
| 753 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferGetByteLength) { | 753 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferGetByteLength) { |
| 754 NoHandleAllocation ha(isolate); | 754 RequireNewHandleScope rnhs(isolate); |
| 755 ASSERT(args.length() == 1); | 755 ASSERT(args.length() == 1); |
| 756 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); | 756 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); |
| 757 return holder->byte_length(); | 757 return holder->byte_length(); |
| 758 } | 758 } |
| 759 | 759 |
| 760 | 760 |
| 761 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferSliceImpl) { | 761 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferSliceImpl) { |
| 762 HandleScope scope(isolate); | 762 HandleScope scope(isolate); |
| 763 ASSERT(args.length() == 3); | 763 ASSERT(args.length() == 3); |
| 764 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); | 764 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1188 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 1189 Handle<Object> value(args[2], isolate); | 1189 Handle<Object> value(args[2], isolate); |
| 1190 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 1190 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 1191 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); | 1191 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
| 1192 weakmap->set_table(*new_table); | 1192 weakmap->set_table(*new_table); |
| 1193 return isolate->heap()->undefined_value(); | 1193 return isolate->heap()->undefined_value(); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 | 1196 |
| 1197 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 1197 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
| 1198 NoHandleAllocation ha(isolate); | 1198 RequireNewHandleScope rnhs(isolate); |
| 1199 ASSERT(args.length() == 1); | 1199 ASSERT(args.length() == 1); |
| 1200 Object* obj = args[0]; | 1200 Object* obj = args[0]; |
| 1201 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 1201 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
| 1202 return JSObject::cast(obj)->class_name(); | 1202 return JSObject::cast(obj)->class_name(); |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 | 1205 |
| 1206 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 1206 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { |
| 1207 NoHandleAllocation ha(isolate); | 1207 RequireNewHandleScope rnhs(isolate); |
| 1208 ASSERT(args.length() == 1); | 1208 ASSERT(args.length() == 1); |
| 1209 CONVERT_ARG_CHECKED(Object, obj, 0); | 1209 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 1210 // We don't expect access checks to be needed on JSProxy objects. | 1210 // We don't expect access checks to be needed on JSProxy objects. |
| 1211 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 1211 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 1212 do { | 1212 do { |
| 1213 if (obj->IsAccessCheckNeeded() && | 1213 if (obj->IsAccessCheckNeeded() && |
| 1214 !isolate->MayNamedAccess(JSObject::cast(obj), | 1214 !isolate->MayNamedAccess(JSObject::cast(obj), |
| 1215 isolate->heap()->proto_string(), | 1215 isolate->heap()->proto_string(), |
| 1216 v8::ACCESS_GET)) { | 1216 v8::ACCESS_GET)) { |
| 1217 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); | 1217 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1229 Object* current = receiver->GetPrototype(isolate); | 1229 Object* current = receiver->GetPrototype(isolate); |
| 1230 while (current->IsJSObject() && | 1230 while (current->IsJSObject() && |
| 1231 JSObject::cast(current)->map()->is_hidden_prototype()) { | 1231 JSObject::cast(current)->map()->is_hidden_prototype()) { |
| 1232 current = current->GetPrototype(isolate); | 1232 current = current->GetPrototype(isolate); |
| 1233 } | 1233 } |
| 1234 return current; | 1234 return current; |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 | 1237 |
| 1238 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) { | 1238 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) { |
| 1239 NoHandleAllocation ha(isolate); | 1239 RequireNewHandleScope rnhs(isolate); |
| 1240 ASSERT(args.length() == 2); | 1240 ASSERT(args.length() == 2); |
| 1241 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 1241 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
| 1242 CONVERT_ARG_CHECKED(Object, prototype, 1); | 1242 CONVERT_ARG_CHECKED(Object, prototype, 1); |
| 1243 if (FLAG_harmony_observation && obj->map()->is_observed()) { | 1243 if (FLAG_harmony_observation && obj->map()->is_observed()) { |
| 1244 HandleScope scope(isolate); | 1244 HandleScope scope(isolate); |
| 1245 Handle<JSObject> receiver(obj); | 1245 Handle<JSObject> receiver(obj); |
| 1246 Handle<Object> value(prototype, isolate); | 1246 Handle<Object> value(prototype, isolate); |
| 1247 Handle<Object> old_value( | 1247 Handle<Object> old_value( |
| 1248 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); | 1248 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); |
| 1249 | 1249 |
| 1250 MaybeObject* result = receiver->SetPrototype(*value, true); | 1250 MaybeObject* result = receiver->SetPrototype(*value, true); |
| 1251 Handle<Object> hresult; | 1251 Handle<Object> hresult; |
| 1252 if (!result->ToHandle(&hresult, isolate)) return result; | 1252 if (!result->ToHandle(&hresult, isolate)) return result; |
| 1253 | 1253 |
| 1254 Handle<Object> new_value( | 1254 Handle<Object> new_value( |
| 1255 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); | 1255 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); |
| 1256 if (!new_value->SameValue(*old_value)) { | 1256 if (!new_value->SameValue(*old_value)) { |
| 1257 JSObject::EnqueueChangeRecord(receiver, "prototype", | 1257 JSObject::EnqueueChangeRecord(receiver, "prototype", |
| 1258 isolate->factory()->proto_string(), | 1258 isolate->factory()->proto_string(), |
| 1259 old_value); | 1259 old_value); |
| 1260 } | 1260 } |
| 1261 return *hresult; | 1261 return *hresult; |
| 1262 } | 1262 } |
| 1263 return obj->SetPrototype(prototype, true); | 1263 return obj->SetPrototype(prototype, true); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 | 1266 |
| 1267 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 1267 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { |
| 1268 NoHandleAllocation ha(isolate); | 1268 RequireNewHandleScope rnhs(isolate); |
| 1269 ASSERT(args.length() == 2); | 1269 ASSERT(args.length() == 2); |
| 1270 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 1270 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
| 1271 Object* O = args[0]; | 1271 Object* O = args[0]; |
| 1272 Object* V = args[1]; | 1272 Object* V = args[1]; |
| 1273 while (true) { | 1273 while (true) { |
| 1274 Object* prototype = V->GetPrototype(isolate); | 1274 Object* prototype = V->GetPrototype(isolate); |
| 1275 if (prototype->IsNull()) return isolate->heap()->false_value(); | 1275 if (prototype->IsNull()) return isolate->heap()->false_value(); |
| 1276 if (O == prototype) return isolate->heap()->true_value(); | 1276 if (O == prototype) return isolate->heap()->true_value(); |
| 1277 V = prototype; | 1277 V = prototype; |
| 1278 } | 1278 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { | 1451 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { |
| 1452 HandleScope scope(isolate); | 1452 HandleScope scope(isolate); |
| 1453 ASSERT(args.length() == 2); | 1453 ASSERT(args.length() == 2); |
| 1454 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1454 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 1455 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 1455 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 1456 return GetOwnProperty(isolate, obj, name); | 1456 return GetOwnProperty(isolate, obj, name); |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 | 1459 |
| 1460 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { | 1460 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { |
| 1461 NoHandleAllocation ha(isolate); | 1461 RequireNewHandleScope rnhs(isolate); |
| 1462 ASSERT(args.length() == 1); | 1462 ASSERT(args.length() == 1); |
| 1463 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 1463 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
| 1464 return obj->PreventExtensions(); | 1464 return obj->PreventExtensions(); |
| 1465 } | 1465 } |
| 1466 | 1466 |
| 1467 | 1467 |
| 1468 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { | 1468 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { |
| 1469 NoHandleAllocation ha(isolate); | 1469 RequireNewHandleScope rnhs(isolate); |
| 1470 ASSERT(args.length() == 1); | 1470 ASSERT(args.length() == 1); |
| 1471 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 1471 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
| 1472 if (obj->IsJSGlobalProxy()) { | 1472 if (obj->IsJSGlobalProxy()) { |
| 1473 Object* proto = obj->GetPrototype(); | 1473 Object* proto = obj->GetPrototype(); |
| 1474 if (proto->IsNull()) return isolate->heap()->false_value(); | 1474 if (proto->IsNull()) return isolate->heap()->false_value(); |
| 1475 ASSERT(proto->IsJSGlobalObject()); | 1475 ASSERT(proto->IsJSGlobalObject()); |
| 1476 obj = JSObject::cast(proto); | 1476 obj = JSObject::cast(proto); |
| 1477 } | 1477 } |
| 1478 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); | 1478 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
| 1479 } | 1479 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1494 | 1494 |
| 1495 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { | 1495 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { |
| 1496 HandleScope scope(isolate); | 1496 HandleScope scope(isolate); |
| 1497 ASSERT(args.length() == 1); | 1497 ASSERT(args.length() == 1); |
| 1498 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); | 1498 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); |
| 1499 return *isolate->factory()->CreateApiFunction(data); | 1499 return *isolate->factory()->CreateApiFunction(data); |
| 1500 } | 1500 } |
| 1501 | 1501 |
| 1502 | 1502 |
| 1503 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { | 1503 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { |
| 1504 NoHandleAllocation ha(isolate); | 1504 RequireNewHandleScope rnhs(isolate); |
| 1505 ASSERT(args.length() == 1); | 1505 ASSERT(args.length() == 1); |
| 1506 Object* arg = args[0]; | 1506 Object* arg = args[0]; |
| 1507 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 1507 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
| 1508 return isolate->heap()->ToBoolean(result); | 1508 return isolate->heap()->ToBoolean(result); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 | 1511 |
| 1512 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { | 1512 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { |
| 1513 NoHandleAllocation ha(isolate); | 1513 RequireNewHandleScope rnhs(isolate); |
| 1514 ASSERT(args.length() == 2); | 1514 ASSERT(args.length() == 2); |
| 1515 CONVERT_ARG_CHECKED(HeapObject, templ, 0); | 1515 CONVERT_ARG_CHECKED(HeapObject, templ, 0); |
| 1516 CONVERT_SMI_ARG_CHECKED(index, 1) | 1516 CONVERT_SMI_ARG_CHECKED(index, 1) |
| 1517 int offset = index * kPointerSize + HeapObject::kHeaderSize; | 1517 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
| 1518 InstanceType type = templ->map()->instance_type(); | 1518 InstanceType type = templ->map()->instance_type(); |
| 1519 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | 1519 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
| 1520 type == OBJECT_TEMPLATE_INFO_TYPE); | 1520 type == OBJECT_TEMPLATE_INFO_TYPE); |
| 1521 RUNTIME_ASSERT(offset > 0); | 1521 RUNTIME_ASSERT(offset > 0); |
| 1522 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | 1522 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
| 1523 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | 1523 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
| 1524 } else { | 1524 } else { |
| 1525 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | 1525 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
| 1526 } | 1526 } |
| 1527 return *HeapObject::RawField(templ, offset); | 1527 return *HeapObject::RawField(templ, offset); |
| 1528 } | 1528 } |
| 1529 | 1529 |
| 1530 | 1530 |
| 1531 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { | 1531 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { |
| 1532 NoHandleAllocation ha(isolate); | 1532 RequireNewHandleScope rnhs(isolate); |
| 1533 ASSERT(args.length() == 1); | 1533 ASSERT(args.length() == 1); |
| 1534 CONVERT_ARG_CHECKED(HeapObject, object, 0); | 1534 CONVERT_ARG_CHECKED(HeapObject, object, 0); |
| 1535 Map* old_map = object->map(); | 1535 Map* old_map = object->map(); |
| 1536 bool needs_access_checks = old_map->is_access_check_needed(); | 1536 bool needs_access_checks = old_map->is_access_check_needed(); |
| 1537 if (needs_access_checks) { | 1537 if (needs_access_checks) { |
| 1538 // Copy map so it won't interfere constructor's initial map. | 1538 // Copy map so it won't interfere constructor's initial map. |
| 1539 Map* new_map; | 1539 Map* new_map; |
| 1540 MaybeObject* maybe_new_map = old_map->Copy(); | 1540 MaybeObject* maybe_new_map = old_map->Copy(); |
| 1541 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 1541 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 1542 | 1542 |
| 1543 new_map->set_is_access_check_needed(false); | 1543 new_map->set_is_access_check_needed(false); |
| 1544 object->set_map(new_map); | 1544 object->set_map(new_map); |
| 1545 } | 1545 } |
| 1546 return isolate->heap()->ToBoolean(needs_access_checks); | 1546 return isolate->heap()->ToBoolean(needs_access_checks); |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 | 1549 |
| 1550 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { | 1550 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { |
| 1551 NoHandleAllocation ha(isolate); | 1551 RequireNewHandleScope rnhs(isolate); |
| 1552 ASSERT(args.length() == 1); | 1552 ASSERT(args.length() == 1); |
| 1553 CONVERT_ARG_CHECKED(HeapObject, object, 0); | 1553 CONVERT_ARG_CHECKED(HeapObject, object, 0); |
| 1554 Map* old_map = object->map(); | 1554 Map* old_map = object->map(); |
| 1555 if (!old_map->is_access_check_needed()) { | 1555 if (!old_map->is_access_check_needed()) { |
| 1556 // Copy map so it won't interfere constructor's initial map. | 1556 // Copy map so it won't interfere constructor's initial map. |
| 1557 Map* new_map; | 1557 Map* new_map; |
| 1558 MaybeObject* maybe_new_map = old_map->Copy(); | 1558 MaybeObject* maybe_new_map = old_map->Copy(); |
| 1559 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 1559 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 1560 | 1560 |
| 1561 new_map->set_is_access_check_needed(true); | 1561 new_map->set_is_access_check_needed(true); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 RETURN_IF_EMPTY_HANDLE(isolate, | 1774 RETURN_IF_EMPTY_HANDLE(isolate, |
| 1775 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); | 1775 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); |
| 1776 } | 1776 } |
| 1777 } | 1777 } |
| 1778 | 1778 |
| 1779 return isolate->heap()->undefined_value(); | 1779 return isolate->heap()->undefined_value(); |
| 1780 } | 1780 } |
| 1781 | 1781 |
| 1782 | 1782 |
| 1783 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { | 1783 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
| 1784 NoHandleAllocation nha(isolate); | 1784 RequireNewHandleScope rnhs(isolate); |
| 1785 // args[0] == name | 1785 // args[0] == name |
| 1786 // args[1] == language_mode | 1786 // args[1] == language_mode |
| 1787 // args[2] == value (optional) | 1787 // args[2] == value (optional) |
| 1788 | 1788 |
| 1789 // Determine if we need to assign to the variable if it already | 1789 // Determine if we need to assign to the variable if it already |
| 1790 // exists (based on the number of arguments). | 1790 // exists (based on the number of arguments). |
| 1791 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 1791 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
| 1792 bool assign = args.length() == 3; | 1792 bool assign = args.length() == 3; |
| 1793 | 1793 |
| 1794 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 1794 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 // Reload global in case the loop above performed a GC. | 1830 // Reload global in case the loop above performed a GC. |
| 1831 global = isolate->context()->global_object(); | 1831 global = isolate->context()->global_object(); |
| 1832 if (assign) { | 1832 if (assign) { |
| 1833 return global->SetProperty(*name, args[2], attributes, strict_mode_flag); | 1833 return global->SetProperty(*name, args[2], attributes, strict_mode_flag); |
| 1834 } | 1834 } |
| 1835 return isolate->heap()->undefined_value(); | 1835 return isolate->heap()->undefined_value(); |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 | 1838 |
| 1839 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { | 1839 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { |
| 1840 NoHandleAllocation ha(isolate); | 1840 RequireNewHandleScope rnhs(isolate); |
| 1841 // All constants are declared with an initial value. The name | 1841 // All constants are declared with an initial value. The name |
| 1842 // of the constant is the first argument and the initial value | 1842 // of the constant is the first argument and the initial value |
| 1843 // is the second. | 1843 // is the second. |
| 1844 RUNTIME_ASSERT(args.length() == 2); | 1844 RUNTIME_ASSERT(args.length() == 2); |
| 1845 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 1845 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| 1846 Handle<Object> value = args.at<Object>(1); | 1846 Handle<Object> value = args.at<Object>(1); |
| 1847 | 1847 |
| 1848 // Get the current global object from top. | 1848 // Get the current global object from top. |
| 1849 GlobalObject* global = isolate->context()->global_object(); | 1849 GlobalObject* global = isolate->context()->global_object(); |
| 1850 | 1850 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 Handle<Object> result = RegExpImpl::Exec(regexp, | 2036 Handle<Object> result = RegExpImpl::Exec(regexp, |
| 2037 subject, | 2037 subject, |
| 2038 index, | 2038 index, |
| 2039 last_match_info); | 2039 last_match_info); |
| 2040 if (result.is_null()) return Failure::Exception(); | 2040 if (result.is_null()) return Failure::Exception(); |
| 2041 return *result; | 2041 return *result; |
| 2042 } | 2042 } |
| 2043 | 2043 |
| 2044 | 2044 |
| 2045 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { | 2045 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { |
| 2046 NoHandleAllocation ha(isolate); | 2046 RequireNewHandleScope rnhs(isolate); |
| 2047 ASSERT(args.length() == 3); | 2047 ASSERT(args.length() == 3); |
| 2048 CONVERT_SMI_ARG_CHECKED(elements_count, 0); | 2048 CONVERT_SMI_ARG_CHECKED(elements_count, 0); |
| 2049 if (elements_count < 0 || | 2049 if (elements_count < 0 || |
| 2050 elements_count > FixedArray::kMaxLength || | 2050 elements_count > FixedArray::kMaxLength || |
| 2051 !Smi::IsValid(elements_count)) { | 2051 !Smi::IsValid(elements_count)) { |
| 2052 return isolate->ThrowIllegalOperation(); | 2052 return isolate->ThrowIllegalOperation(); |
| 2053 } | 2053 } |
| 2054 Object* new_object; | 2054 Object* new_object; |
| 2055 { MaybeObject* maybe_new_object = | 2055 { MaybeObject* maybe_new_object = |
| 2056 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); | 2056 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); |
| 2057 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | 2057 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
| 2058 } | 2058 } |
| 2059 FixedArray* elements = FixedArray::cast(new_object); | 2059 FixedArray* elements = FixedArray::cast(new_object); |
| 2060 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( | 2060 { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( |
| 2061 JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE); | 2061 JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE); |
| 2062 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | 2062 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
| 2063 } | 2063 } |
| 2064 { | 2064 { |
| 2065 AssertNoAllocation no_gc; | 2065 DisallowHeapAllocation no_gc; |
| 2066 HandleScope scope(isolate); | 2066 HandleScope scope(isolate); |
| 2067 reinterpret_cast<HeapObject*>(new_object)-> | 2067 reinterpret_cast<HeapObject*>(new_object)-> |
| 2068 set_map(isolate->native_context()->regexp_result_map()); | 2068 set_map(isolate->native_context()->regexp_result_map()); |
| 2069 } | 2069 } |
| 2070 JSArray* array = JSArray::cast(new_object); | 2070 JSArray* array = JSArray::cast(new_object); |
| 2071 array->set_properties(isolate->heap()->empty_fixed_array()); | 2071 array->set_properties(isolate->heap()->empty_fixed_array()); |
| 2072 array->set_elements(elements); | 2072 array->set_elements(elements); |
| 2073 array->set_length(Smi::FromInt(elements_count)); | 2073 array->set_length(Smi::FromInt(elements_count)); |
| 2074 // Write in-object properties after the length of the array. | 2074 // Write in-object properties after the length of the array. |
| 2075 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); | 2075 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); |
| 2076 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); | 2076 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); |
| 2077 return array; | 2077 return array; |
| 2078 } | 2078 } |
| 2079 | 2079 |
| 2080 | 2080 |
| 2081 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { | 2081 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { |
| 2082 NoHandleAllocation ha(isolate); | 2082 RequireNewHandleScope rnhs(isolate); |
| 2083 AssertNoAllocation no_alloc; | 2083 DisallowHeapAllocation no_allocation; |
| 2084 ASSERT(args.length() == 5); | 2084 ASSERT(args.length() == 5); |
| 2085 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); | 2085 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
| 2086 CONVERT_ARG_CHECKED(String, source, 1); | 2086 CONVERT_ARG_CHECKED(String, source, 1); |
| 2087 // If source is the empty string we set it to "(?:)" instead as | 2087 // If source is the empty string we set it to "(?:)" instead as |
| 2088 // suggested by ECMA-262, 5th, section 15.10.4.1. | 2088 // suggested by ECMA-262, 5th, section 15.10.4.1. |
| 2089 if (source->length() == 0) source = isolate->heap()->query_colon_string(); | 2089 if (source->length() == 0) source = isolate->heap()->query_colon_string(); |
| 2090 | 2090 |
| 2091 Object* global = args[2]; | 2091 Object* global = args[2]; |
| 2092 if (!global->IsTrue()) global = isolate->heap()->false_value(); | 2092 if (!global->IsTrue()) global = isolate->heap()->false_value(); |
| 2093 | 2093 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); | 2192 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); |
| 2193 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 2193 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
| 2194 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 2194 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
| 2195 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); | 2195 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); |
| 2196 | 2196 |
| 2197 return *holder; | 2197 return *holder; |
| 2198 } | 2198 } |
| 2199 | 2199 |
| 2200 | 2200 |
| 2201 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) { | 2201 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) { |
| 2202 NoHandleAllocation ha(isolate); | 2202 RequireNewHandleScope rnhs(isolate); |
| 2203 ASSERT(args.length() == 1); | 2203 ASSERT(args.length() == 1); |
| 2204 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2204 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
| 2205 if (!callable->IsJSFunction()) { | 2205 if (!callable->IsJSFunction()) { |
| 2206 HandleScope scope(isolate); | 2206 HandleScope scope(isolate); |
| 2207 bool threw = false; | 2207 bool threw = false; |
| 2208 Handle<Object> delegate = | 2208 Handle<Object> delegate = |
| 2209 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); | 2209 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); |
| 2210 if (threw) return Failure::Exception(); | 2210 if (threw) return Failure::Exception(); |
| 2211 callable = JSFunction::cast(*delegate); | 2211 callable = JSFunction::cast(*delegate); |
| 2212 } | 2212 } |
| 2213 JSFunction* function = JSFunction::cast(callable); | 2213 JSFunction* function = JSFunction::cast(callable); |
| 2214 SharedFunctionInfo* shared = function->shared(); | 2214 SharedFunctionInfo* shared = function->shared(); |
| 2215 return isolate->heap()->ToBoolean(shared->is_classic_mode()); | 2215 return isolate->heap()->ToBoolean(shared->is_classic_mode()); |
| 2216 } | 2216 } |
| 2217 | 2217 |
| 2218 | 2218 |
| 2219 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { | 2219 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { |
| 2220 NoHandleAllocation ha(isolate); | 2220 RequireNewHandleScope rnhs(isolate); |
| 2221 ASSERT(args.length() == 1); | 2221 ASSERT(args.length() == 1); |
| 2222 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2222 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
| 2223 | 2223 |
| 2224 if (!callable->IsJSFunction()) { | 2224 if (!callable->IsJSFunction()) { |
| 2225 HandleScope scope(isolate); | 2225 HandleScope scope(isolate); |
| 2226 bool threw = false; | 2226 bool threw = false; |
| 2227 Handle<Object> delegate = | 2227 Handle<Object> delegate = |
| 2228 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); | 2228 Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable), &threw); |
| 2229 if (threw) return Failure::Exception(); | 2229 if (threw) return Failure::Exception(); |
| 2230 callable = JSFunction::cast(*delegate); | 2230 callable = JSFunction::cast(*delegate); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2268 if (has_pending_exception) { | 2268 if (has_pending_exception) { |
| 2269 ASSERT(isolate->has_pending_exception()); | 2269 ASSERT(isolate->has_pending_exception()); |
| 2270 return Failure::Exception(); | 2270 return Failure::Exception(); |
| 2271 } | 2271 } |
| 2272 literals->set(index, *regexp); | 2272 literals->set(index, *regexp); |
| 2273 return *regexp; | 2273 return *regexp; |
| 2274 } | 2274 } |
| 2275 | 2275 |
| 2276 | 2276 |
| 2277 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { | 2277 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { |
| 2278 NoHandleAllocation ha(isolate); | 2278 RequireNewHandleScope rnhs(isolate); |
| 2279 ASSERT(args.length() == 1); | 2279 ASSERT(args.length() == 1); |
| 2280 | 2280 |
| 2281 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2281 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2282 return f->shared()->name(); | 2282 return f->shared()->name(); |
| 2283 } | 2283 } |
| 2284 | 2284 |
| 2285 | 2285 |
| 2286 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { | 2286 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { |
| 2287 NoHandleAllocation ha(isolate); | 2287 RequireNewHandleScope rnhs(isolate); |
| 2288 ASSERT(args.length() == 2); | 2288 ASSERT(args.length() == 2); |
| 2289 | 2289 |
| 2290 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2290 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2291 CONVERT_ARG_CHECKED(String, name, 1); | 2291 CONVERT_ARG_CHECKED(String, name, 1); |
| 2292 f->shared()->set_name(name); | 2292 f->shared()->set_name(name); |
| 2293 return isolate->heap()->undefined_value(); | 2293 return isolate->heap()->undefined_value(); |
| 2294 } | 2294 } |
| 2295 | 2295 |
| 2296 | 2296 |
| 2297 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { | 2297 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { |
| 2298 NoHandleAllocation ha(isolate); | 2298 RequireNewHandleScope rnhs(isolate); |
| 2299 ASSERT(args.length() == 1); | 2299 ASSERT(args.length() == 1); |
| 2300 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2300 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2301 return isolate->heap()->ToBoolean( | 2301 return isolate->heap()->ToBoolean( |
| 2302 f->shared()->name_should_print_as_anonymous()); | 2302 f->shared()->name_should_print_as_anonymous()); |
| 2303 } | 2303 } |
| 2304 | 2304 |
| 2305 | 2305 |
| 2306 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { | 2306 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
| 2307 NoHandleAllocation ha(isolate); | 2307 RequireNewHandleScope rnhs(isolate); |
| 2308 ASSERT(args.length() == 1); | 2308 ASSERT(args.length() == 1); |
| 2309 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2309 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2310 f->shared()->set_name_should_print_as_anonymous(true); | 2310 f->shared()->set_name_should_print_as_anonymous(true); |
| 2311 return isolate->heap()->undefined_value(); | 2311 return isolate->heap()->undefined_value(); |
| 2312 } | 2312 } |
| 2313 | 2313 |
| 2314 | 2314 |
| 2315 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsGenerator) { | 2315 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsGenerator) { |
| 2316 NoHandleAllocation ha(isolate); | 2316 RequireNewHandleScope rnhs(isolate); |
| 2317 ASSERT(args.length() == 1); | 2317 ASSERT(args.length() == 1); |
| 2318 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2318 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2319 return isolate->heap()->ToBoolean(f->shared()->is_generator()); | 2319 return isolate->heap()->ToBoolean(f->shared()->is_generator()); |
| 2320 } | 2320 } |
| 2321 | 2321 |
| 2322 | 2322 |
| 2323 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 2323 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
| 2324 NoHandleAllocation ha(isolate); | 2324 RequireNewHandleScope rnhs(isolate); |
| 2325 ASSERT(args.length() == 1); | 2325 ASSERT(args.length() == 1); |
| 2326 | 2326 |
| 2327 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2327 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2328 f->RemovePrototype(); | 2328 f->RemovePrototype(); |
| 2329 | 2329 |
| 2330 return isolate->heap()->undefined_value(); | 2330 return isolate->heap()->undefined_value(); |
| 2331 } | 2331 } |
| 2332 | 2332 |
| 2333 | 2333 |
| 2334 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { | 2334 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2347 HandleScope scope(isolate); | 2347 HandleScope scope(isolate); |
| 2348 ASSERT(args.length() == 1); | 2348 ASSERT(args.length() == 1); |
| 2349 | 2349 |
| 2350 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); | 2350 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
| 2351 Handle<SharedFunctionInfo> shared(f->shared()); | 2351 Handle<SharedFunctionInfo> shared(f->shared()); |
| 2352 return *shared->GetSourceCode(); | 2352 return *shared->GetSourceCode(); |
| 2353 } | 2353 } |
| 2354 | 2354 |
| 2355 | 2355 |
| 2356 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { | 2356 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { |
| 2357 NoHandleAllocation ha(isolate); | 2357 RequireNewHandleScope rnhs(isolate); |
| 2358 ASSERT(args.length() == 1); | 2358 ASSERT(args.length() == 1); |
| 2359 | 2359 |
| 2360 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2360 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2361 int pos = fun->shared()->start_position(); | 2361 int pos = fun->shared()->start_position(); |
| 2362 return Smi::FromInt(pos); | 2362 return Smi::FromInt(pos); |
| 2363 } | 2363 } |
| 2364 | 2364 |
| 2365 | 2365 |
| 2366 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { | 2366 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { |
| 2367 NoHandleAllocation ha(isolate); | 2367 RequireNewHandleScope rnhs(isolate); |
| 2368 ASSERT(args.length() == 2); | 2368 ASSERT(args.length() == 2); |
| 2369 | 2369 |
| 2370 CONVERT_ARG_CHECKED(Code, code, 0); | 2370 CONVERT_ARG_CHECKED(Code, code, 0); |
| 2371 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 2371 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
| 2372 | 2372 |
| 2373 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 2373 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
| 2374 | 2374 |
| 2375 Address pc = code->address() + offset; | 2375 Address pc = code->address() + offset; |
| 2376 return Smi::FromInt(code->SourcePosition(pc)); | 2376 return Smi::FromInt(code->SourcePosition(pc)); |
| 2377 } | 2377 } |
| 2378 | 2378 |
| 2379 | 2379 |
| 2380 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { | 2380 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { |
| 2381 NoHandleAllocation ha(isolate); | 2381 RequireNewHandleScope rnhs(isolate); |
| 2382 ASSERT(args.length() == 2); | 2382 ASSERT(args.length() == 2); |
| 2383 | 2383 |
| 2384 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2384 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2385 CONVERT_ARG_CHECKED(String, name, 1); | 2385 CONVERT_ARG_CHECKED(String, name, 1); |
| 2386 fun->SetInstanceClassName(name); | 2386 fun->SetInstanceClassName(name); |
| 2387 return isolate->heap()->undefined_value(); | 2387 return isolate->heap()->undefined_value(); |
| 2388 } | 2388 } |
| 2389 | 2389 |
| 2390 | 2390 |
| 2391 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { | 2391 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { |
| 2392 NoHandleAllocation ha(isolate); | 2392 RequireNewHandleScope rnhs(isolate); |
| 2393 ASSERT(args.length() == 2); | 2393 ASSERT(args.length() == 2); |
| 2394 | 2394 |
| 2395 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2395 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2396 CONVERT_SMI_ARG_CHECKED(length, 1); | 2396 CONVERT_SMI_ARG_CHECKED(length, 1); |
| 2397 fun->shared()->set_length(length); | 2397 fun->shared()->set_length(length); |
| 2398 return isolate->heap()->undefined_value(); | 2398 return isolate->heap()->undefined_value(); |
| 2399 } | 2399 } |
| 2400 | 2400 |
| 2401 | 2401 |
| 2402 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { | 2402 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { |
| 2403 NoHandleAllocation ha(isolate); | 2403 RequireNewHandleScope rnhs(isolate); |
| 2404 ASSERT(args.length() == 2); | 2404 ASSERT(args.length() == 2); |
| 2405 | 2405 |
| 2406 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2406 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
| 2407 ASSERT(fun->should_have_prototype()); | 2407 ASSERT(fun->should_have_prototype()); |
| 2408 Object* obj; | 2408 Object* obj; |
| 2409 { MaybeObject* maybe_obj = | 2409 { MaybeObject* maybe_obj = |
| 2410 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 2410 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
| 2411 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 2411 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2412 } | 2412 } |
| 2413 return args[0]; // return TOS | 2413 return args[0]; // return TOS |
| 2414 } | 2414 } |
| 2415 | 2415 |
| 2416 | 2416 |
| 2417 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 2417 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { |
| 2418 NoHandleAllocation ha(isolate); | 2418 RequireNewHandleScope rnhs(isolate); |
| 2419 RUNTIME_ASSERT(args.length() == 1); | 2419 RUNTIME_ASSERT(args.length() == 1); |
| 2420 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 2420 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 2421 | 2421 |
| 2422 String* name = isolate->heap()->prototype_string(); | 2422 String* name = isolate->heap()->prototype_string(); |
| 2423 | 2423 |
| 2424 if (function->HasFastProperties()) { | 2424 if (function->HasFastProperties()) { |
| 2425 // Construct a new field descriptor with updated attributes. | 2425 // Construct a new field descriptor with updated attributes. |
| 2426 DescriptorArray* instance_desc = function->map()->instance_descriptors(); | 2426 DescriptorArray* instance_desc = function->map()->instance_descriptors(); |
| 2427 | 2427 |
| 2428 int index = instance_desc->SearchWithCache(name, function->map()); | 2428 int index = instance_desc->SearchWithCache(name, function->map()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2450 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2450 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
| 2451 details.type(), | 2451 details.type(), |
| 2452 details.dictionary_index()); | 2452 details.dictionary_index()); |
| 2453 function->property_dictionary()->DetailsAtPut(entry, new_details); | 2453 function->property_dictionary()->DetailsAtPut(entry, new_details); |
| 2454 } | 2454 } |
| 2455 return function; | 2455 return function; |
| 2456 } | 2456 } |
| 2457 | 2457 |
| 2458 | 2458 |
| 2459 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2459 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
| 2460 NoHandleAllocation ha(isolate); | 2460 RequireNewHandleScope rnhs(isolate); |
| 2461 ASSERT(args.length() == 1); | 2461 ASSERT(args.length() == 1); |
| 2462 | 2462 |
| 2463 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2463 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2464 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 2464 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
| 2465 } | 2465 } |
| 2466 | 2466 |
| 2467 | 2467 |
| 2468 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 2468 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { |
| 2469 NoHandleAllocation ha(isolate); | 2469 RequireNewHandleScope rnhs(isolate); |
| 2470 ASSERT(args.length() == 1); | 2470 ASSERT(args.length() == 1); |
| 2471 | 2471 |
| 2472 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2472 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 2473 return isolate->heap()->ToBoolean(f->IsBuiltin()); | 2473 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
| 2474 } | 2474 } |
| 2475 | 2475 |
| 2476 | 2476 |
| 2477 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 2477 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
| 2478 HandleScope scope(isolate); | 2478 HandleScope scope(isolate); |
| 2479 ASSERT(args.length() == 2); | 2479 ASSERT(args.length() == 2); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2549 ASSERT(args.length() == 2); | 2549 ASSERT(args.length() == 2); |
| 2550 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 2550 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 2551 CONVERT_SMI_ARG_CHECKED(num, 1); | 2551 CONVERT_SMI_ARG_CHECKED(num, 1); |
| 2552 RUNTIME_ASSERT(num >= 0); | 2552 RUNTIME_ASSERT(num >= 0); |
| 2553 SetExpectedNofProperties(function, num); | 2553 SetExpectedNofProperties(function, num); |
| 2554 return isolate->heap()->undefined_value(); | 2554 return isolate->heap()->undefined_value(); |
| 2555 } | 2555 } |
| 2556 | 2556 |
| 2557 | 2557 |
| 2558 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) { | 2558 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) { |
| 2559 NoHandleAllocation ha(isolate); | 2559 RequireNewHandleScope rnhs(isolate); |
| 2560 ASSERT(args.length() == 0); | 2560 ASSERT(args.length() == 0); |
| 2561 | 2561 |
| 2562 JavaScriptFrameIterator it(isolate); | 2562 JavaScriptFrameIterator it(isolate); |
| 2563 JavaScriptFrame* frame = it.frame(); | 2563 JavaScriptFrame* frame = it.frame(); |
| 2564 JSFunction* function = JSFunction::cast(frame->function()); | 2564 JSFunction* function = JSFunction::cast(frame->function()); |
| 2565 RUNTIME_ASSERT(function->shared()->is_generator()); | 2565 RUNTIME_ASSERT(function->shared()->is_generator()); |
| 2566 | 2566 |
| 2567 JSGeneratorObject* generator; | 2567 JSGeneratorObject* generator; |
| 2568 if (frame->IsConstructor()) { | 2568 if (frame->IsConstructor()) { |
| 2569 generator = JSGeneratorObject::cast(frame->receiver()); | 2569 generator = JSGeneratorObject::cast(frame->receiver()); |
| 2570 } else { | 2570 } else { |
| 2571 MaybeObject* maybe_generator = | 2571 MaybeObject* maybe_generator = |
| 2572 isolate->heap()->AllocateJSGeneratorObject(function); | 2572 isolate->heap()->AllocateJSGeneratorObject(function); |
| 2573 if (!maybe_generator->To(&generator)) return maybe_generator; | 2573 if (!maybe_generator->To(&generator)) return maybe_generator; |
| 2574 } | 2574 } |
| 2575 generator->set_function(function); | 2575 generator->set_function(function); |
| 2576 generator->set_context(Context::cast(frame->context())); | 2576 generator->set_context(Context::cast(frame->context())); |
| 2577 generator->set_receiver(frame->receiver()); | 2577 generator->set_receiver(frame->receiver()); |
| 2578 generator->set_continuation(0); | 2578 generator->set_continuation(0); |
| 2579 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); | 2579 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); |
| 2580 generator->set_stack_handler_index(-1); | 2580 generator->set_stack_handler_index(-1); |
| 2581 | 2581 |
| 2582 return generator; | 2582 return generator; |
| 2583 } | 2583 } |
| 2584 | 2584 |
| 2585 | 2585 |
| 2586 RUNTIME_FUNCTION(MaybeObject*, Runtime_SuspendJSGeneratorObject) { | 2586 RUNTIME_FUNCTION(MaybeObject*, Runtime_SuspendJSGeneratorObject) { |
| 2587 NoHandleAllocation ha(isolate); | 2587 RequireNewHandleScope rnhs(isolate); |
| 2588 ASSERT(args.length() == 1); | 2588 ASSERT(args.length() == 1); |
| 2589 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); | 2589 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); |
| 2590 | 2590 |
| 2591 JavaScriptFrameIterator stack_iterator(isolate); | 2591 JavaScriptFrameIterator stack_iterator(isolate); |
| 2592 JavaScriptFrame* frame = stack_iterator.frame(); | 2592 JavaScriptFrame* frame = stack_iterator.frame(); |
| 2593 JSFunction* function = JSFunction::cast(frame->function()); | 2593 JSFunction* function = JSFunction::cast(frame->function()); |
| 2594 RUNTIME_ASSERT(function->shared()->is_generator()); | 2594 RUNTIME_ASSERT(function->shared()->is_generator()); |
| 2595 ASSERT_EQ(function, generator_object->function()); | 2595 ASSERT_EQ(function, generator_object->function()); |
| 2596 | 2596 |
| 2597 // We expect there to be at least two values on the operand stack: the return | 2597 // We expect there to be at least two values on the operand stack: the return |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2636 | 2636 |
| 2637 | 2637 |
| 2638 // Note that this function is the slow path for resuming generators. It is only | 2638 // Note that this function is the slow path for resuming generators. It is only |
| 2639 // called if the suspended activation had operands on the stack, stack handlers | 2639 // called if the suspended activation had operands on the stack, stack handlers |
| 2640 // needing rewinding, or if the resume should throw an exception. The fast path | 2640 // needing rewinding, or if the resume should throw an exception. The fast path |
| 2641 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is | 2641 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is |
| 2642 // inlined into GeneratorNext, GeneratorSend, and GeneratorThrow. | 2642 // inlined into GeneratorNext, GeneratorSend, and GeneratorThrow. |
| 2643 // EmitGeneratorResumeResume is called in any case, as it needs to reconstruct | 2643 // EmitGeneratorResumeResume is called in any case, as it needs to reconstruct |
| 2644 // the stack frame and make space for arguments and operands. | 2644 // the stack frame and make space for arguments and operands. |
| 2645 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResumeJSGeneratorObject) { | 2645 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResumeJSGeneratorObject) { |
| 2646 NoHandleAllocation ha(isolate); | 2646 RequireNewHandleScope rnhs(isolate); |
| 2647 ASSERT(args.length() == 3); | 2647 ASSERT(args.length() == 3); |
| 2648 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); | 2648 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); |
| 2649 CONVERT_ARG_CHECKED(Object, value, 1); | 2649 CONVERT_ARG_CHECKED(Object, value, 1); |
| 2650 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); | 2650 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); |
| 2651 JavaScriptFrameIterator stack_iterator(isolate); | 2651 JavaScriptFrameIterator stack_iterator(isolate); |
| 2652 JavaScriptFrame* frame = stack_iterator.frame(); | 2652 JavaScriptFrame* frame = stack_iterator.frame(); |
| 2653 | 2653 |
| 2654 ASSERT_EQ(frame->function(), generator_object->function()); | 2654 ASSERT_EQ(frame->function(), generator_object->function()); |
| 2655 | 2655 |
| 2656 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0); | 2656 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2692 int continuation = generator->continuation(); | 2692 int continuation = generator->continuation(); |
| 2693 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? | 2693 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? |
| 2694 "generator_finished" : "generator_running"; | 2694 "generator_finished" : "generator_running"; |
| 2695 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); | 2695 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); |
| 2696 Handle<Object> error = isolate->factory()->NewError(message, argv); | 2696 Handle<Object> error = isolate->factory()->NewError(message, argv); |
| 2697 return isolate->Throw(*error); | 2697 return isolate->Throw(*error); |
| 2698 } | 2698 } |
| 2699 | 2699 |
| 2700 | 2700 |
| 2701 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectFreeze) { | 2701 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectFreeze) { |
| 2702 NoHandleAllocation ha(isolate); | 2702 RequireNewHandleScope rnhs(isolate); |
| 2703 ASSERT(args.length() == 1); | 2703 ASSERT(args.length() == 1); |
| 2704 CONVERT_ARG_CHECKED(JSObject, object, 0); | 2704 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 2705 return object->Freeze(isolate); | 2705 return object->Freeze(isolate); |
| 2706 } | 2706 } |
| 2707 | 2707 |
| 2708 | 2708 |
| 2709 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, | 2709 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, |
| 2710 Object* char_code) { | 2710 Object* char_code) { |
| 2711 if (char_code->IsNumber()) { | 2711 if (char_code->IsNumber()) { |
| 2712 return isolate->heap()->LookupSingleCharacterStringFromCode( | 2712 return isolate->heap()->LookupSingleCharacterStringFromCode( |
| 2713 NumberToUint32(char_code) & 0xffff); | 2713 NumberToUint32(char_code) & 0xffff); |
| 2714 } | 2714 } |
| 2715 return isolate->heap()->empty_string(); | 2715 return isolate->heap()->empty_string(); |
| 2716 } | 2716 } |
| 2717 | 2717 |
| 2718 | 2718 |
| 2719 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { | 2719 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { |
| 2720 NoHandleAllocation ha(isolate); | 2720 RequireNewHandleScope rnhs(isolate); |
| 2721 ASSERT(args.length() == 2); | 2721 ASSERT(args.length() == 2); |
| 2722 | 2722 |
| 2723 CONVERT_ARG_CHECKED(String, subject, 0); | 2723 CONVERT_ARG_CHECKED(String, subject, 0); |
| 2724 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 2724 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
| 2725 | 2725 |
| 2726 // Flatten the string. If someone wants to get a char at an index | 2726 // Flatten the string. If someone wants to get a char at an index |
| 2727 // in a cons string, it is likely that more indices will be | 2727 // in a cons string, it is likely that more indices will be |
| 2728 // accessed. | 2728 // accessed. |
| 2729 Object* flat; | 2729 Object* flat; |
| 2730 { MaybeObject* maybe_flat = subject->TryFlatten(); | 2730 { MaybeObject* maybe_flat = subject->TryFlatten(); |
| 2731 if (!maybe_flat->ToObject(&flat)) return maybe_flat; | 2731 if (!maybe_flat->ToObject(&flat)) return maybe_flat; |
| 2732 } | 2732 } |
| 2733 subject = String::cast(flat); | 2733 subject = String::cast(flat); |
| 2734 | 2734 |
| 2735 if (i >= static_cast<uint32_t>(subject->length())) { | 2735 if (i >= static_cast<uint32_t>(subject->length())) { |
| 2736 return isolate->heap()->nan_value(); | 2736 return isolate->heap()->nan_value(); |
| 2737 } | 2737 } |
| 2738 | 2738 |
| 2739 return Smi::FromInt(subject->Get(i)); | 2739 return Smi::FromInt(subject->Get(i)); |
| 2740 } | 2740 } |
| 2741 | 2741 |
| 2742 | 2742 |
| 2743 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { | 2743 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { |
| 2744 NoHandleAllocation ha(isolate); | 2744 RequireNewHandleScope rnhs(isolate); |
| 2745 ASSERT(args.length() == 1); | 2745 ASSERT(args.length() == 1); |
| 2746 return CharFromCode(isolate, args[0]); | 2746 return CharFromCode(isolate, args[0]); |
| 2747 } | 2747 } |
| 2748 | 2748 |
| 2749 | 2749 |
| 2750 class FixedArrayBuilder { | 2750 class FixedArrayBuilder { |
| 2751 public: | 2751 public: |
| 2752 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) | 2752 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) |
| 2753 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), | 2753 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), |
| 2754 length_(0), | 2754 length_(0), |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2904 | 2904 |
| 2905 | 2905 |
| 2906 Handle<String> ToString() { | 2906 Handle<String> ToString() { |
| 2907 if (array_builder_.length() == 0) { | 2907 if (array_builder_.length() == 0) { |
| 2908 return heap_->isolate()->factory()->empty_string(); | 2908 return heap_->isolate()->factory()->empty_string(); |
| 2909 } | 2909 } |
| 2910 | 2910 |
| 2911 Handle<String> joined_string; | 2911 Handle<String> joined_string; |
| 2912 if (is_ascii_) { | 2912 if (is_ascii_) { |
| 2913 Handle<SeqOneByteString> seq = NewRawOneByteString(character_count_); | 2913 Handle<SeqOneByteString> seq = NewRawOneByteString(character_count_); |
| 2914 AssertNoAllocation no_alloc; | 2914 DisallowHeapAllocation no_gc; |
| 2915 uint8_t* char_buffer = seq->GetChars(); | 2915 uint8_t* char_buffer = seq->GetChars(); |
| 2916 StringBuilderConcatHelper(*subject_, | 2916 StringBuilderConcatHelper(*subject_, |
| 2917 char_buffer, | 2917 char_buffer, |
| 2918 *array_builder_.array(), | 2918 *array_builder_.array(), |
| 2919 array_builder_.length()); | 2919 array_builder_.length()); |
| 2920 joined_string = Handle<String>::cast(seq); | 2920 joined_string = Handle<String>::cast(seq); |
| 2921 } else { | 2921 } else { |
| 2922 // Non-ASCII. | 2922 // Non-ASCII. |
| 2923 Handle<SeqTwoByteString> seq = NewRawTwoByteString(character_count_); | 2923 Handle<SeqTwoByteString> seq = NewRawTwoByteString(character_count_); |
| 2924 AssertNoAllocation no_alloc; | 2924 DisallowHeapAllocation no_gc; |
| 2925 uc16* char_buffer = seq->GetChars(); | 2925 uc16* char_buffer = seq->GetChars(); |
| 2926 StringBuilderConcatHelper(*subject_, | 2926 StringBuilderConcatHelper(*subject_, |
| 2927 char_buffer, | 2927 char_buffer, |
| 2928 *array_builder_.array(), | 2928 *array_builder_.array(), |
| 2929 array_builder_.length()); | 2929 array_builder_.length()); |
| 2930 joined_string = Handle<String>::cast(seq); | 2930 joined_string = Handle<String>::cast(seq); |
| 2931 } | 2931 } |
| 2932 return joined_string; | 2932 return joined_string; |
| 2933 } | 2933 } |
| 2934 | 2934 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3156 ZoneList<ReplacementPart> parts_; | 3156 ZoneList<ReplacementPart> parts_; |
| 3157 ZoneList<Handle<String> > replacement_substrings_; | 3157 ZoneList<Handle<String> > replacement_substrings_; |
| 3158 Zone* zone_; | 3158 Zone* zone_; |
| 3159 }; | 3159 }; |
| 3160 | 3160 |
| 3161 | 3161 |
| 3162 bool CompiledReplacement::Compile(Handle<String> replacement, | 3162 bool CompiledReplacement::Compile(Handle<String> replacement, |
| 3163 int capture_count, | 3163 int capture_count, |
| 3164 int subject_length) { | 3164 int subject_length) { |
| 3165 { | 3165 { |
| 3166 AssertNoAllocation no_alloc; | 3166 DisallowHeapAllocation no_gc; |
| 3167 String::FlatContent content = replacement->GetFlatContent(); | 3167 String::FlatContent content = replacement->GetFlatContent(); |
| 3168 ASSERT(content.IsFlat()); | 3168 ASSERT(content.IsFlat()); |
| 3169 bool simple = false; | 3169 bool simple = false; |
| 3170 if (content.IsAscii()) { | 3170 if (content.IsAscii()) { |
| 3171 simple = ParseReplacementPattern(&parts_, | 3171 simple = ParseReplacementPattern(&parts_, |
| 3172 content.ToOneByteVector(), | 3172 content.ToOneByteVector(), |
| 3173 capture_count, | 3173 capture_count, |
| 3174 subject_length, | 3174 subject_length, |
| 3175 zone()); | 3175 zone()); |
| 3176 } else { | 3176 } else { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3307 } | 3307 } |
| 3308 | 3308 |
| 3309 | 3309 |
| 3310 void FindStringIndicesDispatch(Isolate* isolate, | 3310 void FindStringIndicesDispatch(Isolate* isolate, |
| 3311 String* subject, | 3311 String* subject, |
| 3312 String* pattern, | 3312 String* pattern, |
| 3313 ZoneList<int>* indices, | 3313 ZoneList<int>* indices, |
| 3314 unsigned int limit, | 3314 unsigned int limit, |
| 3315 Zone* zone) { | 3315 Zone* zone) { |
| 3316 { | 3316 { |
| 3317 AssertNoAllocation no_gc; | 3317 DisallowHeapAllocation no_gc; |
| 3318 String::FlatContent subject_content = subject->GetFlatContent(); | 3318 String::FlatContent subject_content = subject->GetFlatContent(); |
| 3319 String::FlatContent pattern_content = pattern->GetFlatContent(); | 3319 String::FlatContent pattern_content = pattern->GetFlatContent(); |
| 3320 ASSERT(subject_content.IsFlat()); | 3320 ASSERT(subject_content.IsFlat()); |
| 3321 ASSERT(pattern_content.IsFlat()); | 3321 ASSERT(pattern_content.IsFlat()); |
| 3322 if (subject_content.IsAscii()) { | 3322 if (subject_content.IsAscii()) { |
| 3323 Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector(); | 3323 Vector<const uint8_t> subject_vector = subject_content.ToOneByteVector(); |
| 3324 if (pattern_content.IsAscii()) { | 3324 if (pattern_content.IsAscii()) { |
| 3325 Vector<const uint8_t> pattern_vector = | 3325 Vector<const uint8_t> pattern_vector = |
| 3326 pattern_content.ToOneByteVector(); | 3326 pattern_content.ToOneByteVector(); |
| 3327 if (pattern_vector.length() == 1) { | 3327 if (pattern_vector.length() == 1) { |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3776 | 3776 |
| 3777 int pattern_length = pat->length(); | 3777 int pattern_length = pat->length(); |
| 3778 if (pattern_length == 0) return start_index; | 3778 if (pattern_length == 0) return start_index; |
| 3779 | 3779 |
| 3780 int subject_length = sub->length(); | 3780 int subject_length = sub->length(); |
| 3781 if (start_index + pattern_length > subject_length) return -1; | 3781 if (start_index + pattern_length > subject_length) return -1; |
| 3782 | 3782 |
| 3783 if (!sub->IsFlat()) FlattenString(sub); | 3783 if (!sub->IsFlat()) FlattenString(sub); |
| 3784 if (!pat->IsFlat()) FlattenString(pat); | 3784 if (!pat->IsFlat()) FlattenString(pat); |
| 3785 | 3785 |
| 3786 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid | 3786 DisallowHeapAllocation no_gc; // ensure vectors stay valid |
| 3787 // Extract flattened substrings of cons strings before determining asciiness. | 3787 // Extract flattened substrings of cons strings before determining asciiness. |
| 3788 String::FlatContent seq_sub = sub->GetFlatContent(); | 3788 String::FlatContent seq_sub = sub->GetFlatContent(); |
| 3789 String::FlatContent seq_pat = pat->GetFlatContent(); | 3789 String::FlatContent seq_pat = pat->GetFlatContent(); |
| 3790 | 3790 |
| 3791 // dispatch on type of strings | 3791 // dispatch on type of strings |
| 3792 if (seq_pat.IsAscii()) { | 3792 if (seq_pat.IsAscii()) { |
| 3793 Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector(); | 3793 Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector(); |
| 3794 if (seq_sub.IsAscii()) { | 3794 if (seq_sub.IsAscii()) { |
| 3795 return SearchString(isolate, | 3795 return SearchString(isolate, |
| 3796 seq_sub.ToOneByteVector(), | 3796 seq_sub.ToOneByteVector(), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 } | 3887 } |
| 3888 | 3888 |
| 3889 if (pat_length == 0) { | 3889 if (pat_length == 0) { |
| 3890 return Smi::FromInt(start_index); | 3890 return Smi::FromInt(start_index); |
| 3891 } | 3891 } |
| 3892 | 3892 |
| 3893 if (!sub->IsFlat()) FlattenString(sub); | 3893 if (!sub->IsFlat()) FlattenString(sub); |
| 3894 if (!pat->IsFlat()) FlattenString(pat); | 3894 if (!pat->IsFlat()) FlattenString(pat); |
| 3895 | 3895 |
| 3896 int position = -1; | 3896 int position = -1; |
| 3897 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid | 3897 DisallowHeapAllocation no_gc; // ensure vectors stay valid |
| 3898 | 3898 |
| 3899 String::FlatContent sub_content = sub->GetFlatContent(); | 3899 String::FlatContent sub_content = sub->GetFlatContent(); |
| 3900 String::FlatContent pat_content = pat->GetFlatContent(); | 3900 String::FlatContent pat_content = pat->GetFlatContent(); |
| 3901 | 3901 |
| 3902 if (pat_content.IsAscii()) { | 3902 if (pat_content.IsAscii()) { |
| 3903 Vector<const uint8_t> pat_vector = pat_content.ToOneByteVector(); | 3903 Vector<const uint8_t> pat_vector = pat_content.ToOneByteVector(); |
| 3904 if (sub_content.IsAscii()) { | 3904 if (sub_content.IsAscii()) { |
| 3905 position = StringMatchBackwards(sub_content.ToOneByteVector(), | 3905 position = StringMatchBackwards(sub_content.ToOneByteVector(), |
| 3906 pat_vector, | 3906 pat_vector, |
| 3907 start_index); | 3907 start_index); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3921 pat_vector, | 3921 pat_vector, |
| 3922 start_index); | 3922 start_index); |
| 3923 } | 3923 } |
| 3924 } | 3924 } |
| 3925 | 3925 |
| 3926 return Smi::FromInt(position); | 3926 return Smi::FromInt(position); |
| 3927 } | 3927 } |
| 3928 | 3928 |
| 3929 | 3929 |
| 3930 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { | 3930 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { |
| 3931 NoHandleAllocation ha(isolate); | 3931 RequireNewHandleScope rnhs(isolate); |
| 3932 ASSERT(args.length() == 2); | 3932 ASSERT(args.length() == 2); |
| 3933 | 3933 |
| 3934 CONVERT_ARG_CHECKED(String, str1, 0); | 3934 CONVERT_ARG_CHECKED(String, str1, 0); |
| 3935 CONVERT_ARG_CHECKED(String, str2, 1); | 3935 CONVERT_ARG_CHECKED(String, str2, 1); |
| 3936 | 3936 |
| 3937 if (str1 == str2) return Smi::FromInt(0); // Equal. | 3937 if (str1 == str2) return Smi::FromInt(0); // Equal. |
| 3938 int str1_length = str1->length(); | 3938 int str1_length = str1->length(); |
| 3939 int str2_length = str2->length(); | 3939 int str2_length = str2->length(); |
| 3940 | 3940 |
| 3941 // Decide trivial cases without flattening. | 3941 // Decide trivial cases without flattening. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3969 uint16_t char1 = stream1.GetNext(); | 3969 uint16_t char1 = stream1.GetNext(); |
| 3970 uint16_t char2 = stream2.GetNext(); | 3970 uint16_t char2 = stream2.GetNext(); |
| 3971 if (char1 != char2) return Smi::FromInt(char1 - char2); | 3971 if (char1 != char2) return Smi::FromInt(char1 - char2); |
| 3972 } | 3972 } |
| 3973 | 3973 |
| 3974 return Smi::FromInt(str1_length - str2_length); | 3974 return Smi::FromInt(str1_length - str2_length); |
| 3975 } | 3975 } |
| 3976 | 3976 |
| 3977 | 3977 |
| 3978 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { | 3978 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { |
| 3979 NoHandleAllocation ha(isolate); | 3979 RequireNewHandleScope rnhs(isolate); |
| 3980 ASSERT(args.length() == 3); | 3980 ASSERT(args.length() == 3); |
| 3981 | 3981 |
| 3982 CONVERT_ARG_CHECKED(String, value, 0); | 3982 CONVERT_ARG_CHECKED(String, value, 0); |
| 3983 int start, end; | 3983 int start, end; |
| 3984 // We have a fast integer-only case here to avoid a conversion to double in | 3984 // We have a fast integer-only case here to avoid a conversion to double in |
| 3985 // the common case where from and to are Smis. | 3985 // the common case where from and to are Smis. |
| 3986 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 3986 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
| 3987 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 3987 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
| 3988 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 3988 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
| 3989 start = from_number; | 3989 start = from_number; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4231 return SearchRegExpMultiple<false>( | 4231 return SearchRegExpMultiple<false>( |
| 4232 isolate, subject, regexp, last_match_info, result_array); | 4232 isolate, subject, regexp, last_match_info, result_array); |
| 4233 } else { | 4233 } else { |
| 4234 return SearchRegExpMultiple<true>( | 4234 return SearchRegExpMultiple<true>( |
| 4235 isolate, subject, regexp, last_match_info, result_array); | 4235 isolate, subject, regexp, last_match_info, result_array); |
| 4236 } | 4236 } |
| 4237 } | 4237 } |
| 4238 | 4238 |
| 4239 | 4239 |
| 4240 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { | 4240 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { |
| 4241 NoHandleAllocation ha(isolate); | 4241 RequireNewHandleScope rnhs(isolate); |
| 4242 ASSERT(args.length() == 2); | 4242 ASSERT(args.length() == 2); |
| 4243 CONVERT_SMI_ARG_CHECKED(radix, 1); | 4243 CONVERT_SMI_ARG_CHECKED(radix, 1); |
| 4244 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 4244 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
| 4245 | 4245 |
| 4246 // Fast case where the result is a one character string. | 4246 // Fast case where the result is a one character string. |
| 4247 if (args[0]->IsSmi()) { | 4247 if (args[0]->IsSmi()) { |
| 4248 int value = args.smi_at(0); | 4248 int value = args.smi_at(0); |
| 4249 if (value >= 0 && value < radix) { | 4249 if (value >= 0 && value < radix) { |
| 4250 // Character array used for conversion. | 4250 // Character array used for conversion. |
| 4251 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; | 4251 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4267 } | 4267 } |
| 4268 char* str = DoubleToRadixCString(value, radix); | 4268 char* str = DoubleToRadixCString(value, radix); |
| 4269 MaybeObject* result = | 4269 MaybeObject* result = |
| 4270 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 4270 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 4271 DeleteArray(str); | 4271 DeleteArray(str); |
| 4272 return result; | 4272 return result; |
| 4273 } | 4273 } |
| 4274 | 4274 |
| 4275 | 4275 |
| 4276 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { | 4276 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { |
| 4277 NoHandleAllocation ha(isolate); | 4277 RequireNewHandleScope rnhs(isolate); |
| 4278 ASSERT(args.length() == 2); | 4278 ASSERT(args.length() == 2); |
| 4279 | 4279 |
| 4280 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4280 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4281 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4281 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4282 int f = FastD2IChecked(f_number); | 4282 int f = FastD2IChecked(f_number); |
| 4283 RUNTIME_ASSERT(f >= 0); | 4283 RUNTIME_ASSERT(f >= 0); |
| 4284 char* str = DoubleToFixedCString(value, f); | 4284 char* str = DoubleToFixedCString(value, f); |
| 4285 MaybeObject* res = | 4285 MaybeObject* res = |
| 4286 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 4286 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 4287 DeleteArray(str); | 4287 DeleteArray(str); |
| 4288 return res; | 4288 return res; |
| 4289 } | 4289 } |
| 4290 | 4290 |
| 4291 | 4291 |
| 4292 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 4292 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { |
| 4293 NoHandleAllocation ha(isolate); | 4293 RequireNewHandleScope rnhs(isolate); |
| 4294 ASSERT(args.length() == 2); | 4294 ASSERT(args.length() == 2); |
| 4295 | 4295 |
| 4296 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4296 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4297 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4297 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4298 int f = FastD2IChecked(f_number); | 4298 int f = FastD2IChecked(f_number); |
| 4299 RUNTIME_ASSERT(f >= -1 && f <= 20); | 4299 RUNTIME_ASSERT(f >= -1 && f <= 20); |
| 4300 char* str = DoubleToExponentialCString(value, f); | 4300 char* str = DoubleToExponentialCString(value, f); |
| 4301 MaybeObject* res = | 4301 MaybeObject* res = |
| 4302 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 4302 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 4303 DeleteArray(str); | 4303 DeleteArray(str); |
| 4304 return res; | 4304 return res; |
| 4305 } | 4305 } |
| 4306 | 4306 |
| 4307 | 4307 |
| 4308 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 4308 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { |
| 4309 NoHandleAllocation ha(isolate); | 4309 RequireNewHandleScope rnhs(isolate); |
| 4310 ASSERT(args.length() == 2); | 4310 ASSERT(args.length() == 2); |
| 4311 | 4311 |
| 4312 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4312 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
| 4313 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4313 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
| 4314 int f = FastD2IChecked(f_number); | 4314 int f = FastD2IChecked(f_number); |
| 4315 RUNTIME_ASSERT(f >= 1 && f <= 21); | 4315 RUNTIME_ASSERT(f >= 1 && f <= 21); |
| 4316 char* str = DoubleToPrecisionCString(value, f); | 4316 char* str = DoubleToPrecisionCString(value, f); |
| 4317 MaybeObject* res = | 4317 MaybeObject* res = |
| 4318 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); | 4318 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); |
| 4319 DeleteArray(str); | 4319 DeleteArray(str); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4436 // the element if so. | 4436 // the element if so. |
| 4437 if (name->AsArrayIndex(&index)) { | 4437 if (name->AsArrayIndex(&index)) { |
| 4438 return GetElementOrCharAt(isolate, object, index); | 4438 return GetElementOrCharAt(isolate, object, index); |
| 4439 } else { | 4439 } else { |
| 4440 return object->GetProperty(*name); | 4440 return object->GetProperty(*name); |
| 4441 } | 4441 } |
| 4442 } | 4442 } |
| 4443 | 4443 |
| 4444 | 4444 |
| 4445 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 4445 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { |
| 4446 NoHandleAllocation ha(isolate); | 4446 RequireNewHandleScope rnhs(isolate); |
| 4447 ASSERT(args.length() == 2); | 4447 ASSERT(args.length() == 2); |
| 4448 | 4448 |
| 4449 Handle<Object> object = args.at<Object>(0); | 4449 Handle<Object> object = args.at<Object>(0); |
| 4450 Handle<Object> key = args.at<Object>(1); | 4450 Handle<Object> key = args.at<Object>(1); |
| 4451 | 4451 |
| 4452 return Runtime::GetObjectProperty(isolate, object, key); | 4452 return Runtime::GetObjectProperty(isolate, object, key); |
| 4453 } | 4453 } |
| 4454 | 4454 |
| 4455 | 4455 |
| 4456 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 4456 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
| 4457 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 4457 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { |
| 4458 NoHandleAllocation ha(isolate); | 4458 RequireNewHandleScope rnhs(isolate); |
| 4459 ASSERT(args.length() == 2); | 4459 ASSERT(args.length() == 2); |
| 4460 | 4460 |
| 4461 // Fast cases for getting named properties of the receiver JSObject | 4461 // Fast cases for getting named properties of the receiver JSObject |
| 4462 // itself. | 4462 // itself. |
| 4463 // | 4463 // |
| 4464 // The global proxy objects has to be excluded since LocalLookup on | 4464 // The global proxy objects has to be excluded since LocalLookup on |
| 4465 // the global proxy object can return a valid result even though the | 4465 // the global proxy object can return a valid result even though the |
| 4466 // global proxy object never has properties. This is the case | 4466 // global proxy object never has properties. This is the case |
| 4467 // because the global proxy object forwards everything to its hidden | 4467 // because the global proxy object forwards everything to its hidden |
| 4468 // prototype including local lookups. | 4468 // prototype including local lookups. |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4656 return Runtime::ForceSetObjectProperty(isolate, | 4656 return Runtime::ForceSetObjectProperty(isolate, |
| 4657 js_object, | 4657 js_object, |
| 4658 name, | 4658 name, |
| 4659 obj_value, | 4659 obj_value, |
| 4660 attr); | 4660 attr); |
| 4661 } | 4661 } |
| 4662 | 4662 |
| 4663 | 4663 |
| 4664 // Return property without being observable by accessors or interceptors. | 4664 // Return property without being observable by accessors or interceptors. |
| 4665 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) { | 4665 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) { |
| 4666 NoHandleAllocation ha(isolate); | 4666 RequireNewHandleScope rnhs(isolate); |
| 4667 ASSERT(args.length() == 2); | 4667 ASSERT(args.length() == 2); |
| 4668 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 4668 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 4669 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 4669 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 4670 LookupResult lookup(isolate); | 4670 LookupResult lookup(isolate); |
| 4671 object->LookupRealNamedProperty(*key, &lookup); | 4671 object->LookupRealNamedProperty(*key, &lookup); |
| 4672 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); | 4672 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); |
| 4673 switch (lookup.type()) { | 4673 switch (lookup.type()) { |
| 4674 case NORMAL: | 4674 case NORMAL: |
| 4675 return lookup.holder()->GetNormalizedProperty(&lookup); | 4675 return lookup.holder()->GetNormalizedProperty(&lookup); |
| 4676 case FIELD: | 4676 case FIELD: |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4869 if (has_pending_exception) return Failure::Exception(); | 4869 if (has_pending_exception) return Failure::Exception(); |
| 4870 name = Handle<String>::cast(converted); | 4870 name = Handle<String>::cast(converted); |
| 4871 } | 4871 } |
| 4872 | 4872 |
| 4873 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); | 4873 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); |
| 4874 return receiver->DeleteProperty(*name, mode); | 4874 return receiver->DeleteProperty(*name, mode); |
| 4875 } | 4875 } |
| 4876 | 4876 |
| 4877 | 4877 |
| 4878 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 4878 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
| 4879 NoHandleAllocation ha(isolate); | 4879 RequireNewHandleScope rnhs(isolate); |
| 4880 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 4880 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
| 4881 | 4881 |
| 4882 Handle<Object> object = args.at<Object>(0); | 4882 Handle<Object> object = args.at<Object>(0); |
| 4883 Handle<Object> key = args.at<Object>(1); | 4883 Handle<Object> key = args.at<Object>(1); |
| 4884 Handle<Object> value = args.at<Object>(2); | 4884 Handle<Object> value = args.at<Object>(2); |
| 4885 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 4885 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
| 4886 RUNTIME_ASSERT( | 4886 RUNTIME_ASSERT( |
| 4887 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4887 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 4888 // Compute attributes. | 4888 // Compute attributes. |
| 4889 PropertyAttributes attributes = | 4889 PropertyAttributes attributes = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4908 HandleScope scope(isolate); | 4908 HandleScope scope(isolate); |
| 4909 RUNTIME_ASSERT(args.length() == 2); | 4909 RUNTIME_ASSERT(args.length() == 2); |
| 4910 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 4910 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 4911 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); | 4911 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); |
| 4912 JSObject::TransitionElementsKind(array, map->elements_kind()); | 4912 JSObject::TransitionElementsKind(array, map->elements_kind()); |
| 4913 return *array; | 4913 return *array; |
| 4914 } | 4914 } |
| 4915 | 4915 |
| 4916 | 4916 |
| 4917 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsSmiToDouble) { | 4917 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsSmiToDouble) { |
| 4918 NoHandleAllocation ha(isolate); | 4918 RequireNewHandleScope rnhs(isolate); |
| 4919 RUNTIME_ASSERT(args.length() == 1); | 4919 RUNTIME_ASSERT(args.length() == 1); |
| 4920 Handle<Object> object = args.at<Object>(0); | 4920 Handle<Object> object = args.at<Object>(0); |
| 4921 if (object->IsJSObject()) { | 4921 if (object->IsJSObject()) { |
| 4922 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | 4922 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); |
| 4923 ASSERT(!js_object->map()->is_observed()); | 4923 ASSERT(!js_object->map()->is_observed()); |
| 4924 ElementsKind new_kind = js_object->HasFastHoleyElements() | 4924 ElementsKind new_kind = js_object->HasFastHoleyElements() |
| 4925 ? FAST_HOLEY_DOUBLE_ELEMENTS | 4925 ? FAST_HOLEY_DOUBLE_ELEMENTS |
| 4926 : FAST_DOUBLE_ELEMENTS; | 4926 : FAST_DOUBLE_ELEMENTS; |
| 4927 return TransitionElements(object, new_kind, isolate); | 4927 return TransitionElements(object, new_kind, isolate); |
| 4928 } else { | 4928 } else { |
| 4929 return *object; | 4929 return *object; |
| 4930 } | 4930 } |
| 4931 } | 4931 } |
| 4932 | 4932 |
| 4933 | 4933 |
| 4934 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsDoubleToObject) { | 4934 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsDoubleToObject) { |
| 4935 NoHandleAllocation ha(isolate); | 4935 RequireNewHandleScope rnhs(isolate); |
| 4936 RUNTIME_ASSERT(args.length() == 1); | 4936 RUNTIME_ASSERT(args.length() == 1); |
| 4937 Handle<Object> object = args.at<Object>(0); | 4937 Handle<Object> object = args.at<Object>(0); |
| 4938 if (object->IsJSObject()) { | 4938 if (object->IsJSObject()) { |
| 4939 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | 4939 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); |
| 4940 ASSERT(!js_object->map()->is_observed()); | 4940 ASSERT(!js_object->map()->is_observed()); |
| 4941 ElementsKind new_kind = js_object->HasFastHoleyElements() | 4941 ElementsKind new_kind = js_object->HasFastHoleyElements() |
| 4942 ? FAST_HOLEY_ELEMENTS | 4942 ? FAST_HOLEY_ELEMENTS |
| 4943 : FAST_ELEMENTS; | 4943 : FAST_ELEMENTS; |
| 4944 return TransitionElements(object, new_kind, isolate); | 4944 return TransitionElements(object, new_kind, isolate); |
| 4945 } else { | 4945 } else { |
| 4946 return *object; | 4946 return *object; |
| 4947 } | 4947 } |
| 4948 } | 4948 } |
| 4949 | 4949 |
| 4950 | 4950 |
| 4951 // Set the native flag on the function. | 4951 // Set the native flag on the function. |
| 4952 // This is used to decide if we should transform null and undefined | 4952 // This is used to decide if we should transform null and undefined |
| 4953 // into the global object when doing call and apply. | 4953 // into the global object when doing call and apply. |
| 4954 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { | 4954 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { |
| 4955 NoHandleAllocation ha(isolate); | 4955 RequireNewHandleScope rnhs(isolate); |
| 4956 RUNTIME_ASSERT(args.length() == 1); | 4956 RUNTIME_ASSERT(args.length() == 1); |
| 4957 | 4957 |
| 4958 Handle<Object> object = args.at<Object>(0); | 4958 Handle<Object> object = args.at<Object>(0); |
| 4959 | 4959 |
| 4960 if (object->IsJSFunction()) { | 4960 if (object->IsJSFunction()) { |
| 4961 JSFunction* func = JSFunction::cast(*object); | 4961 JSFunction* func = JSFunction::cast(*object); |
| 4962 func->shared()->set_native(true); | 4962 func->shared()->set_native(true); |
| 4963 } | 4963 } |
| 4964 return isolate->heap()->undefined_value(); | 4964 return isolate->heap()->undefined_value(); |
| 4965 } | 4965 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5011 FixedArray* object_array = FixedArray::cast(object->elements()); | 5011 FixedArray* object_array = FixedArray::cast(object->elements()); |
| 5012 object_array->set(store_index, *value); | 5012 object_array->set(store_index, *value); |
| 5013 } | 5013 } |
| 5014 return *object; | 5014 return *object; |
| 5015 } | 5015 } |
| 5016 | 5016 |
| 5017 | 5017 |
| 5018 // Check whether debugger and is about to step into the callback that is passed | 5018 // Check whether debugger and is about to step into the callback that is passed |
| 5019 // to a built-in function such as Array.forEach. | 5019 // to a built-in function such as Array.forEach. |
| 5020 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) { | 5020 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) { |
| 5021 NoHandleAllocation ha(isolate); | 5021 RequireNewHandleScope rnhs(isolate); |
| 5022 #ifdef ENABLE_DEBUGGER_SUPPORT | 5022 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 5023 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { | 5023 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { |
| 5024 return isolate->heap()->false_value(); | 5024 return isolate->heap()->false_value(); |
| 5025 } | 5025 } |
| 5026 CONVERT_ARG_CHECKED(Object, callback, 0); | 5026 CONVERT_ARG_CHECKED(Object, callback, 0); |
| 5027 // We do not step into the callback if it's a builtin or not even a function. | 5027 // We do not step into the callback if it's a builtin or not even a function. |
| 5028 if (!callback->IsJSFunction() || JSFunction::cast(callback)->IsBuiltin()) { | 5028 if (!callback->IsJSFunction() || JSFunction::cast(callback)->IsBuiltin()) { |
| 5029 return isolate->heap()->false_value(); | 5029 return isolate->heap()->false_value(); |
| 5030 } | 5030 } |
| 5031 return isolate->heap()->true_value(); | 5031 return isolate->heap()->true_value(); |
| 5032 #else | 5032 #else |
| 5033 return isolate->heap()->false_value(); | 5033 return isolate->heap()->false_value(); |
| 5034 #endif // ENABLE_DEBUGGER_SUPPORT | 5034 #endif // ENABLE_DEBUGGER_SUPPORT |
| 5035 } | 5035 } |
| 5036 | 5036 |
| 5037 | 5037 |
| 5038 // Set one shot breakpoints for the callback function that is passed to a | 5038 // Set one shot breakpoints for the callback function that is passed to a |
| 5039 // built-in function such as Array.forEach to enable stepping into the callback. | 5039 // built-in function such as Array.forEach to enable stepping into the callback. |
| 5040 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) { | 5040 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) { |
| 5041 NoHandleAllocation ha(isolate); | 5041 RequireNewHandleScope rnhs(isolate); |
| 5042 #ifdef ENABLE_DEBUGGER_SUPPORT | 5042 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 5043 Debug* debug = isolate->debug(); | 5043 Debug* debug = isolate->debug(); |
| 5044 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); | 5044 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); |
| 5045 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); | 5045 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); |
| 5046 HandleScope scope(isolate); | 5046 HandleScope scope(isolate); |
| 5047 // When leaving the callback, step out has been activated, but not performed | 5047 // When leaving the callback, step out has been activated, but not performed |
| 5048 // if we do not leave the builtin. To be able to step into the callback | 5048 // if we do not leave the builtin. To be able to step into the callback |
| 5049 // again, we need to clear the step out at this point. | 5049 // again, we need to clear the step out at this point. |
| 5050 debug->ClearStepOut(); | 5050 debug->ClearStepOut(); |
| 5051 debug->FloodWithOneShot(callback); | 5051 debug->FloodWithOneShot(callback); |
| 5052 #endif // ENABLE_DEBUGGER_SUPPORT | 5052 #endif // ENABLE_DEBUGGER_SUPPORT |
| 5053 return isolate->heap()->undefined_value(); | 5053 return isolate->heap()->undefined_value(); |
| 5054 } | 5054 } |
| 5055 | 5055 |
| 5056 | 5056 |
| 5057 // Set a local property, even if it is READ_ONLY. If the property does not | 5057 // Set a local property, even if it is READ_ONLY. If the property does not |
| 5058 // exist, it will be added with attributes NONE. | 5058 // exist, it will be added with attributes NONE. |
| 5059 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { | 5059 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { |
| 5060 NoHandleAllocation ha(isolate); | 5060 RequireNewHandleScope rnhs(isolate); |
| 5061 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 5061 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
| 5062 CONVERT_ARG_CHECKED(JSObject, object, 0); | 5062 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 5063 CONVERT_ARG_CHECKED(Name, name, 1); | 5063 CONVERT_ARG_CHECKED(Name, name, 1); |
| 5064 // Compute attributes. | 5064 // Compute attributes. |
| 5065 PropertyAttributes attributes = NONE; | 5065 PropertyAttributes attributes = NONE; |
| 5066 if (args.length() == 4) { | 5066 if (args.length() == 4) { |
| 5067 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); | 5067 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); |
| 5068 // Only attribute bits should be set. | 5068 // Only attribute bits should be set. |
| 5069 RUNTIME_ASSERT( | 5069 RUNTIME_ASSERT( |
| 5070 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5070 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
| 5071 attributes = static_cast<PropertyAttributes>(unchecked_value); | 5071 attributes = static_cast<PropertyAttributes>(unchecked_value); |
| 5072 } | 5072 } |
| 5073 | 5073 |
| 5074 return object-> | 5074 return object-> |
| 5075 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 5075 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
| 5076 } | 5076 } |
| 5077 | 5077 |
| 5078 | 5078 |
| 5079 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 5079 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
| 5080 NoHandleAllocation ha(isolate); | 5080 RequireNewHandleScope rnhs(isolate); |
| 5081 ASSERT(args.length() == 3); | 5081 ASSERT(args.length() == 3); |
| 5082 | 5082 |
| 5083 CONVERT_ARG_CHECKED(JSReceiver, object, 0); | 5083 CONVERT_ARG_CHECKED(JSReceiver, object, 0); |
| 5084 CONVERT_ARG_CHECKED(Name, key, 1); | 5084 CONVERT_ARG_CHECKED(Name, key, 1); |
| 5085 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 5085 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
| 5086 return object->DeleteProperty(key, (strict_mode == kStrictMode) | 5086 return object->DeleteProperty(key, (strict_mode == kStrictMode) |
| 5087 ? JSReceiver::STRICT_DELETION | 5087 ? JSReceiver::STRICT_DELETION |
| 5088 : JSReceiver::NORMAL_DELETION); | 5088 : JSReceiver::NORMAL_DELETION); |
| 5089 } | 5089 } |
| 5090 | 5090 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5101 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 5101 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
| 5102 return HasLocalPropertyImplementation(isolate, | 5102 return HasLocalPropertyImplementation(isolate, |
| 5103 Handle<JSObject>::cast(proto), | 5103 Handle<JSObject>::cast(proto), |
| 5104 key); | 5104 key); |
| 5105 } | 5105 } |
| 5106 return isolate->heap()->false_value(); | 5106 return isolate->heap()->false_value(); |
| 5107 } | 5107 } |
| 5108 | 5108 |
| 5109 | 5109 |
| 5110 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { | 5110 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { |
| 5111 NoHandleAllocation ha(isolate); | 5111 RequireNewHandleScope rnhs(isolate); |
| 5112 ASSERT(args.length() == 2); | 5112 ASSERT(args.length() == 2); |
| 5113 CONVERT_ARG_CHECKED(Name, key, 1); | 5113 CONVERT_ARG_CHECKED(Name, key, 1); |
| 5114 | 5114 |
| 5115 uint32_t index; | 5115 uint32_t index; |
| 5116 const bool key_is_array_index = key->AsArrayIndex(&index); | 5116 const bool key_is_array_index = key->AsArrayIndex(&index); |
| 5117 | 5117 |
| 5118 Object* obj = args[0]; | 5118 Object* obj = args[0]; |
| 5119 // Only JS objects can have properties. | 5119 // Only JS objects can have properties. |
| 5120 if (obj->IsJSObject()) { | 5120 if (obj->IsJSObject()) { |
| 5121 JSObject* object = JSObject::cast(obj); | 5121 JSObject* object = JSObject::cast(obj); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5140 String* string = String::cast(obj); | 5140 String* string = String::cast(obj); |
| 5141 if (index < static_cast<uint32_t>(string->length())) { | 5141 if (index < static_cast<uint32_t>(string->length())) { |
| 5142 return isolate->heap()->true_value(); | 5142 return isolate->heap()->true_value(); |
| 5143 } | 5143 } |
| 5144 } | 5144 } |
| 5145 return isolate->heap()->false_value(); | 5145 return isolate->heap()->false_value(); |
| 5146 } | 5146 } |
| 5147 | 5147 |
| 5148 | 5148 |
| 5149 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { | 5149 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { |
| 5150 NoHandleAllocation na(isolate); | 5150 RequireNewHandleScope rnhs(isolate); |
| 5151 ASSERT(args.length() == 2); | 5151 ASSERT(args.length() == 2); |
| 5152 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 5152 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); |
| 5153 CONVERT_ARG_CHECKED(Name, key, 1); | 5153 CONVERT_ARG_CHECKED(Name, key, 1); |
| 5154 | 5154 |
| 5155 bool result = receiver->HasProperty(key); | 5155 bool result = receiver->HasProperty(key); |
| 5156 if (isolate->has_pending_exception()) return Failure::Exception(); | 5156 if (isolate->has_pending_exception()) return Failure::Exception(); |
| 5157 return isolate->heap()->ToBoolean(result); | 5157 return isolate->heap()->ToBoolean(result); |
| 5158 } | 5158 } |
| 5159 | 5159 |
| 5160 | 5160 |
| 5161 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { | 5161 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { |
| 5162 NoHandleAllocation na(isolate); | 5162 RequireNewHandleScope rnhs(isolate); |
| 5163 ASSERT(args.length() == 2); | 5163 ASSERT(args.length() == 2); |
| 5164 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 5164 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); |
| 5165 CONVERT_SMI_ARG_CHECKED(index, 1); | 5165 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 5166 | 5166 |
| 5167 bool result = receiver->HasElement(index); | 5167 bool result = receiver->HasElement(index); |
| 5168 if (isolate->has_pending_exception()) return Failure::Exception(); | 5168 if (isolate->has_pending_exception()) return Failure::Exception(); |
| 5169 return isolate->heap()->ToBoolean(result); | 5169 return isolate->heap()->ToBoolean(result); |
| 5170 } | 5170 } |
| 5171 | 5171 |
| 5172 | 5172 |
| 5173 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { | 5173 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { |
| 5174 NoHandleAllocation ha(isolate); | 5174 RequireNewHandleScope rnhs(isolate); |
| 5175 ASSERT(args.length() == 2); | 5175 ASSERT(args.length() == 2); |
| 5176 | 5176 |
| 5177 CONVERT_ARG_CHECKED(JSObject, object, 0); | 5177 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 5178 CONVERT_ARG_CHECKED(Name, key, 1); | 5178 CONVERT_ARG_CHECKED(Name, key, 1); |
| 5179 | 5179 |
| 5180 PropertyAttributes att = object->GetLocalPropertyAttribute(key); | 5180 PropertyAttributes att = object->GetLocalPropertyAttribute(key); |
| 5181 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); | 5181 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); |
| 5182 } | 5182 } |
| 5183 | 5183 |
| 5184 | 5184 |
| 5185 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { | 5185 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { |
| 5186 HandleScope scope(isolate); | 5186 HandleScope scope(isolate); |
| 5187 ASSERT(args.length() == 1); | 5187 ASSERT(args.length() == 1); |
| 5188 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5188 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 5189 bool threw = false; | 5189 bool threw = false; |
| 5190 Handle<JSArray> result = GetKeysFor(object, &threw); | 5190 Handle<JSArray> result = GetKeysFor(object, &threw); |
| 5191 if (threw) return Failure::Exception(); | 5191 if (threw) return Failure::Exception(); |
| 5192 return *result; | 5192 return *result; |
| 5193 } | 5193 } |
| 5194 | 5194 |
| 5195 | 5195 |
| 5196 // Returns either a FixedArray as Runtime_GetPropertyNames, | 5196 // Returns either a FixedArray as Runtime_GetPropertyNames, |
| 5197 // or, if the given object has an enum cache that contains | 5197 // or, if the given object has an enum cache that contains |
| 5198 // all enumerable properties of the object and its prototypes | 5198 // all enumerable properties of the object and its prototypes |
| 5199 // have none, the map of the object. This is used to speed up | 5199 // have none, the map of the object. This is used to speed up |
| 5200 // the check for deletions during a for-in. | 5200 // the check for deletions during a for-in. |
| 5201 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { | 5201 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { |
| 5202 NoHandleAllocation ha(isolate); | 5202 RequireNewHandleScope rnhs(isolate); |
| 5203 ASSERT(args.length() == 1); | 5203 ASSERT(args.length() == 1); |
| 5204 | 5204 |
| 5205 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); | 5205 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); |
| 5206 | 5206 |
| 5207 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 5207 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
| 5208 | 5208 |
| 5209 HandleScope scope(isolate); | 5209 HandleScope scope(isolate); |
| 5210 Handle<JSReceiver> object(raw_object); | 5210 Handle<JSReceiver> object(raw_object); |
| 5211 bool threw = false; | 5211 bool threw = false; |
| 5212 Handle<FixedArray> content = | 5212 Handle<FixedArray> content = |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5431 Handle<Object> entry_str = | 5431 Handle<Object> entry_str = |
| 5432 isolate->factory()->NumberToString(entry_handle); | 5432 isolate->factory()->NumberToString(entry_handle); |
| 5433 copy->set(i, *entry_str); | 5433 copy->set(i, *entry_str); |
| 5434 } | 5434 } |
| 5435 } | 5435 } |
| 5436 return *isolate->factory()->NewJSArrayWithElements(copy); | 5436 return *isolate->factory()->NewJSArrayWithElements(copy); |
| 5437 } | 5437 } |
| 5438 | 5438 |
| 5439 | 5439 |
| 5440 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { | 5440 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { |
| 5441 NoHandleAllocation ha(isolate); | 5441 RequireNewHandleScope rnhs(isolate); |
| 5442 ASSERT(args.length() == 1); | 5442 ASSERT(args.length() == 1); |
| 5443 | 5443 |
| 5444 // Compute the frame holding the arguments. | 5444 // Compute the frame holding the arguments. |
| 5445 JavaScriptFrameIterator it(isolate); | 5445 JavaScriptFrameIterator it(isolate); |
| 5446 it.AdvanceToArgumentsFrame(); | 5446 it.AdvanceToArgumentsFrame(); |
| 5447 JavaScriptFrame* frame = it.frame(); | 5447 JavaScriptFrame* frame = it.frame(); |
| 5448 | 5448 |
| 5449 // Get the actual number of provided arguments. | 5449 // Get the actual number of provided arguments. |
| 5450 const uint32_t n = frame->ComputeParametersCount(); | 5450 const uint32_t n = frame->ComputeParametersCount(); |
| 5451 | 5451 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5490 } | 5490 } |
| 5491 return function; | 5491 return function; |
| 5492 } | 5492 } |
| 5493 | 5493 |
| 5494 // Lookup in the initial Object.prototype object. | 5494 // Lookup in the initial Object.prototype object. |
| 5495 return isolate->initial_object_prototype()->GetProperty(*key); | 5495 return isolate->initial_object_prototype()->GetProperty(*key); |
| 5496 } | 5496 } |
| 5497 | 5497 |
| 5498 | 5498 |
| 5499 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { | 5499 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { |
| 5500 NoHandleAllocation ha(isolate); | 5500 RequireNewHandleScope rnhs(isolate); |
| 5501 ASSERT(args.length() == 1); | 5501 ASSERT(args.length() == 1); |
| 5502 Object* object = args[0]; | 5502 Object* object = args[0]; |
| 5503 return (object->IsJSObject() && !object->IsGlobalObject()) | 5503 return (object->IsJSObject() && !object->IsGlobalObject()) |
| 5504 ? JSObject::cast(object)->TransformToFastProperties(0) | 5504 ? JSObject::cast(object)->TransformToFastProperties(0) |
| 5505 : object; | 5505 : object; |
| 5506 } | 5506 } |
| 5507 | 5507 |
| 5508 | 5508 |
| 5509 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { | 5509 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { |
| 5510 NoHandleAllocation ha(isolate); | 5510 RequireNewHandleScope rnhs(isolate); |
| 5511 ASSERT(args.length() == 1); | 5511 ASSERT(args.length() == 1); |
| 5512 | 5512 |
| 5513 return isolate->heap()->ToBoolean(args[0]->BooleanValue()); | 5513 return isolate->heap()->ToBoolean(args[0]->BooleanValue()); |
| 5514 } | 5514 } |
| 5515 | 5515 |
| 5516 | 5516 |
| 5517 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 5517 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
| 5518 // Possible optimizations: put the type string into the oddballs. | 5518 // Possible optimizations: put the type string into the oddballs. |
| 5519 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { | 5519 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { |
| 5520 NoHandleAllocation ha(isolate); | 5520 RequireNewHandleScope rnhs(isolate); |
| 5521 | 5521 |
| 5522 Object* obj = args[0]; | 5522 Object* obj = args[0]; |
| 5523 if (obj->IsNumber()) return isolate->heap()->number_string(); | 5523 if (obj->IsNumber()) return isolate->heap()->number_string(); |
| 5524 HeapObject* heap_obj = HeapObject::cast(obj); | 5524 HeapObject* heap_obj = HeapObject::cast(obj); |
| 5525 | 5525 |
| 5526 // typeof an undetectable object is 'undefined' | 5526 // typeof an undetectable object is 'undefined' |
| 5527 if (heap_obj->map()->is_undetectable()) { | 5527 if (heap_obj->map()->is_undetectable()) { |
| 5528 return isolate->heap()->undefined_string(); | 5528 return isolate->heap()->undefined_string(); |
| 5529 } | 5529 } |
| 5530 | 5530 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5574 | 5574 |
| 5575 for (int i = from + 1; i < to; i++) { | 5575 for (int i = from + 1; i < to; i++) { |
| 5576 d = 10 * d + (s[i] - '0'); | 5576 d = 10 * d + (s[i] - '0'); |
| 5577 } | 5577 } |
| 5578 | 5578 |
| 5579 return d; | 5579 return d; |
| 5580 } | 5580 } |
| 5581 | 5581 |
| 5582 | 5582 |
| 5583 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { | 5583 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { |
| 5584 NoHandleAllocation ha(isolate); | 5584 RequireNewHandleScope rnhs(isolate); |
| 5585 ASSERT(args.length() == 1); | 5585 ASSERT(args.length() == 1); |
| 5586 CONVERT_ARG_CHECKED(String, subject, 0); | 5586 CONVERT_ARG_CHECKED(String, subject, 0); |
| 5587 subject->TryFlatten(); | 5587 subject->TryFlatten(); |
| 5588 | 5588 |
| 5589 // Fast case: short integer or some sorts of junk values. | 5589 // Fast case: short integer or some sorts of junk values. |
| 5590 int len = subject->length(); | 5590 int len = subject->length(); |
| 5591 if (subject->IsSeqOneByteString()) { | 5591 if (subject->IsSeqOneByteString()) { |
| 5592 if (len == 0) return Smi::FromInt(0); | 5592 if (len == 0) return Smi::FromInt(0); |
| 5593 | 5593 |
| 5594 uint8_t const* data = SeqOneByteString::cast(subject)->GetChars(); | 5594 uint8_t const* data = SeqOneByteString::cast(subject)->GetChars(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5629 } | 5629 } |
| 5630 } | 5630 } |
| 5631 | 5631 |
| 5632 // Slower case. | 5632 // Slower case. |
| 5633 return isolate->heap()->NumberFromDouble( | 5633 return isolate->heap()->NumberFromDouble( |
| 5634 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX)); | 5634 StringToDouble(isolate->unicode_cache(), subject, ALLOW_HEX)); |
| 5635 } | 5635 } |
| 5636 | 5636 |
| 5637 | 5637 |
| 5638 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) { | 5638 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) { |
| 5639 NoHandleAllocation ha(isolate); | 5639 RequireNewHandleScope rnhs(isolate); |
| 5640 CONVERT_SMI_ARG_CHECKED(length, 0); | 5640 CONVERT_SMI_ARG_CHECKED(length, 0); |
| 5641 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); | 5641 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); |
| 5642 if (length == 0) return isolate->heap()->empty_string(); | 5642 if (length == 0) return isolate->heap()->empty_string(); |
| 5643 if (is_one_byte) { | 5643 if (is_one_byte) { |
| 5644 return isolate->heap()->AllocateRawOneByteString(length); | 5644 return isolate->heap()->AllocateRawOneByteString(length); |
| 5645 } else { | 5645 } else { |
| 5646 return isolate->heap()->AllocateRawTwoByteString(length); | 5646 return isolate->heap()->AllocateRawTwoByteString(length); |
| 5647 } | 5647 } |
| 5648 } | 5648 } |
| 5649 | 5649 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5692 | 5692 |
| 5693 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { | 5693 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { |
| 5694 HandleScope scope(isolate); | 5694 HandleScope scope(isolate); |
| 5695 ASSERT(args.length() == 1); | 5695 ASSERT(args.length() == 1); |
| 5696 BasicJsonStringifier stringifier(isolate); | 5696 BasicJsonStringifier stringifier(isolate); |
| 5697 return stringifier.Stringify(Handle<Object>(args[0], isolate)); | 5697 return stringifier.Stringify(Handle<Object>(args[0], isolate)); |
| 5698 } | 5698 } |
| 5699 | 5699 |
| 5700 | 5700 |
| 5701 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { | 5701 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { |
| 5702 NoHandleAllocation ha(isolate); | 5702 RequireNewHandleScope rnhs(isolate); |
| 5703 | 5703 |
| 5704 CONVERT_ARG_CHECKED(String, s, 0); | 5704 CONVERT_ARG_CHECKED(String, s, 0); |
| 5705 CONVERT_SMI_ARG_CHECKED(radix, 1); | 5705 CONVERT_SMI_ARG_CHECKED(radix, 1); |
| 5706 | 5706 |
| 5707 s->TryFlatten(); | 5707 s->TryFlatten(); |
| 5708 | 5708 |
| 5709 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 5709 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
| 5710 double value = StringToInt(isolate->unicode_cache(), s, radix); | 5710 double value = StringToInt(isolate->unicode_cache(), s, radix); |
| 5711 return isolate->heap()->NumberFromDouble(value); | 5711 return isolate->heap()->NumberFromDouble(value); |
| 5712 } | 5712 } |
| 5713 | 5713 |
| 5714 | 5714 |
| 5715 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { | 5715 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { |
| 5716 NoHandleAllocation ha(isolate); | 5716 RequireNewHandleScope rnhs(isolate); |
| 5717 CONVERT_ARG_CHECKED(String, str, 0); | 5717 CONVERT_ARG_CHECKED(String, str, 0); |
| 5718 | 5718 |
| 5719 // ECMA-262 section 15.1.2.3, empty string is NaN | 5719 // ECMA-262 section 15.1.2.3, empty string is NaN |
| 5720 double value = StringToDouble(isolate->unicode_cache(), | 5720 double value = StringToDouble(isolate->unicode_cache(), |
| 5721 str, ALLOW_TRAILING_JUNK, OS::nan_value()); | 5721 str, ALLOW_TRAILING_JUNK, OS::nan_value()); |
| 5722 | 5722 |
| 5723 // Create a number object from the value. | 5723 // Create a number object from the value. |
| 5724 return isolate->heap()->NumberFromDouble(value); | 5724 return isolate->heap()->NumberFromDouble(value); |
| 5725 } | 5725 } |
| 5726 | 5726 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5961 }; | 5961 }; |
| 5962 | 5962 |
| 5963 } // namespace | 5963 } // namespace |
| 5964 | 5964 |
| 5965 | 5965 |
| 5966 template <typename ConvertTraits> | 5966 template <typename ConvertTraits> |
| 5967 MUST_USE_RESULT static MaybeObject* ConvertCase( | 5967 MUST_USE_RESULT static MaybeObject* ConvertCase( |
| 5968 Arguments args, | 5968 Arguments args, |
| 5969 Isolate* isolate, | 5969 Isolate* isolate, |
| 5970 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { | 5970 unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) { |
| 5971 NoHandleAllocation ha(isolate); | 5971 RequireNewHandleScope rnhs(isolate); |
| 5972 CONVERT_ARG_CHECKED(String, s, 0); | 5972 CONVERT_ARG_CHECKED(String, s, 0); |
| 5973 s = s->TryFlattenGetString(); | 5973 s = s->TryFlattenGetString(); |
| 5974 | 5974 |
| 5975 const int length = s->length(); | 5975 const int length = s->length(); |
| 5976 // Assume that the string is not empty; we need this assumption later | 5976 // Assume that the string is not empty; we need this assumption later |
| 5977 if (length == 0) return s; | 5977 if (length == 0) return s; |
| 5978 | 5978 |
| 5979 // Simpler handling of ASCII strings. | 5979 // Simpler handling of ASCII strings. |
| 5980 // | 5980 // |
| 5981 // NOTE: This assumes that the upper/lower case of an ASCII | 5981 // NOTE: This assumes that the upper/lower case of an ASCII |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6028 args, isolate, isolate->runtime_state()->to_upper_mapping()); | 6028 args, isolate, isolate->runtime_state()->to_upper_mapping()); |
| 6029 } | 6029 } |
| 6030 | 6030 |
| 6031 | 6031 |
| 6032 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { | 6032 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { |
| 6033 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; | 6033 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; |
| 6034 } | 6034 } |
| 6035 | 6035 |
| 6036 | 6036 |
| 6037 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { | 6037 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { |
| 6038 NoHandleAllocation ha(isolate); | 6038 RequireNewHandleScope rnhs(isolate); |
| 6039 ASSERT(args.length() == 3); | 6039 ASSERT(args.length() == 3); |
| 6040 | 6040 |
| 6041 CONVERT_ARG_CHECKED(String, s, 0); | 6041 CONVERT_ARG_CHECKED(String, s, 0); |
| 6042 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); | 6042 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); |
| 6043 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); | 6043 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); |
| 6044 | 6044 |
| 6045 s->TryFlatten(); | 6045 s->TryFlatten(); |
| 6046 int length = s->length(); | 6046 int length = s->length(); |
| 6047 | 6047 |
| 6048 int left = 0; | 6048 int left = 0; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6154 | 6154 |
| 6155 | 6155 |
| 6156 // Copies ASCII characters to the given fixed array looking up | 6156 // Copies ASCII characters to the given fixed array looking up |
| 6157 // one-char strings in the cache. Gives up on the first char that is | 6157 // one-char strings in the cache. Gives up on the first char that is |
| 6158 // not in the cache and fills the remainder with smi zeros. Returns | 6158 // not in the cache and fills the remainder with smi zeros. Returns |
| 6159 // the length of the successfully copied prefix. | 6159 // the length of the successfully copied prefix. |
| 6160 static int CopyCachedAsciiCharsToArray(Heap* heap, | 6160 static int CopyCachedAsciiCharsToArray(Heap* heap, |
| 6161 const uint8_t* chars, | 6161 const uint8_t* chars, |
| 6162 FixedArray* elements, | 6162 FixedArray* elements, |
| 6163 int length) { | 6163 int length) { |
| 6164 AssertNoAllocation no_gc; | 6164 DisallowHeapAllocation no_gc; |
| 6165 FixedArray* ascii_cache = heap->single_character_string_cache(); | 6165 FixedArray* ascii_cache = heap->single_character_string_cache(); |
| 6166 Object* undefined = heap->undefined_value(); | 6166 Object* undefined = heap->undefined_value(); |
| 6167 int i; | 6167 int i; |
| 6168 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); | 6168 WriteBarrierMode mode = elements->GetWriteBarrierMode(no_gc); |
| 6169 for (i = 0; i < length; ++i) { | 6169 for (i = 0; i < length; ++i) { |
| 6170 Object* value = ascii_cache->get(chars[i]); | 6170 Object* value = ascii_cache->get(chars[i]); |
| 6171 if (value == undefined) break; | 6171 if (value == undefined) break; |
| 6172 elements->set(i, value, mode); | 6172 elements->set(i, value, mode); |
| 6173 } | 6173 } |
| 6174 if (i < length) { | 6174 if (i < length) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 6200 Handle<FixedArray> elements; | 6200 Handle<FixedArray> elements; |
| 6201 int position = 0; | 6201 int position = 0; |
| 6202 if (s->IsFlat() && s->IsOneByteRepresentation()) { | 6202 if (s->IsFlat() && s->IsOneByteRepresentation()) { |
| 6203 // Try using cached chars where possible. | 6203 // Try using cached chars where possible. |
| 6204 Object* obj; | 6204 Object* obj; |
| 6205 { MaybeObject* maybe_obj = | 6205 { MaybeObject* maybe_obj = |
| 6206 isolate->heap()->AllocateUninitializedFixedArray(length); | 6206 isolate->heap()->AllocateUninitializedFixedArray(length); |
| 6207 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6207 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 6208 } | 6208 } |
| 6209 elements = Handle<FixedArray>(FixedArray::cast(obj), isolate); | 6209 elements = Handle<FixedArray>(FixedArray::cast(obj), isolate); |
| 6210 AssertNoAllocation no_gc; | 6210 DisallowHeapAllocation no_gc; |
| 6211 String::FlatContent content = s->GetFlatContent(); | 6211 String::FlatContent content = s->GetFlatContent(); |
| 6212 if (content.IsAscii()) { | 6212 if (content.IsAscii()) { |
| 6213 Vector<const uint8_t> chars = content.ToOneByteVector(); | 6213 Vector<const uint8_t> chars = content.ToOneByteVector(); |
| 6214 // Note, this will initialize all elements (not only the prefix) | 6214 // Note, this will initialize all elements (not only the prefix) |
| 6215 // to prevent GC from seeing partially initialized array. | 6215 // to prevent GC from seeing partially initialized array. |
| 6216 position = CopyCachedAsciiCharsToArray(isolate->heap(), | 6216 position = CopyCachedAsciiCharsToArray(isolate->heap(), |
| 6217 chars.start(), | 6217 chars.start(), |
| 6218 *elements, | 6218 *elements, |
| 6219 length); | 6219 length); |
| 6220 } else { | 6220 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6235 for (int i = 0; i < length; ++i) { | 6235 for (int i = 0; i < length; ++i) { |
| 6236 ASSERT(String::cast(elements->get(i))->length() == 1); | 6236 ASSERT(String::cast(elements->get(i))->length() == 1); |
| 6237 } | 6237 } |
| 6238 #endif | 6238 #endif |
| 6239 | 6239 |
| 6240 return *isolate->factory()->NewJSArrayWithElements(elements); | 6240 return *isolate->factory()->NewJSArrayWithElements(elements); |
| 6241 } | 6241 } |
| 6242 | 6242 |
| 6243 | 6243 |
| 6244 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { | 6244 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { |
| 6245 NoHandleAllocation ha(isolate); | 6245 RequireNewHandleScope rnhs(isolate); |
| 6246 ASSERT(args.length() == 1); | 6246 ASSERT(args.length() == 1); |
| 6247 CONVERT_ARG_CHECKED(String, value, 0); | 6247 CONVERT_ARG_CHECKED(String, value, 0); |
| 6248 return value->ToObject(); | 6248 return value->ToObject(); |
| 6249 } | 6249 } |
| 6250 | 6250 |
| 6251 | 6251 |
| 6252 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6252 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
| 6253 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6253 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
| 6254 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6254 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
| 6255 return char_length == 0; | 6255 return char_length == 0; |
| 6256 } | 6256 } |
| 6257 | 6257 |
| 6258 | 6258 |
| 6259 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { | 6259 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { |
| 6260 NoHandleAllocation ha(isolate); | 6260 RequireNewHandleScope rnhs(isolate); |
| 6261 ASSERT(args.length() == 1); | 6261 ASSERT(args.length() == 1); |
| 6262 | 6262 |
| 6263 Object* number = args[0]; | 6263 Object* number = args[0]; |
| 6264 RUNTIME_ASSERT(number->IsNumber()); | 6264 RUNTIME_ASSERT(number->IsNumber()); |
| 6265 | 6265 |
| 6266 return isolate->heap()->NumberToString(number); | 6266 return isolate->heap()->NumberToString(number); |
| 6267 } | 6267 } |
| 6268 | 6268 |
| 6269 | 6269 |
| 6270 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { | 6270 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { |
| 6271 NoHandleAllocation ha(isolate); | 6271 RequireNewHandleScope rnhs(isolate); |
| 6272 ASSERT(args.length() == 1); | 6272 ASSERT(args.length() == 1); |
| 6273 | 6273 |
| 6274 Object* number = args[0]; | 6274 Object* number = args[0]; |
| 6275 RUNTIME_ASSERT(number->IsNumber()); | 6275 RUNTIME_ASSERT(number->IsNumber()); |
| 6276 | 6276 |
| 6277 return isolate->heap()->NumberToString( | 6277 return isolate->heap()->NumberToString( |
| 6278 number, false, isolate->heap()->GetPretenureMode()); | 6278 number, false, isolate->heap()->GetPretenureMode()); |
| 6279 } | 6279 } |
| 6280 | 6280 |
| 6281 | 6281 |
| 6282 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { | 6282 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { |
| 6283 NoHandleAllocation ha(isolate); | 6283 RequireNewHandleScope rnhs(isolate); |
| 6284 ASSERT(args.length() == 1); | 6284 ASSERT(args.length() == 1); |
| 6285 | 6285 |
| 6286 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6286 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6287 | 6287 |
| 6288 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6288 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 6289 if (number > 0 && number <= Smi::kMaxValue) { | 6289 if (number > 0 && number <= Smi::kMaxValue) { |
| 6290 return Smi::FromInt(static_cast<int>(number)); | 6290 return Smi::FromInt(static_cast<int>(number)); |
| 6291 } | 6291 } |
| 6292 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); | 6292 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); |
| 6293 } | 6293 } |
| 6294 | 6294 |
| 6295 | 6295 |
| 6296 // ES6 draft 9.1.11 | 6296 // ES6 draft 9.1.11 |
| 6297 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPositiveInteger) { | 6297 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPositiveInteger) { |
| 6298 NoHandleAllocation ha(isolate); | 6298 RequireNewHandleScope rnhs(isolate); |
| 6299 ASSERT(args.length() == 1); | 6299 ASSERT(args.length() == 1); |
| 6300 | 6300 |
| 6301 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6301 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6302 | 6302 |
| 6303 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6303 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 6304 if (number > 0 && number <= Smi::kMaxValue) { | 6304 if (number > 0 && number <= Smi::kMaxValue) { |
| 6305 return Smi::FromInt(static_cast<int>(number)); | 6305 return Smi::FromInt(static_cast<int>(number)); |
| 6306 } | 6306 } |
| 6307 if (number <= 0) { | 6307 if (number <= 0) { |
| 6308 return Smi::FromInt(0); | 6308 return Smi::FromInt(0); |
| 6309 } | 6309 } |
| 6310 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); | 6310 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); |
| 6311 } | 6311 } |
| 6312 | 6312 |
| 6313 | 6313 |
| 6314 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { | 6314 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { |
| 6315 NoHandleAllocation ha(isolate); | 6315 RequireNewHandleScope rnhs(isolate); |
| 6316 ASSERT(args.length() == 1); | 6316 ASSERT(args.length() == 1); |
| 6317 | 6317 |
| 6318 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6318 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6319 | 6319 |
| 6320 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6320 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 6321 if (number > 0 && number <= Smi::kMaxValue) { | 6321 if (number > 0 && number <= Smi::kMaxValue) { |
| 6322 return Smi::FromInt(static_cast<int>(number)); | 6322 return Smi::FromInt(static_cast<int>(number)); |
| 6323 } | 6323 } |
| 6324 | 6324 |
| 6325 double double_value = DoubleToInteger(number); | 6325 double double_value = DoubleToInteger(number); |
| 6326 // Map both -0 and +0 to +0. | 6326 // Map both -0 and +0 to +0. |
| 6327 if (double_value == 0) double_value = 0; | 6327 if (double_value == 0) double_value = 0; |
| 6328 | 6328 |
| 6329 return isolate->heap()->NumberFromDouble(double_value); | 6329 return isolate->heap()->NumberFromDouble(double_value); |
| 6330 } | 6330 } |
| 6331 | 6331 |
| 6332 | 6332 |
| 6333 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { | 6333 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { |
| 6334 NoHandleAllocation ha(isolate); | 6334 RequireNewHandleScope rnhs(isolate); |
| 6335 ASSERT(args.length() == 1); | 6335 ASSERT(args.length() == 1); |
| 6336 | 6336 |
| 6337 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 6337 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
| 6338 return isolate->heap()->NumberFromUint32(number); | 6338 return isolate->heap()->NumberFromUint32(number); |
| 6339 } | 6339 } |
| 6340 | 6340 |
| 6341 | 6341 |
| 6342 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { | 6342 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { |
| 6343 NoHandleAllocation ha(isolate); | 6343 RequireNewHandleScope rnhs(isolate); |
| 6344 ASSERT(args.length() == 1); | 6344 ASSERT(args.length() == 1); |
| 6345 | 6345 |
| 6346 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6346 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
| 6347 | 6347 |
| 6348 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 6348 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 6349 if (number > 0 && number <= Smi::kMaxValue) { | 6349 if (number > 0 && number <= Smi::kMaxValue) { |
| 6350 return Smi::FromInt(static_cast<int>(number)); | 6350 return Smi::FromInt(static_cast<int>(number)); |
| 6351 } | 6351 } |
| 6352 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); | 6352 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); |
| 6353 } | 6353 } |
| 6354 | 6354 |
| 6355 | 6355 |
| 6356 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 6356 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
| 6357 // a small integer. | 6357 // a small integer. |
| 6358 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToSmi) { | 6358 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToSmi) { |
| 6359 NoHandleAllocation ha(isolate); | 6359 RequireNewHandleScope rnhs(isolate); |
| 6360 ASSERT(args.length() == 1); | 6360 ASSERT(args.length() == 1); |
| 6361 | 6361 |
| 6362 Object* obj = args[0]; | 6362 Object* obj = args[0]; |
| 6363 if (obj->IsSmi()) { | 6363 if (obj->IsSmi()) { |
| 6364 return obj; | 6364 return obj; |
| 6365 } | 6365 } |
| 6366 if (obj->IsHeapNumber()) { | 6366 if (obj->IsHeapNumber()) { |
| 6367 double value = HeapNumber::cast(obj)->value(); | 6367 double value = HeapNumber::cast(obj)->value(); |
| 6368 int int_value = FastD2I(value); | 6368 int int_value = FastD2I(value); |
| 6369 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 6369 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
| 6370 return Smi::FromInt(int_value); | 6370 return Smi::FromInt(int_value); |
| 6371 } | 6371 } |
| 6372 } | 6372 } |
| 6373 return isolate->heap()->nan_value(); | 6373 return isolate->heap()->nan_value(); |
| 6374 } | 6374 } |
| 6375 | 6375 |
| 6376 | 6376 |
| 6377 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { | 6377 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { |
| 6378 NoHandleAllocation ha(isolate); | 6378 RequireNewHandleScope rnhs(isolate); |
| 6379 ASSERT(args.length() == 0); | 6379 ASSERT(args.length() == 0); |
| 6380 return isolate->heap()->AllocateHeapNumber(0); | 6380 return isolate->heap()->AllocateHeapNumber(0); |
| 6381 } | 6381 } |
| 6382 | 6382 |
| 6383 | 6383 |
| 6384 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { | 6384 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { |
| 6385 NoHandleAllocation ha(isolate); | 6385 RequireNewHandleScope rnhs(isolate); |
| 6386 ASSERT(args.length() == 2); | 6386 ASSERT(args.length() == 2); |
| 6387 | 6387 |
| 6388 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6388 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6389 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6389 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6390 return isolate->heap()->NumberFromDouble(x + y); | 6390 return isolate->heap()->NumberFromDouble(x + y); |
| 6391 } | 6391 } |
| 6392 | 6392 |
| 6393 | 6393 |
| 6394 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { | 6394 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { |
| 6395 NoHandleAllocation ha(isolate); | 6395 RequireNewHandleScope rnhs(isolate); |
| 6396 ASSERT(args.length() == 2); | 6396 ASSERT(args.length() == 2); |
| 6397 | 6397 |
| 6398 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6398 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6399 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6399 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6400 return isolate->heap()->NumberFromDouble(x - y); | 6400 return isolate->heap()->NumberFromDouble(x - y); |
| 6401 } | 6401 } |
| 6402 | 6402 |
| 6403 | 6403 |
| 6404 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { | 6404 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { |
| 6405 NoHandleAllocation ha(isolate); | 6405 RequireNewHandleScope rnhs(isolate); |
| 6406 ASSERT(args.length() == 2); | 6406 ASSERT(args.length() == 2); |
| 6407 | 6407 |
| 6408 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6408 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6409 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6409 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6410 return isolate->heap()->NumberFromDouble(x * y); | 6410 return isolate->heap()->NumberFromDouble(x * y); |
| 6411 } | 6411 } |
| 6412 | 6412 |
| 6413 | 6413 |
| 6414 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { | 6414 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { |
| 6415 NoHandleAllocation ha(isolate); | 6415 RequireNewHandleScope rnhs(isolate); |
| 6416 ASSERT(args.length() == 1); | 6416 ASSERT(args.length() == 1); |
| 6417 | 6417 |
| 6418 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6418 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6419 return isolate->heap()->NumberFromDouble(-x); | 6419 return isolate->heap()->NumberFromDouble(-x); |
| 6420 } | 6420 } |
| 6421 | 6421 |
| 6422 | 6422 |
| 6423 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { | 6423 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { |
| 6424 NoHandleAllocation ha(isolate); | 6424 RequireNewHandleScope rnhs(isolate); |
| 6425 ASSERT(args.length() == 0); | 6425 ASSERT(args.length() == 0); |
| 6426 | 6426 |
| 6427 return isolate->heap()->NumberFromDouble(9876543210.0); | 6427 return isolate->heap()->NumberFromDouble(9876543210.0); |
| 6428 } | 6428 } |
| 6429 | 6429 |
| 6430 | 6430 |
| 6431 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { | 6431 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { |
| 6432 NoHandleAllocation ha(isolate); | 6432 RequireNewHandleScope rnhs(isolate); |
| 6433 ASSERT(args.length() == 2); | 6433 ASSERT(args.length() == 2); |
| 6434 | 6434 |
| 6435 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6435 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6436 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6436 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6437 return isolate->heap()->NumberFromDouble(x / y); | 6437 return isolate->heap()->NumberFromDouble(x / y); |
| 6438 } | 6438 } |
| 6439 | 6439 |
| 6440 | 6440 |
| 6441 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { | 6441 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { |
| 6442 NoHandleAllocation ha(isolate); | 6442 RequireNewHandleScope rnhs(isolate); |
| 6443 ASSERT(args.length() == 2); | 6443 ASSERT(args.length() == 2); |
| 6444 | 6444 |
| 6445 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6445 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6446 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6446 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6447 | 6447 |
| 6448 x = modulo(x, y); | 6448 x = modulo(x, y); |
| 6449 // NumberFromDouble may return a Smi instead of a Number object | 6449 // NumberFromDouble may return a Smi instead of a Number object |
| 6450 return isolate->heap()->NumberFromDouble(x); | 6450 return isolate->heap()->NumberFromDouble(x); |
| 6451 } | 6451 } |
| 6452 | 6452 |
| 6453 | 6453 |
| 6454 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { | 6454 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { |
| 6455 NoHandleAllocation ha(isolate); | 6455 RequireNewHandleScope rnhs(isolate); |
| 6456 ASSERT(args.length() == 2); | 6456 ASSERT(args.length() == 2); |
| 6457 | 6457 |
| 6458 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6458 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6459 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6459 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6460 return isolate->heap()->NumberFromInt32(x * y); | 6460 return isolate->heap()->NumberFromInt32(x * y); |
| 6461 } | 6461 } |
| 6462 | 6462 |
| 6463 | 6463 |
| 6464 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { | 6464 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { |
| 6465 NoHandleAllocation ha(isolate); | 6465 RequireNewHandleScope rnhs(isolate); |
| 6466 ASSERT(args.length() == 2); | 6466 ASSERT(args.length() == 2); |
| 6467 CONVERT_ARG_CHECKED(String, str1, 0); | 6467 CONVERT_ARG_CHECKED(String, str1, 0); |
| 6468 CONVERT_ARG_CHECKED(String, str2, 1); | 6468 CONVERT_ARG_CHECKED(String, str2, 1); |
| 6469 isolate->counters()->string_add_runtime()->Increment(); | 6469 isolate->counters()->string_add_runtime()->Increment(); |
| 6470 return isolate->heap()->AllocateConsString(str1, str2); | 6470 return isolate->heap()->AllocateConsString(str1, str2); |
| 6471 } | 6471 } |
| 6472 | 6472 |
| 6473 | 6473 |
| 6474 template <typename sinkchar> | 6474 template <typename sinkchar> |
| 6475 static inline void StringBuilderConcatHelper(String* special, | 6475 static inline void StringBuilderConcatHelper(String* special, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6504 String* string = String::cast(element); | 6504 String* string = String::cast(element); |
| 6505 int element_length = string->length(); | 6505 int element_length = string->length(); |
| 6506 String::WriteToFlat(string, sink + position, 0, element_length); | 6506 String::WriteToFlat(string, sink + position, 0, element_length); |
| 6507 position += element_length; | 6507 position += element_length; |
| 6508 } | 6508 } |
| 6509 } | 6509 } |
| 6510 } | 6510 } |
| 6511 | 6511 |
| 6512 | 6512 |
| 6513 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { | 6513 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { |
| 6514 NoHandleAllocation ha(isolate); | 6514 RequireNewHandleScope rnhs(isolate); |
| 6515 ASSERT(args.length() == 3); | 6515 ASSERT(args.length() == 3); |
| 6516 CONVERT_ARG_CHECKED(JSArray, array, 0); | 6516 CONVERT_ARG_CHECKED(JSArray, array, 0); |
| 6517 if (!args[1]->IsSmi()) { | 6517 if (!args[1]->IsSmi()) { |
| 6518 isolate->context()->mark_out_of_memory(); | 6518 isolate->context()->mark_out_of_memory(); |
| 6519 return Failure::OutOfMemoryException(0x14); | 6519 return Failure::OutOfMemoryException(0x14); |
| 6520 } | 6520 } |
| 6521 int array_length = args.smi_at(1); | 6521 int array_length = args.smi_at(1); |
| 6522 CONVERT_ARG_CHECKED(String, special, 2); | 6522 CONVERT_ARG_CHECKED(String, special, 2); |
| 6523 | 6523 |
| 6524 // This assumption is used by the slice encoding in one or two smis. | 6524 // This assumption is used by the slice encoding in one or two smis. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6621 StringBuilderConcatHelper(special, | 6621 StringBuilderConcatHelper(special, |
| 6622 answer->GetChars(), | 6622 answer->GetChars(), |
| 6623 fixed_array, | 6623 fixed_array, |
| 6624 array_length); | 6624 array_length); |
| 6625 return answer; | 6625 return answer; |
| 6626 } | 6626 } |
| 6627 } | 6627 } |
| 6628 | 6628 |
| 6629 | 6629 |
| 6630 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { | 6630 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { |
| 6631 NoHandleAllocation ha(isolate); | 6631 RequireNewHandleScope rnhs(isolate); |
| 6632 ASSERT(args.length() == 3); | 6632 ASSERT(args.length() == 3); |
| 6633 CONVERT_ARG_CHECKED(JSArray, array, 0); | 6633 CONVERT_ARG_CHECKED(JSArray, array, 0); |
| 6634 if (!args[1]->IsSmi()) { | 6634 if (!args[1]->IsSmi()) { |
| 6635 isolate->context()->mark_out_of_memory(); | 6635 isolate->context()->mark_out_of_memory(); |
| 6636 return Failure::OutOfMemoryException(0x16); | 6636 return Failure::OutOfMemoryException(0x16); |
| 6637 } | 6637 } |
| 6638 int array_length = args.smi_at(1); | 6638 int array_length = args.smi_at(1); |
| 6639 CONVERT_ARG_CHECKED(String, separator, 2); | 6639 CONVERT_ARG_CHECKED(String, separator, 2); |
| 6640 | 6640 |
| 6641 if (!array->HasFastObjectElements()) { | 6641 if (!array->HasFastObjectElements()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6746 0, separator_length); | 6746 0, separator_length); |
| 6747 cursor += separator_length; | 6747 cursor += separator_length; |
| 6748 previous_separator_position++; | 6748 previous_separator_position++; |
| 6749 } | 6749 } |
| 6750 } | 6750 } |
| 6751 ASSERT(cursor <= buffer.length()); | 6751 ASSERT(cursor <= buffer.length()); |
| 6752 } | 6752 } |
| 6753 | 6753 |
| 6754 | 6754 |
| 6755 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { | 6755 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { |
| 6756 NoHandleAllocation ha(isolate); | 6756 RequireNewHandleScope rnhs(isolate); |
| 6757 ASSERT(args.length() == 3); | 6757 ASSERT(args.length() == 3); |
| 6758 CONVERT_ARG_CHECKED(JSArray, elements_array, 0); | 6758 CONVERT_ARG_CHECKED(JSArray, elements_array, 0); |
| 6759 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); | 6759 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); |
| 6760 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 6760 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
| 6761 CONVERT_ARG_CHECKED(String, separator, 2); | 6761 CONVERT_ARG_CHECKED(String, separator, 2); |
| 6762 // elements_array is fast-mode JSarray of alternating positions | 6762 // elements_array is fast-mode JSarray of alternating positions |
| 6763 // (increasing order) and strings. | 6763 // (increasing order) and strings. |
| 6764 // array_length is length of original array (used to add separators); | 6764 // array_length is length of original array (used to add separators); |
| 6765 // separator is string to put between elements. Assumed to be non-empty. | 6765 // separator is string to put between elements. Assumed to be non-empty. |
| 6766 | 6766 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6842 array_length, | 6842 array_length, |
| 6843 separator, | 6843 separator, |
| 6844 Vector<uc16>(result_string->GetChars(), | 6844 Vector<uc16>(result_string->GetChars(), |
| 6845 string_length)); | 6845 string_length)); |
| 6846 return result_string; | 6846 return result_string; |
| 6847 } | 6847 } |
| 6848 } | 6848 } |
| 6849 | 6849 |
| 6850 | 6850 |
| 6851 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { | 6851 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { |
| 6852 NoHandleAllocation ha(isolate); | 6852 RequireNewHandleScope rnhs(isolate); |
| 6853 ASSERT(args.length() == 2); | 6853 ASSERT(args.length() == 2); |
| 6854 | 6854 |
| 6855 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6855 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6856 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6856 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6857 return isolate->heap()->NumberFromInt32(x | y); | 6857 return isolate->heap()->NumberFromInt32(x | y); |
| 6858 } | 6858 } |
| 6859 | 6859 |
| 6860 | 6860 |
| 6861 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { | 6861 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { |
| 6862 NoHandleAllocation ha(isolate); | 6862 RequireNewHandleScope rnhs(isolate); |
| 6863 ASSERT(args.length() == 2); | 6863 ASSERT(args.length() == 2); |
| 6864 | 6864 |
| 6865 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6865 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6866 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6866 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6867 return isolate->heap()->NumberFromInt32(x & y); | 6867 return isolate->heap()->NumberFromInt32(x & y); |
| 6868 } | 6868 } |
| 6869 | 6869 |
| 6870 | 6870 |
| 6871 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { | 6871 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { |
| 6872 NoHandleAllocation ha(isolate); | 6872 RequireNewHandleScope rnhs(isolate); |
| 6873 ASSERT(args.length() == 2); | 6873 ASSERT(args.length() == 2); |
| 6874 | 6874 |
| 6875 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6875 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6876 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6876 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6877 return isolate->heap()->NumberFromInt32(x ^ y); | 6877 return isolate->heap()->NumberFromInt32(x ^ y); |
| 6878 } | 6878 } |
| 6879 | 6879 |
| 6880 | 6880 |
| 6881 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberNot) { | 6881 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberNot) { |
| 6882 NoHandleAllocation ha(isolate); | 6882 RequireNewHandleScope rnhs(isolate); |
| 6883 ASSERT(args.length() == 1); | 6883 ASSERT(args.length() == 1); |
| 6884 | 6884 |
| 6885 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6885 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6886 return isolate->heap()->NumberFromInt32(~x); | 6886 return isolate->heap()->NumberFromInt32(~x); |
| 6887 } | 6887 } |
| 6888 | 6888 |
| 6889 | 6889 |
| 6890 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { | 6890 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { |
| 6891 NoHandleAllocation ha(isolate); | 6891 RequireNewHandleScope rnhs(isolate); |
| 6892 ASSERT(args.length() == 2); | 6892 ASSERT(args.length() == 2); |
| 6893 | 6893 |
| 6894 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6894 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6895 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6895 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6896 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); | 6896 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); |
| 6897 } | 6897 } |
| 6898 | 6898 |
| 6899 | 6899 |
| 6900 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { | 6900 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { |
| 6901 NoHandleAllocation ha(isolate); | 6901 RequireNewHandleScope rnhs(isolate); |
| 6902 ASSERT(args.length() == 2); | 6902 ASSERT(args.length() == 2); |
| 6903 | 6903 |
| 6904 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 6904 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
| 6905 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6905 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6906 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); | 6906 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); |
| 6907 } | 6907 } |
| 6908 | 6908 |
| 6909 | 6909 |
| 6910 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { | 6910 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { |
| 6911 NoHandleAllocation ha(isolate); | 6911 RequireNewHandleScope rnhs(isolate); |
| 6912 ASSERT(args.length() == 2); | 6912 ASSERT(args.length() == 2); |
| 6913 | 6913 |
| 6914 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6914 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
| 6915 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6915 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
| 6916 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); | 6916 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); |
| 6917 } | 6917 } |
| 6918 | 6918 |
| 6919 | 6919 |
| 6920 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { | 6920 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { |
| 6921 NoHandleAllocation ha(isolate); | 6921 RequireNewHandleScope rnhs(isolate); |
| 6922 ASSERT(args.length() == 2); | 6922 ASSERT(args.length() == 2); |
| 6923 | 6923 |
| 6924 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6924 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6925 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6925 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6926 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); | 6926 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); |
| 6927 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); | 6927 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); |
| 6928 if (x == y) return Smi::FromInt(EQUAL); | 6928 if (x == y) return Smi::FromInt(EQUAL); |
| 6929 Object* result; | 6929 Object* result; |
| 6930 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | 6930 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { |
| 6931 result = Smi::FromInt(EQUAL); | 6931 result = Smi::FromInt(EQUAL); |
| 6932 } else { | 6932 } else { |
| 6933 result = Smi::FromInt(NOT_EQUAL); | 6933 result = Smi::FromInt(NOT_EQUAL); |
| 6934 } | 6934 } |
| 6935 return result; | 6935 return result; |
| 6936 } | 6936 } |
| 6937 | 6937 |
| 6938 | 6938 |
| 6939 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { | 6939 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { |
| 6940 NoHandleAllocation ha(isolate); | 6940 RequireNewHandleScope rnhs(isolate); |
| 6941 ASSERT(args.length() == 2); | 6941 ASSERT(args.length() == 2); |
| 6942 | 6942 |
| 6943 CONVERT_ARG_CHECKED(String, x, 0); | 6943 CONVERT_ARG_CHECKED(String, x, 0); |
| 6944 CONVERT_ARG_CHECKED(String, y, 1); | 6944 CONVERT_ARG_CHECKED(String, y, 1); |
| 6945 | 6945 |
| 6946 bool not_equal = !x->Equals(y); | 6946 bool not_equal = !x->Equals(y); |
| 6947 // This is slightly convoluted because the value that signifies | 6947 // This is slightly convoluted because the value that signifies |
| 6948 // equality is 0 and inequality is 1 so we have to negate the result | 6948 // equality is 0 and inequality is 1 so we have to negate the result |
| 6949 // from String::Equals. | 6949 // from String::Equals. |
| 6950 ASSERT(not_equal == 0 || not_equal == 1); | 6950 ASSERT(not_equal == 0 || not_equal == 1); |
| 6951 STATIC_CHECK(EQUAL == 0); | 6951 STATIC_CHECK(EQUAL == 0); |
| 6952 STATIC_CHECK(NOT_EQUAL == 1); | 6952 STATIC_CHECK(NOT_EQUAL == 1); |
| 6953 return Smi::FromInt(not_equal); | 6953 return Smi::FromInt(not_equal); |
| 6954 } | 6954 } |
| 6955 | 6955 |
| 6956 | 6956 |
| 6957 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { | 6957 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { |
| 6958 NoHandleAllocation ha(isolate); | 6958 RequireNewHandleScope rnhs(isolate); |
| 6959 ASSERT(args.length() == 3); | 6959 ASSERT(args.length() == 3); |
| 6960 | 6960 |
| 6961 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6961 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 6962 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6962 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 6963 if (std::isnan(x) || std::isnan(y)) return args[2]; | 6963 if (std::isnan(x) || std::isnan(y)) return args[2]; |
| 6964 if (x == y) return Smi::FromInt(EQUAL); | 6964 if (x == y) return Smi::FromInt(EQUAL); |
| 6965 if (isless(x, y)) return Smi::FromInt(LESS); | 6965 if (isless(x, y)) return Smi::FromInt(LESS); |
| 6966 return Smi::FromInt(GREATER); | 6966 return Smi::FromInt(GREATER); |
| 6967 } | 6967 } |
| 6968 | 6968 |
| 6969 | 6969 |
| 6970 // Compare two Smis as if they were converted to strings and then | 6970 // Compare two Smis as if they were converted to strings and then |
| 6971 // compared lexicographically. | 6971 // compared lexicographically. |
| 6972 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { | 6972 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { |
| 6973 NoHandleAllocation ha(isolate); | 6973 RequireNewHandleScope rnhs(isolate); |
| 6974 ASSERT(args.length() == 2); | 6974 ASSERT(args.length() == 2); |
| 6975 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 6975 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
| 6976 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 6976 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
| 6977 | 6977 |
| 6978 // If the integers are equal so are the string representations. | 6978 // If the integers are equal so are the string representations. |
| 6979 if (x_value == y_value) return Smi::FromInt(EQUAL); | 6979 if (x_value == y_value) return Smi::FromInt(EQUAL); |
| 6980 | 6980 |
| 6981 // If one of the integers is zero the normal integer order is the | 6981 // If one of the integers is zero the normal integer order is the |
| 6982 // same as the lexicographic order of the string representations. | 6982 // same as the lexicographic order of the string representations. |
| 6983 if (x_value == 0 || y_value == 0) | 6983 if (x_value == 0 || y_value == 0) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7067 ASSERT(y->IsFlat()); | 7067 ASSERT(y->IsFlat()); |
| 7068 Object* equal_prefix_result = Smi::FromInt(EQUAL); | 7068 Object* equal_prefix_result = Smi::FromInt(EQUAL); |
| 7069 int prefix_length = x->length(); | 7069 int prefix_length = x->length(); |
| 7070 if (y->length() < prefix_length) { | 7070 if (y->length() < prefix_length) { |
| 7071 prefix_length = y->length(); | 7071 prefix_length = y->length(); |
| 7072 equal_prefix_result = Smi::FromInt(GREATER); | 7072 equal_prefix_result = Smi::FromInt(GREATER); |
| 7073 } else if (y->length() > prefix_length) { | 7073 } else if (y->length() > prefix_length) { |
| 7074 equal_prefix_result = Smi::FromInt(LESS); | 7074 equal_prefix_result = Smi::FromInt(LESS); |
| 7075 } | 7075 } |
| 7076 int r; | 7076 int r; |
| 7077 AssertNoAllocation no_gc; | 7077 DisallowHeapAllocation no_gc; |
| 7078 String::FlatContent x_content = x->GetFlatContent(); | 7078 String::FlatContent x_content = x->GetFlatContent(); |
| 7079 String::FlatContent y_content = y->GetFlatContent(); | 7079 String::FlatContent y_content = y->GetFlatContent(); |
| 7080 if (x_content.IsAscii()) { | 7080 if (x_content.IsAscii()) { |
| 7081 Vector<const uint8_t> x_chars = x_content.ToOneByteVector(); | 7081 Vector<const uint8_t> x_chars = x_content.ToOneByteVector(); |
| 7082 if (y_content.IsAscii()) { | 7082 if (y_content.IsAscii()) { |
| 7083 Vector<const uint8_t> y_chars = y_content.ToOneByteVector(); | 7083 Vector<const uint8_t> y_chars = y_content.ToOneByteVector(); |
| 7084 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); | 7084 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); |
| 7085 } else { | 7085 } else { |
| 7086 Vector<const uc16> y_chars = y_content.ToUC16Vector(); | 7086 Vector<const uc16> y_chars = y_content.ToUC16Vector(); |
| 7087 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); | 7087 r = CompareChars(x_chars.start(), y_chars.start(), prefix_length); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 7102 } else { | 7102 } else { |
| 7103 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 7103 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
| 7104 } | 7104 } |
| 7105 ASSERT(result == | 7105 ASSERT(result == |
| 7106 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); | 7106 StringCharacterStreamCompare(Isolate::Current()->runtime_state(), x, y)); |
| 7107 return result; | 7107 return result; |
| 7108 } | 7108 } |
| 7109 | 7109 |
| 7110 | 7110 |
| 7111 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { | 7111 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { |
| 7112 NoHandleAllocation ha(isolate); | 7112 RequireNewHandleScope rnhs(isolate); |
| 7113 ASSERT(args.length() == 2); | 7113 ASSERT(args.length() == 2); |
| 7114 | 7114 |
| 7115 CONVERT_ARG_CHECKED(String, x, 0); | 7115 CONVERT_ARG_CHECKED(String, x, 0); |
| 7116 CONVERT_ARG_CHECKED(String, y, 1); | 7116 CONVERT_ARG_CHECKED(String, y, 1); |
| 7117 | 7117 |
| 7118 isolate->counters()->string_compare_runtime()->Increment(); | 7118 isolate->counters()->string_compare_runtime()->Increment(); |
| 7119 | 7119 |
| 7120 // A few fast case tests before we flatten. | 7120 // A few fast case tests before we flatten. |
| 7121 if (x == y) return Smi::FromInt(EQUAL); | 7121 if (x == y) return Smi::FromInt(EQUAL); |
| 7122 if (y->length() == 0) { | 7122 if (y->length() == 0) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 7137 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); | 7137 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); |
| 7138 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 7138 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 7139 } | 7139 } |
| 7140 | 7140 |
| 7141 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) | 7141 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) |
| 7142 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); | 7142 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); |
| 7143 } | 7143 } |
| 7144 | 7144 |
| 7145 | 7145 |
| 7146 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { | 7146 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { |
| 7147 NoHandleAllocation ha(isolate); | 7147 RequireNewHandleScope rnhs(isolate); |
| 7148 ASSERT(args.length() == 1); | 7148 ASSERT(args.length() == 1); |
| 7149 isolate->counters()->math_acos()->Increment(); | 7149 isolate->counters()->math_acos()->Increment(); |
| 7150 | 7150 |
| 7151 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7151 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7152 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); | 7152 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); |
| 7153 } | 7153 } |
| 7154 | 7154 |
| 7155 | 7155 |
| 7156 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { | 7156 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { |
| 7157 NoHandleAllocation ha(isolate); | 7157 RequireNewHandleScope rnhs(isolate); |
| 7158 ASSERT(args.length() == 1); | 7158 ASSERT(args.length() == 1); |
| 7159 isolate->counters()->math_asin()->Increment(); | 7159 isolate->counters()->math_asin()->Increment(); |
| 7160 | 7160 |
| 7161 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7161 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7162 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); | 7162 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); |
| 7163 } | 7163 } |
| 7164 | 7164 |
| 7165 | 7165 |
| 7166 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { | 7166 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { |
| 7167 NoHandleAllocation ha(isolate); | 7167 RequireNewHandleScope rnhs(isolate); |
| 7168 ASSERT(args.length() == 1); | 7168 ASSERT(args.length() == 1); |
| 7169 isolate->counters()->math_atan()->Increment(); | 7169 isolate->counters()->math_atan()->Increment(); |
| 7170 | 7170 |
| 7171 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7171 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7172 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); | 7172 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); |
| 7173 } | 7173 } |
| 7174 | 7174 |
| 7175 | 7175 |
| 7176 static const double kPiDividedBy4 = 0.78539816339744830962; | 7176 static const double kPiDividedBy4 = 0.78539816339744830962; |
| 7177 | 7177 |
| 7178 | 7178 |
| 7179 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { | 7179 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { |
| 7180 NoHandleAllocation ha(isolate); | 7180 RequireNewHandleScope rnhs(isolate); |
| 7181 ASSERT(args.length() == 2); | 7181 ASSERT(args.length() == 2); |
| 7182 isolate->counters()->math_atan2()->Increment(); | 7182 isolate->counters()->math_atan2()->Increment(); |
| 7183 | 7183 |
| 7184 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7184 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7185 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7185 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7186 double result; | 7186 double result; |
| 7187 if (std::isinf(x) && std::isinf(y)) { | 7187 if (std::isinf(x) && std::isinf(y)) { |
| 7188 // Make sure that the result in case of two infinite arguments | 7188 // Make sure that the result in case of two infinite arguments |
| 7189 // is a multiple of Pi / 4. The sign of the result is determined | 7189 // is a multiple of Pi / 4. The sign of the result is determined |
| 7190 // by the first argument (x) and the sign of the second argument | 7190 // by the first argument (x) and the sign of the second argument |
| 7191 // determines the multiplier: one or three. | 7191 // determines the multiplier: one or three. |
| 7192 int multiplier = (x < 0) ? -1 : 1; | 7192 int multiplier = (x < 0) ? -1 : 1; |
| 7193 if (y < 0) multiplier *= 3; | 7193 if (y < 0) multiplier *= 3; |
| 7194 result = multiplier * kPiDividedBy4; | 7194 result = multiplier * kPiDividedBy4; |
| 7195 } else { | 7195 } else { |
| 7196 result = atan2(x, y); | 7196 result = atan2(x, y); |
| 7197 } | 7197 } |
| 7198 return isolate->heap()->AllocateHeapNumber(result); | 7198 return isolate->heap()->AllocateHeapNumber(result); |
| 7199 } | 7199 } |
| 7200 | 7200 |
| 7201 | 7201 |
| 7202 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { | 7202 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { |
| 7203 NoHandleAllocation ha(isolate); | 7203 RequireNewHandleScope rnhs(isolate); |
| 7204 ASSERT(args.length() == 1); | 7204 ASSERT(args.length() == 1); |
| 7205 isolate->counters()->math_ceil()->Increment(); | 7205 isolate->counters()->math_ceil()->Increment(); |
| 7206 | 7206 |
| 7207 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7207 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7208 return isolate->heap()->NumberFromDouble(ceiling(x)); | 7208 return isolate->heap()->NumberFromDouble(ceiling(x)); |
| 7209 } | 7209 } |
| 7210 | 7210 |
| 7211 | 7211 |
| 7212 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { | 7212 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { |
| 7213 NoHandleAllocation ha(isolate); | 7213 RequireNewHandleScope rnhs(isolate); |
| 7214 ASSERT(args.length() == 1); | 7214 ASSERT(args.length() == 1); |
| 7215 isolate->counters()->math_cos()->Increment(); | 7215 isolate->counters()->math_cos()->Increment(); |
| 7216 | 7216 |
| 7217 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7217 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7218 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); | 7218 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); |
| 7219 } | 7219 } |
| 7220 | 7220 |
| 7221 | 7221 |
| 7222 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { | 7222 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { |
| 7223 NoHandleAllocation ha(isolate); | 7223 RequireNewHandleScope rnhs(isolate); |
| 7224 ASSERT(args.length() == 1); | 7224 ASSERT(args.length() == 1); |
| 7225 isolate->counters()->math_exp()->Increment(); | 7225 isolate->counters()->math_exp()->Increment(); |
| 7226 | 7226 |
| 7227 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7227 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7228 lazily_initialize_fast_exp(); | 7228 lazily_initialize_fast_exp(); |
| 7229 return isolate->heap()->NumberFromDouble(fast_exp(x)); | 7229 return isolate->heap()->NumberFromDouble(fast_exp(x)); |
| 7230 } | 7230 } |
| 7231 | 7231 |
| 7232 | 7232 |
| 7233 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { | 7233 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { |
| 7234 NoHandleAllocation ha(isolate); | 7234 RequireNewHandleScope rnhs(isolate); |
| 7235 ASSERT(args.length() == 1); | 7235 ASSERT(args.length() == 1); |
| 7236 isolate->counters()->math_floor()->Increment(); | 7236 isolate->counters()->math_floor()->Increment(); |
| 7237 | 7237 |
| 7238 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7238 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7239 return isolate->heap()->NumberFromDouble(floor(x)); | 7239 return isolate->heap()->NumberFromDouble(floor(x)); |
| 7240 } | 7240 } |
| 7241 | 7241 |
| 7242 | 7242 |
| 7243 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { | 7243 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { |
| 7244 NoHandleAllocation ha(isolate); | 7244 RequireNewHandleScope rnhs(isolate); |
| 7245 ASSERT(args.length() == 1); | 7245 ASSERT(args.length() == 1); |
| 7246 isolate->counters()->math_log()->Increment(); | 7246 isolate->counters()->math_log()->Increment(); |
| 7247 | 7247 |
| 7248 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7248 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7249 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); | 7249 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); |
| 7250 } | 7250 } |
| 7251 | 7251 |
| 7252 // Slow version of Math.pow. We check for fast paths for special cases. | 7252 // Slow version of Math.pow. We check for fast paths for special cases. |
| 7253 // Used if SSE2/VFP3 is not available. | 7253 // Used if SSE2/VFP3 is not available. |
| 7254 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { | 7254 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { |
| 7255 NoHandleAllocation ha(isolate); | 7255 RequireNewHandleScope rnhs(isolate); |
| 7256 ASSERT(args.length() == 2); | 7256 ASSERT(args.length() == 2); |
| 7257 isolate->counters()->math_pow()->Increment(); | 7257 isolate->counters()->math_pow()->Increment(); |
| 7258 | 7258 |
| 7259 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7259 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7260 | 7260 |
| 7261 // If the second argument is a smi, it is much faster to call the | 7261 // If the second argument is a smi, it is much faster to call the |
| 7262 // custom powi() function than the generic pow(). | 7262 // custom powi() function than the generic pow(). |
| 7263 if (args[1]->IsSmi()) { | 7263 if (args[1]->IsSmi()) { |
| 7264 int y = args.smi_at(1); | 7264 int y = args.smi_at(1); |
| 7265 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); | 7265 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); |
| 7266 } | 7266 } |
| 7267 | 7267 |
| 7268 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7268 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7269 double result = power_helper(x, y); | 7269 double result = power_helper(x, y); |
| 7270 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7270 if (std::isnan(result)) return isolate->heap()->nan_value(); |
| 7271 return isolate->heap()->AllocateHeapNumber(result); | 7271 return isolate->heap()->AllocateHeapNumber(result); |
| 7272 } | 7272 } |
| 7273 | 7273 |
| 7274 // Fast version of Math.pow if we know that y is not an integer and y is not | 7274 // Fast version of Math.pow if we know that y is not an integer and y is not |
| 7275 // -0.5 or 0.5. Used as slow case from full codegen. | 7275 // -0.5 or 0.5. Used as slow case from full codegen. |
| 7276 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { | 7276 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { |
| 7277 NoHandleAllocation ha(isolate); | 7277 RequireNewHandleScope rnhs(isolate); |
| 7278 ASSERT(args.length() == 2); | 7278 ASSERT(args.length() == 2); |
| 7279 isolate->counters()->math_pow()->Increment(); | 7279 isolate->counters()->math_pow()->Increment(); |
| 7280 | 7280 |
| 7281 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7281 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7282 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7282 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
| 7283 if (y == 0) { | 7283 if (y == 0) { |
| 7284 return Smi::FromInt(1); | 7284 return Smi::FromInt(1); |
| 7285 } else { | 7285 } else { |
| 7286 double result = power_double_double(x, y); | 7286 double result = power_double_double(x, y); |
| 7287 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7287 if (std::isnan(result)) return isolate->heap()->nan_value(); |
| 7288 return isolate->heap()->AllocateHeapNumber(result); | 7288 return isolate->heap()->AllocateHeapNumber(result); |
| 7289 } | 7289 } |
| 7290 } | 7290 } |
| 7291 | 7291 |
| 7292 | 7292 |
| 7293 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { | 7293 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { |
| 7294 NoHandleAllocation ha(isolate); | 7294 RequireNewHandleScope rnhs(isolate); |
| 7295 ASSERT(args.length() == 1); | 7295 ASSERT(args.length() == 1); |
| 7296 isolate->counters()->math_round()->Increment(); | 7296 isolate->counters()->math_round()->Increment(); |
| 7297 | 7297 |
| 7298 if (!args[0]->IsHeapNumber()) { | 7298 if (!args[0]->IsHeapNumber()) { |
| 7299 // Must be smi. Return the argument unchanged for all the other types | 7299 // Must be smi. Return the argument unchanged for all the other types |
| 7300 // to make fuzz-natives test happy. | 7300 // to make fuzz-natives test happy. |
| 7301 return args[0]; | 7301 return args[0]; |
| 7302 } | 7302 } |
| 7303 | 7303 |
| 7304 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); | 7304 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7327 } | 7327 } |
| 7328 | 7328 |
| 7329 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7329 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
| 7330 | 7330 |
| 7331 // Do not call NumberFromDouble() to avoid extra checks. | 7331 // Do not call NumberFromDouble() to avoid extra checks. |
| 7332 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); | 7332 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); |
| 7333 } | 7333 } |
| 7334 | 7334 |
| 7335 | 7335 |
| 7336 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { | 7336 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { |
| 7337 NoHandleAllocation ha(isolate); | 7337 RequireNewHandleScope rnhs(isolate); |
| 7338 ASSERT(args.length() == 1); | 7338 ASSERT(args.length() == 1); |
| 7339 isolate->counters()->math_sin()->Increment(); | 7339 isolate->counters()->math_sin()->Increment(); |
| 7340 | 7340 |
| 7341 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7341 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7342 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); | 7342 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); |
| 7343 } | 7343 } |
| 7344 | 7344 |
| 7345 | 7345 |
| 7346 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { | 7346 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { |
| 7347 NoHandleAllocation ha(isolate); | 7347 RequireNewHandleScope rnhs(isolate); |
| 7348 ASSERT(args.length() == 1); | 7348 ASSERT(args.length() == 1); |
| 7349 isolate->counters()->math_sqrt()->Increment(); | 7349 isolate->counters()->math_sqrt()->Increment(); |
| 7350 | 7350 |
| 7351 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7351 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7352 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); | 7352 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); |
| 7353 } | 7353 } |
| 7354 | 7354 |
| 7355 | 7355 |
| 7356 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { | 7356 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { |
| 7357 NoHandleAllocation ha(isolate); | 7357 RequireNewHandleScope rnhs(isolate); |
| 7358 ASSERT(args.length() == 1); | 7358 ASSERT(args.length() == 1); |
| 7359 isolate->counters()->math_tan()->Increment(); | 7359 isolate->counters()->math_tan()->Increment(); |
| 7360 | 7360 |
| 7361 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7361 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 7362 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); | 7362 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); |
| 7363 } | 7363 } |
| 7364 | 7364 |
| 7365 | 7365 |
| 7366 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 7366 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { |
| 7367 NoHandleAllocation ha(isolate); | 7367 RequireNewHandleScope rnhs(isolate); |
| 7368 ASSERT(args.length() == 2); | 7368 ASSERT(args.length() == 2); |
| 7369 | 7369 |
| 7370 CONVERT_SMI_ARG_CHECKED(year, 0); | 7370 CONVERT_SMI_ARG_CHECKED(year, 0); |
| 7371 CONVERT_SMI_ARG_CHECKED(month, 1); | 7371 CONVERT_SMI_ARG_CHECKED(month, 1); |
| 7372 | 7372 |
| 7373 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 7373 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
| 7374 } | 7374 } |
| 7375 | 7375 |
| 7376 | 7376 |
| 7377 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { | 7377 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7500 for (int i = 0; i < argument_count; ++i) { | 7500 for (int i = 0; i < argument_count; ++i) { |
| 7501 elements->set(i, *(parameters - i - 1)); | 7501 elements->set(i, *(parameters - i - 1)); |
| 7502 } | 7502 } |
| 7503 } | 7503 } |
| 7504 } | 7504 } |
| 7505 return *result; | 7505 return *result; |
| 7506 } | 7506 } |
| 7507 | 7507 |
| 7508 | 7508 |
| 7509 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStrictArgumentsFast) { | 7509 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStrictArgumentsFast) { |
| 7510 NoHandleAllocation ha(isolate); | 7510 RequireNewHandleScope rnhs(isolate); |
| 7511 ASSERT(args.length() == 3); | 7511 ASSERT(args.length() == 3); |
| 7512 | 7512 |
| 7513 JSFunction* callee = JSFunction::cast(args[0]); | 7513 JSFunction* callee = JSFunction::cast(args[0]); |
| 7514 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7514 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 7515 const int length = args.smi_at(2); | 7515 const int length = args.smi_at(2); |
| 7516 | 7516 |
| 7517 Object* result; | 7517 Object* result; |
| 7518 { MaybeObject* maybe_result = | 7518 { MaybeObject* maybe_result = |
| 7519 isolate->heap()->AllocateArgumentsObject(callee, length); | 7519 isolate->heap()->AllocateArgumentsObject(callee, length); |
| 7520 if (!maybe_result->ToObject(&result)) return maybe_result; | 7520 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 7521 } | 7521 } |
| 7522 // Allocate the elements if needed. | 7522 // Allocate the elements if needed. |
| 7523 if (length > 0) { | 7523 if (length > 0) { |
| 7524 // Allocate the fixed array. | 7524 // Allocate the fixed array. |
| 7525 Object* obj; | 7525 Object* obj; |
| 7526 { MaybeObject* maybe_obj = isolate->heap()->AllocateRawFixedArray(length); | 7526 { MaybeObject* maybe_obj = isolate->heap()->AllocateRawFixedArray(length); |
| 7527 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 7527 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 7528 } | 7528 } |
| 7529 | 7529 |
| 7530 AssertNoAllocation no_gc; | 7530 DisallowHeapAllocation no_gc; |
| 7531 FixedArray* array = reinterpret_cast<FixedArray*>(obj); | 7531 FixedArray* array = reinterpret_cast<FixedArray*>(obj); |
| 7532 array->set_map_no_write_barrier(isolate->heap()->fixed_array_map()); | 7532 array->set_map_no_write_barrier(isolate->heap()->fixed_array_map()); |
| 7533 array->set_length(length); | 7533 array->set_length(length); |
| 7534 | 7534 |
| 7535 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 7535 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 7536 for (int i = 0; i < length; i++) { | 7536 for (int i = 0; i < length; i++) { |
| 7537 array->set(i, *--parameters, mode); | 7537 array->set(i, *--parameters, mode); |
| 7538 } | 7538 } |
| 7539 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); | 7539 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); |
| 7540 } | 7540 } |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7943 private: | 7943 private: |
| 7944 JSFunction* function_; | 7944 JSFunction* function_; |
| 7945 bool has_activations_; | 7945 bool has_activations_; |
| 7946 }; | 7946 }; |
| 7947 | 7947 |
| 7948 | 7948 |
| 7949 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyStubFailure) { | 7949 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyStubFailure) { |
| 7950 HandleScope scope(isolate); | 7950 HandleScope scope(isolate); |
| 7951 ASSERT(args.length() == 0); | 7951 ASSERT(args.length() == 0); |
| 7952 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 7952 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 7953 ASSERT(isolate->heap()->IsAllocationAllowed()); | 7953 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 7954 delete deoptimizer; | 7954 delete deoptimizer; |
| 7955 return isolate->heap()->undefined_value(); | 7955 return isolate->heap()->undefined_value(); |
| 7956 } | 7956 } |
| 7957 | 7957 |
| 7958 | 7958 |
| 7959 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { | 7959 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { |
| 7960 HandleScope scope(isolate); | 7960 HandleScope scope(isolate); |
| 7961 ASSERT(args.length() == 1); | 7961 ASSERT(args.length() == 1); |
| 7962 RUNTIME_ASSERT(args[0]->IsSmi()); | 7962 RUNTIME_ASSERT(args[0]->IsSmi()); |
| 7963 Deoptimizer::BailoutType type = | 7963 Deoptimizer::BailoutType type = |
| 7964 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); | 7964 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); |
| 7965 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 7965 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 7966 ASSERT(isolate->heap()->IsAllocationAllowed()); | 7966 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 7967 | 7967 |
| 7968 ASSERT(deoptimizer->compiled_code_kind() == Code::OPTIMIZED_FUNCTION); | 7968 ASSERT(deoptimizer->compiled_code_kind() == Code::OPTIMIZED_FUNCTION); |
| 7969 | 7969 |
| 7970 // Make sure to materialize objects before causing any allocation. | 7970 // Make sure to materialize objects before causing any allocation. |
| 7971 JavaScriptFrameIterator it(isolate); | 7971 JavaScriptFrameIterator it(isolate); |
| 7972 deoptimizer->MaterializeHeapObjects(&it); | 7972 deoptimizer->MaterializeHeapObjects(&it); |
| 7973 delete deoptimizer; | 7973 delete deoptimizer; |
| 7974 | 7974 |
| 7975 JavaScriptFrame* frame = it.frame(); | 7975 JavaScriptFrame* frame = it.frame(); |
| 7976 RUNTIME_ASSERT(frame->function()->IsJSFunction()); | 7976 RUNTIME_ASSERT(frame->function()->IsJSFunction()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8017 // Evict optimized code for this function from the cache so that it doesn't | 8017 // Evict optimized code for this function from the cache so that it doesn't |
| 8018 // get used for new closures. | 8018 // get used for new closures. |
| 8019 function->shared()->EvictFromOptimizedCodeMap(*optimized_code, | 8019 function->shared()->EvictFromOptimizedCodeMap(*optimized_code, |
| 8020 "notify deoptimized"); | 8020 "notify deoptimized"); |
| 8021 | 8021 |
| 8022 return isolate->heap()->undefined_value(); | 8022 return isolate->heap()->undefined_value(); |
| 8023 } | 8023 } |
| 8024 | 8024 |
| 8025 | 8025 |
| 8026 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { | 8026 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { |
| 8027 NoHandleAllocation ha(isolate); | 8027 RequireNewHandleScope rnhs(isolate); |
| 8028 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8028 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8029 delete deoptimizer; | 8029 delete deoptimizer; |
| 8030 return isolate->heap()->undefined_value(); | 8030 return isolate->heap()->undefined_value(); |
| 8031 } | 8031 } |
| 8032 | 8032 |
| 8033 | 8033 |
| 8034 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { | 8034 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { |
| 8035 HandleScope scope(isolate); | 8035 HandleScope scope(isolate); |
| 8036 ASSERT(args.length() == 1); | 8036 ASSERT(args.length() == 1); |
| 8037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 8050 Code* unoptimized = function->shared()->code(); | 8050 Code* unoptimized = function->shared()->code(); |
| 8051 if (unoptimized->kind() == Code::FUNCTION) { | 8051 if (unoptimized->kind() == Code::FUNCTION) { |
| 8052 unoptimized->ClearInlineCaches(); | 8052 unoptimized->ClearInlineCaches(); |
| 8053 unoptimized->ClearTypeFeedbackCells(isolate->heap()); | 8053 unoptimized->ClearTypeFeedbackCells(isolate->heap()); |
| 8054 } | 8054 } |
| 8055 return isolate->heap()->undefined_value(); | 8055 return isolate->heap()->undefined_value(); |
| 8056 } | 8056 } |
| 8057 | 8057 |
| 8058 | 8058 |
| 8059 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { | 8059 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { |
| 8060 NoHandleAllocation ha(isolate); | 8060 RequireNewHandleScope rnhs(isolate); |
| 8061 #if defined(USE_SIMULATOR) | 8061 #if defined(USE_SIMULATOR) |
| 8062 return isolate->heap()->true_value(); | 8062 return isolate->heap()->true_value(); |
| 8063 #else | 8063 #else |
| 8064 return isolate->heap()->false_value(); | 8064 return isolate->heap()->false_value(); |
| 8065 #endif | 8065 #endif |
| 8066 } | 8066 } |
| 8067 | 8067 |
| 8068 | 8068 |
| 8069 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { | 8069 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { |
| 8070 HandleScope scope(isolate); | 8070 HandleScope scope(isolate); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8249 } else { | 8249 } else { |
| 8250 if (function->IsMarkedForLazyRecompilation()) { | 8250 if (function->IsMarkedForLazyRecompilation()) { |
| 8251 function->ReplaceCode(function->shared()->code()); | 8251 function->ReplaceCode(function->shared()->code()); |
| 8252 } | 8252 } |
| 8253 return Smi::FromInt(-1); | 8253 return Smi::FromInt(-1); |
| 8254 } | 8254 } |
| 8255 } | 8255 } |
| 8256 | 8256 |
| 8257 | 8257 |
| 8258 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { | 8258 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { |
| 8259 NoHandleAllocation ha(isolate); | 8259 RequireNewHandleScope rnhs(isolate); |
| 8260 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8260 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
| 8261 return isolate->heap()->undefined_value(); | 8261 return isolate->heap()->undefined_value(); |
| 8262 } | 8262 } |
| 8263 | 8263 |
| 8264 | 8264 |
| 8265 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) { | 8265 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) { |
| 8266 NoHandleAllocation ha(isolate); | 8266 RequireNewHandleScope rnhs(isolate); |
| 8267 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8267 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
| 8268 return isolate->heap()->nan_value(); | 8268 return isolate->heap()->nan_value(); |
| 8269 } | 8269 } |
| 8270 | 8270 |
| 8271 | 8271 |
| 8272 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { | 8272 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { |
| 8273 HandleScope scope(isolate); | 8273 HandleScope scope(isolate); |
| 8274 ASSERT(args.length() >= 2); | 8274 ASSERT(args.length() >= 2); |
| 8275 int argc = args.length() - 2; | 8275 int argc = args.length() - 2; |
| 8276 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); | 8276 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8350 | 8350 |
| 8351 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { | 8351 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { |
| 8352 HandleScope scope(isolate); | 8352 HandleScope scope(isolate); |
| 8353 ASSERT(args.length() == 1); | 8353 ASSERT(args.length() == 1); |
| 8354 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 8354 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
| 8355 return *Execution::GetConstructorDelegate(args.at<Object>(0)); | 8355 return *Execution::GetConstructorDelegate(args.at<Object>(0)); |
| 8356 } | 8356 } |
| 8357 | 8357 |
| 8358 | 8358 |
| 8359 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) { | 8359 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewGlobalContext) { |
| 8360 NoHandleAllocation ha(isolate); | 8360 RequireNewHandleScope rnhs(isolate); |
| 8361 ASSERT(args.length() == 2); | 8361 ASSERT(args.length() == 2); |
| 8362 | 8362 |
| 8363 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8363 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8364 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); | 8364 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); |
| 8365 Context* result; | 8365 Context* result; |
| 8366 MaybeObject* maybe_result = | 8366 MaybeObject* maybe_result = |
| 8367 isolate->heap()->AllocateGlobalContext(function, scope_info); | 8367 isolate->heap()->AllocateGlobalContext(function, scope_info); |
| 8368 if (!maybe_result->To(&result)) return maybe_result; | 8368 if (!maybe_result->To(&result)) return maybe_result; |
| 8369 | 8369 |
| 8370 ASSERT(function->context() == isolate->context()); | 8370 ASSERT(function->context() == isolate->context()); |
| 8371 ASSERT(function->context()->global_object() == result->global_object()); | 8371 ASSERT(function->context()->global_object() == result->global_object()); |
| 8372 isolate->set_context(result); | 8372 isolate->set_context(result); |
| 8373 result->global_object()->set_global_context(result); | 8373 result->global_object()->set_global_context(result); |
| 8374 | 8374 |
| 8375 return result; // non-failure | 8375 return result; // non-failure |
| 8376 } | 8376 } |
| 8377 | 8377 |
| 8378 | 8378 |
| 8379 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { | 8379 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { |
| 8380 NoHandleAllocation ha(isolate); | 8380 RequireNewHandleScope rnhs(isolate); |
| 8381 ASSERT(args.length() == 1); | 8381 ASSERT(args.length() == 1); |
| 8382 | 8382 |
| 8383 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8383 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 8384 int length = function->shared()->scope_info()->ContextLength(); | 8384 int length = function->shared()->scope_info()->ContextLength(); |
| 8385 Context* result; | 8385 Context* result; |
| 8386 MaybeObject* maybe_result = | 8386 MaybeObject* maybe_result = |
| 8387 isolate->heap()->AllocateFunctionContext(length, function); | 8387 isolate->heap()->AllocateFunctionContext(length, function); |
| 8388 if (!maybe_result->To(&result)) return maybe_result; | 8388 if (!maybe_result->To(&result)) return maybe_result; |
| 8389 | 8389 |
| 8390 isolate->set_context(result); | 8390 isolate->set_context(result); |
| 8391 | 8391 |
| 8392 return result; // non-failure | 8392 return result; // non-failure |
| 8393 } | 8393 } |
| 8394 | 8394 |
| 8395 | 8395 |
| 8396 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { | 8396 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { |
| 8397 NoHandleAllocation ha(isolate); | 8397 RequireNewHandleScope rnhs(isolate); |
| 8398 ASSERT(args.length() == 2); | 8398 ASSERT(args.length() == 2); |
| 8399 JSObject* extension_object; | 8399 JSObject* extension_object; |
| 8400 if (args[0]->IsJSObject()) { | 8400 if (args[0]->IsJSObject()) { |
| 8401 extension_object = JSObject::cast(args[0]); | 8401 extension_object = JSObject::cast(args[0]); |
| 8402 } else { | 8402 } else { |
| 8403 // Convert the object to a proper JavaScript object. | 8403 // Convert the object to a proper JavaScript object. |
| 8404 MaybeObject* maybe_js_object = args[0]->ToObject(); | 8404 MaybeObject* maybe_js_object = args[0]->ToObject(); |
| 8405 if (!maybe_js_object->To(&extension_object)) { | 8405 if (!maybe_js_object->To(&extension_object)) { |
| 8406 if (Failure::cast(maybe_js_object)->IsInternalError()) { | 8406 if (Failure::cast(maybe_js_object)->IsInternalError()) { |
| 8407 HandleScope scope(isolate); | 8407 HandleScope scope(isolate); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 8431 isolate->heap()->AllocateWithContext(function, | 8431 isolate->heap()->AllocateWithContext(function, |
| 8432 isolate->context(), | 8432 isolate->context(), |
| 8433 extension_object); | 8433 extension_object); |
| 8434 if (!maybe_context->To(&context)) return maybe_context; | 8434 if (!maybe_context->To(&context)) return maybe_context; |
| 8435 isolate->set_context(context); | 8435 isolate->set_context(context); |
| 8436 return context; | 8436 return context; |
| 8437 } | 8437 } |
| 8438 | 8438 |
| 8439 | 8439 |
| 8440 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { | 8440 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { |
| 8441 NoHandleAllocation ha(isolate); | 8441 RequireNewHandleScope rnhs(isolate); |
| 8442 ASSERT(args.length() == 3); | 8442 ASSERT(args.length() == 3); |
| 8443 String* name = String::cast(args[0]); | 8443 String* name = String::cast(args[0]); |
| 8444 Object* thrown_object = args[1]; | 8444 Object* thrown_object = args[1]; |
| 8445 JSFunction* function; | 8445 JSFunction* function; |
| 8446 if (args[2]->IsSmi()) { | 8446 if (args[2]->IsSmi()) { |
| 8447 // A smi sentinel indicates a context nested inside global code rather | 8447 // A smi sentinel indicates a context nested inside global code rather |
| 8448 // than some function. There is a canonical empty function that can be | 8448 // than some function. There is a canonical empty function that can be |
| 8449 // gotten from the native context. | 8449 // gotten from the native context. |
| 8450 function = isolate->context()->native_context()->closure(); | 8450 function = isolate->context()->native_context()->closure(); |
| 8451 } else { | 8451 } else { |
| 8452 function = JSFunction::cast(args[2]); | 8452 function = JSFunction::cast(args[2]); |
| 8453 } | 8453 } |
| 8454 Context* context; | 8454 Context* context; |
| 8455 MaybeObject* maybe_context = | 8455 MaybeObject* maybe_context = |
| 8456 isolate->heap()->AllocateCatchContext(function, | 8456 isolate->heap()->AllocateCatchContext(function, |
| 8457 isolate->context(), | 8457 isolate->context(), |
| 8458 name, | 8458 name, |
| 8459 thrown_object); | 8459 thrown_object); |
| 8460 if (!maybe_context->To(&context)) return maybe_context; | 8460 if (!maybe_context->To(&context)) return maybe_context; |
| 8461 isolate->set_context(context); | 8461 isolate->set_context(context); |
| 8462 return context; | 8462 return context; |
| 8463 } | 8463 } |
| 8464 | 8464 |
| 8465 | 8465 |
| 8466 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { | 8466 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushBlockContext) { |
| 8467 NoHandleAllocation ha(isolate); | 8467 RequireNewHandleScope rnhs(isolate); |
| 8468 ASSERT(args.length() == 2); | 8468 ASSERT(args.length() == 2); |
| 8469 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); | 8469 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); |
| 8470 JSFunction* function; | 8470 JSFunction* function; |
| 8471 if (args[1]->IsSmi()) { | 8471 if (args[1]->IsSmi()) { |
| 8472 // A smi sentinel indicates a context nested inside global code rather | 8472 // A smi sentinel indicates a context nested inside global code rather |
| 8473 // than some function. There is a canonical empty function that can be | 8473 // than some function. There is a canonical empty function that can be |
| 8474 // gotten from the native context. | 8474 // gotten from the native context. |
| 8475 function = isolate->context()->native_context()->closure(); | 8475 function = isolate->context()->native_context()->closure(); |
| 8476 } else { | 8476 } else { |
| 8477 function = JSFunction::cast(args[1]); | 8477 function = JSFunction::cast(args[1]); |
| 8478 } | 8478 } |
| 8479 Context* context; | 8479 Context* context; |
| 8480 MaybeObject* maybe_context = | 8480 MaybeObject* maybe_context = |
| 8481 isolate->heap()->AllocateBlockContext(function, | 8481 isolate->heap()->AllocateBlockContext(function, |
| 8482 isolate->context(), | 8482 isolate->context(), |
| 8483 scope_info); | 8483 scope_info); |
| 8484 if (!maybe_context->To(&context)) return maybe_context; | 8484 if (!maybe_context->To(&context)) return maybe_context; |
| 8485 isolate->set_context(context); | 8485 isolate->set_context(context); |
| 8486 return context; | 8486 return context; |
| 8487 } | 8487 } |
| 8488 | 8488 |
| 8489 | 8489 |
| 8490 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { | 8490 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { |
| 8491 NoHandleAllocation ha(isolate); | 8491 RequireNewHandleScope rnhs(isolate); |
| 8492 ASSERT(args.length() == 1); | 8492 ASSERT(args.length() == 1); |
| 8493 Object* obj = args[0]; | 8493 Object* obj = args[0]; |
| 8494 return isolate->heap()->ToBoolean(obj->IsJSModule()); | 8494 return isolate->heap()->ToBoolean(obj->IsJSModule()); |
| 8495 } | 8495 } |
| 8496 | 8496 |
| 8497 | 8497 |
| 8498 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) { | 8498 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushModuleContext) { |
| 8499 NoHandleAllocation ha(isolate); | 8499 RequireNewHandleScope rnhs(isolate); |
| 8500 ASSERT(args.length() == 2); | 8500 ASSERT(args.length() == 2); |
| 8501 CONVERT_SMI_ARG_CHECKED(index, 0); | 8501 CONVERT_SMI_ARG_CHECKED(index, 0); |
| 8502 | 8502 |
| 8503 if (!args[1]->IsScopeInfo()) { | 8503 if (!args[1]->IsScopeInfo()) { |
| 8504 // Module already initialized. Find hosting context and retrieve context. | 8504 // Module already initialized. Find hosting context and retrieve context. |
| 8505 Context* host = Context::cast(isolate->context())->global_context(); | 8505 Context* host = Context::cast(isolate->context())->global_context(); |
| 8506 Context* context = Context::cast(host->get(index)); | 8506 Context* context = Context::cast(host->get(index)); |
| 8507 ASSERT(context->previous() == isolate->context()); | 8507 ASSERT(context->previous() == isolate->context()); |
| 8508 isolate->set_context(context); | 8508 isolate->set_context(context); |
| 8509 return context; | 8509 return context; |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8873 | 8873 |
| 8874 RUNTIME_FUNCTION(MaybeObject*, Runtime_ReThrow) { | 8874 RUNTIME_FUNCTION(MaybeObject*, Runtime_ReThrow) { |
| 8875 HandleScope scope(isolate); | 8875 HandleScope scope(isolate); |
| 8876 ASSERT(args.length() == 1); | 8876 ASSERT(args.length() == 1); |
| 8877 | 8877 |
| 8878 return isolate->ReThrow(args[0]); | 8878 return isolate->ReThrow(args[0]); |
| 8879 } | 8879 } |
| 8880 | 8880 |
| 8881 | 8881 |
| 8882 RUNTIME_FUNCTION(MaybeObject*, Runtime_PromoteScheduledException) { | 8882 RUNTIME_FUNCTION(MaybeObject*, Runtime_PromoteScheduledException) { |
| 8883 NoHandleAllocation ha(isolate); | 8883 RequireNewHandleScope rnhs(isolate); |
| 8884 ASSERT_EQ(0, args.length()); | 8884 ASSERT_EQ(0, args.length()); |
| 8885 return isolate->PromoteScheduledException(); | 8885 return isolate->PromoteScheduledException(); |
| 8886 } | 8886 } |
| 8887 | 8887 |
| 8888 | 8888 |
| 8889 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowReferenceError) { | 8889 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowReferenceError) { |
| 8890 HandleScope scope(isolate); | 8890 HandleScope scope(isolate); |
| 8891 ASSERT(args.length() == 1); | 8891 ASSERT(args.length() == 1); |
| 8892 | 8892 |
| 8893 Handle<Object> name(args[0], isolate); | 8893 Handle<Object> name(args[0], isolate); |
| 8894 Handle<Object> reference_error = | 8894 Handle<Object> reference_error = |
| 8895 isolate->factory()->NewReferenceError("not_defined", | 8895 isolate->factory()->NewReferenceError("not_defined", |
| 8896 HandleVector(&name, 1)); | 8896 HandleVector(&name, 1)); |
| 8897 return isolate->Throw(*reference_error); | 8897 return isolate->Throw(*reference_error); |
| 8898 } | 8898 } |
| 8899 | 8899 |
| 8900 | 8900 |
| 8901 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowNotDateError) { | 8901 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowNotDateError) { |
| 8902 HandleScope scope(isolate); | 8902 HandleScope scope(isolate); |
| 8903 ASSERT(args.length() == 0); | 8903 ASSERT(args.length() == 0); |
| 8904 return isolate->Throw(*isolate->factory()->NewTypeError( | 8904 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 8905 "not_date_object", HandleVector<Object>(NULL, 0))); | 8905 "not_date_object", HandleVector<Object>(NULL, 0))); |
| 8906 } | 8906 } |
| 8907 | 8907 |
| 8908 | 8908 |
| 8909 | 8909 |
| 8910 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { | 8910 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { |
| 8911 NoHandleAllocation ha(isolate); | 8911 RequireNewHandleScope rnhs(isolate); |
| 8912 ASSERT(args.length() == 0); | 8912 ASSERT(args.length() == 0); |
| 8913 | 8913 |
| 8914 // First check if this is a real stack overflow. | 8914 // First check if this is a real stack overflow. |
| 8915 if (isolate->stack_guard()->IsStackOverflow()) { | 8915 if (isolate->stack_guard()->IsStackOverflow()) { |
| 8916 NoHandleAllocation na(isolate); | 8916 RequireNewHandleScope rnhs(isolate); |
| 8917 return isolate->StackOverflow(); | 8917 return isolate->StackOverflow(); |
| 8918 } | 8918 } |
| 8919 | 8919 |
| 8920 return Execution::HandleStackGuardInterrupt(isolate); | 8920 return Execution::HandleStackGuardInterrupt(isolate); |
| 8921 } | 8921 } |
| 8922 | 8922 |
| 8923 | 8923 |
| 8924 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { | 8924 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { |
| 8925 NoHandleAllocation ha(isolate); | 8925 RequireNewHandleScope rnhs(isolate); |
| 8926 ASSERT(args.length() == 0); | 8926 ASSERT(args.length() == 0); |
| 8927 return Execution::HandleStackGuardInterrupt(isolate); | 8927 return Execution::HandleStackGuardInterrupt(isolate); |
| 8928 } | 8928 } |
| 8929 | 8929 |
| 8930 | 8930 |
| 8931 static int StackSize(Isolate* isolate) { | 8931 static int StackSize(Isolate* isolate) { |
| 8932 int n = 0; | 8932 int n = 0; |
| 8933 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; | 8933 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; |
| 8934 return n; | 8934 return n; |
| 8935 } | 8935 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 8951 } else { | 8951 } else { |
| 8952 // function result | 8952 // function result |
| 8953 PrintF("} -> "); | 8953 PrintF("} -> "); |
| 8954 result->ShortPrint(); | 8954 result->ShortPrint(); |
| 8955 PrintF("\n"); | 8955 PrintF("\n"); |
| 8956 } | 8956 } |
| 8957 } | 8957 } |
| 8958 | 8958 |
| 8959 | 8959 |
| 8960 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { | 8960 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { |
| 8961 NoHandleAllocation ha(isolate); | 8961 RequireNewHandleScope rnhs(isolate); |
| 8962 ASSERT(args.length() == 0); | 8962 ASSERT(args.length() == 0); |
| 8963 PrintTransition(isolate, NULL); | 8963 PrintTransition(isolate, NULL); |
| 8964 return isolate->heap()->undefined_value(); | 8964 return isolate->heap()->undefined_value(); |
| 8965 } | 8965 } |
| 8966 | 8966 |
| 8967 | 8967 |
| 8968 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { | 8968 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { |
| 8969 NoHandleAllocation ha(isolate); | 8969 RequireNewHandleScope rnhs(isolate); |
| 8970 PrintTransition(isolate, args[0]); | 8970 PrintTransition(isolate, args[0]); |
| 8971 return args[0]; // return TOS | 8971 return args[0]; // return TOS |
| 8972 } | 8972 } |
| 8973 | 8973 |
| 8974 | 8974 |
| 8975 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { | 8975 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { |
| 8976 NoHandleAllocation ha(isolate); | 8976 RequireNewHandleScope rnhs(isolate); |
| 8977 ASSERT(args.length() == 1); | 8977 ASSERT(args.length() == 1); |
| 8978 | 8978 |
| 8979 #ifdef DEBUG | 8979 #ifdef DEBUG |
| 8980 if (args[0]->IsString()) { | 8980 if (args[0]->IsString()) { |
| 8981 // If we have a string, assume it's a code "marker" | 8981 // If we have a string, assume it's a code "marker" |
| 8982 // and print some interesting cpu debugging info. | 8982 // and print some interesting cpu debugging info. |
| 8983 JavaScriptFrameIterator it(isolate); | 8983 JavaScriptFrameIterator it(isolate); |
| 8984 JavaScriptFrame* frame = it.frame(); | 8984 JavaScriptFrame* frame = it.frame(); |
| 8985 PrintF("fp = %p, sp = %p, caller_sp = %p: ", | 8985 PrintF("fp = %p, sp = %p, caller_sp = %p: ", |
| 8986 frame->fp(), frame->sp(), frame->caller_sp()); | 8986 frame->fp(), frame->sp(), frame->caller_sp()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8997 args[0]->ShortPrint(); | 8997 args[0]->ShortPrint(); |
| 8998 #endif | 8998 #endif |
| 8999 PrintF("\n"); | 8999 PrintF("\n"); |
| 9000 Flush(); | 9000 Flush(); |
| 9001 | 9001 |
| 9002 return args[0]; // return TOS | 9002 return args[0]; // return TOS |
| 9003 } | 9003 } |
| 9004 | 9004 |
| 9005 | 9005 |
| 9006 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { | 9006 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { |
| 9007 NoHandleAllocation ha(isolate); | 9007 RequireNewHandleScope rnhs(isolate); |
| 9008 ASSERT(args.length() == 0); | 9008 ASSERT(args.length() == 0); |
| 9009 isolate->PrintStack(stdout); | 9009 isolate->PrintStack(stdout); |
| 9010 return isolate->heap()->undefined_value(); | 9010 return isolate->heap()->undefined_value(); |
| 9011 } | 9011 } |
| 9012 | 9012 |
| 9013 | 9013 |
| 9014 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { | 9014 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { |
| 9015 NoHandleAllocation ha(isolate); | 9015 RequireNewHandleScope rnhs(isolate); |
| 9016 ASSERT(args.length() == 0); | 9016 ASSERT(args.length() == 0); |
| 9017 | 9017 |
| 9018 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9018 // According to ECMA-262, section 15.9.1, page 117, the precision of |
| 9019 // the number in a Date object representing a particular instant in | 9019 // the number in a Date object representing a particular instant in |
| 9020 // time is milliseconds. Therefore, we floor the result of getting | 9020 // time is milliseconds. Therefore, we floor the result of getting |
| 9021 // the OS time. | 9021 // the OS time. |
| 9022 double millis = floor(OS::TimeCurrentMillis()); | 9022 double millis = floor(OS::TimeCurrentMillis()); |
| 9023 return isolate->heap()->NumberFromDouble(millis); | 9023 return isolate->heap()->NumberFromDouble(millis); |
| 9024 } | 9024 } |
| 9025 | 9025 |
| 9026 | 9026 |
| 9027 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { | 9027 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { |
| 9028 HandleScope scope(isolate); | 9028 HandleScope scope(isolate); |
| 9029 ASSERT(args.length() == 2); | 9029 ASSERT(args.length() == 2); |
| 9030 | 9030 |
| 9031 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 9031 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
| 9032 FlattenString(str); | 9032 FlattenString(str); |
| 9033 | 9033 |
| 9034 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); | 9034 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); |
| 9035 | 9035 |
| 9036 MaybeObject* maybe_result_array = | 9036 MaybeObject* maybe_result_array = |
| 9037 output->EnsureCanContainHeapObjectElements(); | 9037 output->EnsureCanContainHeapObjectElements(); |
| 9038 if (maybe_result_array->IsFailure()) return maybe_result_array; | 9038 if (maybe_result_array->IsFailure()) return maybe_result_array; |
| 9039 RUNTIME_ASSERT(output->HasFastObjectElements()); | 9039 RUNTIME_ASSERT(output->HasFastObjectElements()); |
| 9040 | 9040 |
| 9041 AssertNoAllocation no_allocation; | 9041 DisallowHeapAllocation no_gc; |
| 9042 | 9042 |
| 9043 FixedArray* output_array = FixedArray::cast(output->elements()); | 9043 FixedArray* output_array = FixedArray::cast(output->elements()); |
| 9044 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); | 9044 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); |
| 9045 bool result; | 9045 bool result; |
| 9046 String::FlatContent str_content = str->GetFlatContent(); | 9046 String::FlatContent str_content = str->GetFlatContent(); |
| 9047 if (str_content.IsAscii()) { | 9047 if (str_content.IsAscii()) { |
| 9048 result = DateParser::Parse(str_content.ToOneByteVector(), | 9048 result = DateParser::Parse(str_content.ToOneByteVector(), |
| 9049 output_array, | 9049 output_array, |
| 9050 isolate->unicode_cache()); | 9050 isolate->unicode_cache()); |
| 9051 } else { | 9051 } else { |
| 9052 ASSERT(str_content.IsTwoByte()); | 9052 ASSERT(str_content.IsTwoByte()); |
| 9053 result = DateParser::Parse(str_content.ToUC16Vector(), | 9053 result = DateParser::Parse(str_content.ToUC16Vector(), |
| 9054 output_array, | 9054 output_array, |
| 9055 isolate->unicode_cache()); | 9055 isolate->unicode_cache()); |
| 9056 } | 9056 } |
| 9057 | 9057 |
| 9058 if (result) { | 9058 if (result) { |
| 9059 return *output; | 9059 return *output; |
| 9060 } else { | 9060 } else { |
| 9061 return isolate->heap()->null_value(); | 9061 return isolate->heap()->null_value(); |
| 9062 } | 9062 } |
| 9063 } | 9063 } |
| 9064 | 9064 |
| 9065 | 9065 |
| 9066 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 9066 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { |
| 9067 NoHandleAllocation ha(isolate); | 9067 RequireNewHandleScope rnhs(isolate); |
| 9068 ASSERT(args.length() == 1); | 9068 ASSERT(args.length() == 1); |
| 9069 | 9069 |
| 9070 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9070 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9071 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); | 9071 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); |
| 9072 const char* zone = OS::LocalTimezone(static_cast<double>(time)); | 9072 const char* zone = OS::LocalTimezone(static_cast<double>(time)); |
| 9073 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); | 9073 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); |
| 9074 } | 9074 } |
| 9075 | 9075 |
| 9076 | 9076 |
| 9077 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9077 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { |
| 9078 NoHandleAllocation ha(isolate); | 9078 RequireNewHandleScope rnhs(isolate); |
| 9079 ASSERT(args.length() == 1); | 9079 ASSERT(args.length() == 1); |
| 9080 | 9080 |
| 9081 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9081 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
| 9082 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9082 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
| 9083 | 9083 |
| 9084 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); | 9084 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); |
| 9085 } | 9085 } |
| 9086 | 9086 |
| 9087 | 9087 |
| 9088 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { | 9088 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { |
| 9089 NoHandleAllocation ha(isolate); | 9089 RequireNewHandleScope rnhs(isolate); |
| 9090 ASSERT(args.length() == 1); | 9090 ASSERT(args.length() == 1); |
| 9091 Object* global = args[0]; | 9091 Object* global = args[0]; |
| 9092 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9092 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
| 9093 return JSGlobalObject::cast(global)->global_receiver(); | 9093 return JSGlobalObject::cast(global)->global_receiver(); |
| 9094 } | 9094 } |
| 9095 | 9095 |
| 9096 | 9096 |
| 9097 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9097 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
| 9098 HandleScope scope(isolate); | 9098 HandleScope scope(isolate); |
| 9099 ASSERT_EQ(1, args.length()); | 9099 ASSERT_EQ(1, args.length()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9228 args.smi_at(4)); | 9228 args.smi_at(4)); |
| 9229 } | 9229 } |
| 9230 | 9230 |
| 9231 | 9231 |
| 9232 static MaybeObject* Allocate(Isolate* isolate, | 9232 static MaybeObject* Allocate(Isolate* isolate, |
| 9233 int size, | 9233 int size, |
| 9234 AllocationSpace space) { | 9234 AllocationSpace space) { |
| 9235 // Allocate a block of memory in the given space (filled with a filler). | 9235 // Allocate a block of memory in the given space (filled with a filler). |
| 9236 // Use as fallback for allocation in generated code when the space | 9236 // Use as fallback for allocation in generated code when the space |
| 9237 // is full. | 9237 // is full. |
| 9238 NoHandleAllocation ha(isolate); | 9238 RequireNewHandleScope rnhs(isolate); |
| 9239 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9239 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
| 9240 RUNTIME_ASSERT(size > 0); | 9240 RUNTIME_ASSERT(size > 0); |
| 9241 Heap* heap = isolate->heap(); | 9241 Heap* heap = isolate->heap(); |
| 9242 RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize()); | 9242 RUNTIME_ASSERT(size <= heap->MaxRegularSpaceAllocationSize()); |
| 9243 Object* allocation; | 9243 Object* allocation; |
| 9244 { MaybeObject* maybe_allocation; | 9244 { MaybeObject* maybe_allocation; |
| 9245 if (space == NEW_SPACE) { | 9245 if (space == NEW_SPACE) { |
| 9246 maybe_allocation = heap->new_space()->AllocateRaw(size); | 9246 maybe_allocation = heap->new_space()->AllocateRaw(size); |
| 9247 } else { | 9247 } else { |
| 9248 ASSERT(space == OLD_POINTER_SPACE || space == OLD_DATA_SPACE); | 9248 ASSERT(space == OLD_POINTER_SPACE || space == OLD_DATA_SPACE); |
| 9249 maybe_allocation = heap->paged_space(space)->AllocateRaw(size); | 9249 maybe_allocation = heap->paged_space(space)->AllocateRaw(size); |
| 9250 } | 9250 } |
| 9251 if (maybe_allocation->ToObject(&allocation)) { | 9251 if (maybe_allocation->ToObject(&allocation)) { |
| 9252 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size); | 9252 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size); |
| 9253 } | 9253 } |
| 9254 return maybe_allocation; | 9254 return maybe_allocation; |
| 9255 } | 9255 } |
| 9256 } | 9256 } |
| 9257 | 9257 |
| 9258 | 9258 |
| 9259 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { | 9259 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { |
| 9260 NoHandleAllocation ha(isolate); | 9260 RequireNewHandleScope rnhs(isolate); |
| 9261 ASSERT(args.length() == 1); | 9261 ASSERT(args.length() == 1); |
| 9262 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); | 9262 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); |
| 9263 return Allocate(isolate, size_smi->value(), NEW_SPACE); | 9263 return Allocate(isolate, size_smi->value(), NEW_SPACE); |
| 9264 } | 9264 } |
| 9265 | 9265 |
| 9266 | 9266 |
| 9267 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldPointerSpace) { | 9267 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldPointerSpace) { |
| 9268 NoHandleAllocation ha(isolate); | 9268 RequireNewHandleScope rnhs(isolate); |
| 9269 ASSERT(args.length() == 1); | 9269 ASSERT(args.length() == 1); |
| 9270 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); | 9270 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); |
| 9271 return Allocate(isolate, size_smi->value(), OLD_POINTER_SPACE); | 9271 return Allocate(isolate, size_smi->value(), OLD_POINTER_SPACE); |
| 9272 } | 9272 } |
| 9273 | 9273 |
| 9274 | 9274 |
| 9275 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldDataSpace) { | 9275 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldDataSpace) { |
| 9276 NoHandleAllocation ha(isolate); | 9276 RequireNewHandleScope rnhs(isolate); |
| 9277 ASSERT(args.length() == 1); | 9277 ASSERT(args.length() == 1); |
| 9278 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); | 9278 CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0); |
| 9279 return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE); | 9279 return Allocate(isolate, size_smi->value(), OLD_DATA_SPACE); |
| 9280 } | 9280 } |
| 9281 | 9281 |
| 9282 | 9282 |
| 9283 // Push an object unto an array of objects if it is not already in the | 9283 // Push an object unto an array of objects if it is not already in the |
| 9284 // array. Returns true if the element was pushed on the stack and | 9284 // array. Returns true if the element was pushed on the stack and |
| 9285 // false otherwise. | 9285 // false otherwise. |
| 9286 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { | 9286 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { |
| 9287 NoHandleAllocation ha(isolate); | 9287 RequireNewHandleScope rnhs(isolate); |
| 9288 ASSERT(args.length() == 2); | 9288 ASSERT(args.length() == 2); |
| 9289 CONVERT_ARG_CHECKED(JSArray, array, 0); | 9289 CONVERT_ARG_CHECKED(JSArray, array, 0); |
| 9290 CONVERT_ARG_CHECKED(JSReceiver, element, 1); | 9290 CONVERT_ARG_CHECKED(JSReceiver, element, 1); |
| 9291 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 9291 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
| 9292 int length = Smi::cast(array->length())->value(); | 9292 int length = Smi::cast(array->length())->value(); |
| 9293 FixedArray* elements = FixedArray::cast(array->elements()); | 9293 FixedArray* elements = FixedArray::cast(array->elements()); |
| 9294 for (int i = 0; i < length; i++) { | 9294 for (int i = 0; i < length; i++) { |
| 9295 if (elements->get(i) == element) return isolate->heap()->false_value(); | 9295 if (elements->get(i) == element) return isolate->heap()->false_value(); |
| 9296 } | 9296 } |
| 9297 Object* obj; | 9297 Object* obj; |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9994 *isolate->factory()->NewRangeError("invalid_array_length", | 9994 *isolate->factory()->NewRangeError("invalid_array_length", |
| 9995 HandleVector<Object>(NULL, 0))); | 9995 HandleVector<Object>(NULL, 0))); |
| 9996 } | 9996 } |
| 9997 return *visitor.ToArray(); | 9997 return *visitor.ToArray(); |
| 9998 } | 9998 } |
| 9999 | 9999 |
| 10000 | 10000 |
| 10001 // This will not allocate (flatten the string), but it may run | 10001 // This will not allocate (flatten the string), but it may run |
| 10002 // very slowly for very deeply nested ConsStrings. For debugging use only. | 10002 // very slowly for very deeply nested ConsStrings. For debugging use only. |
| 10003 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { | 10003 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { |
| 10004 NoHandleAllocation ha(isolate); | 10004 RequireNewHandleScope rnhs(isolate); |
| 10005 ASSERT(args.length() == 1); | 10005 ASSERT(args.length() == 1); |
| 10006 | 10006 |
| 10007 CONVERT_ARG_CHECKED(String, string, 0); | 10007 CONVERT_ARG_CHECKED(String, string, 0); |
| 10008 ConsStringIteratorOp op; | 10008 ConsStringIteratorOp op; |
| 10009 StringCharacterStream stream(string, &op); | 10009 StringCharacterStream stream(string, &op); |
| 10010 while (stream.HasMore()) { | 10010 while (stream.HasMore()) { |
| 10011 uint16_t character = stream.GetNext(); | 10011 uint16_t character = stream.GetNext(); |
| 10012 PrintF("%c", character); | 10012 PrintF("%c", character); |
| 10013 } | 10013 } |
| 10014 return string; | 10014 return string; |
| 10015 } | 10015 } |
| 10016 | 10016 |
| 10017 // Moves all own elements of an object, that are below a limit, to positions | 10017 // Moves all own elements of an object, that are below a limit, to positions |
| 10018 // starting at zero. All undefined values are placed after non-undefined values, | 10018 // starting at zero. All undefined values are placed after non-undefined values, |
| 10019 // and are followed by non-existing element. Does not change the length | 10019 // and are followed by non-existing element. Does not change the length |
| 10020 // property. | 10020 // property. |
| 10021 // Returns the number of non-undefined elements collected. | 10021 // Returns the number of non-undefined elements collected. |
| 10022 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { | 10022 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { |
| 10023 NoHandleAllocation ha(isolate); | 10023 RequireNewHandleScope rnhs(isolate); |
| 10024 ASSERT(args.length() == 2); | 10024 ASSERT(args.length() == 2); |
| 10025 CONVERT_ARG_CHECKED(JSObject, object, 0); | 10025 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 10026 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 10026 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
| 10027 return object->PrepareElementsForSort(limit); | 10027 return object->PrepareElementsForSort(limit); |
| 10028 } | 10028 } |
| 10029 | 10029 |
| 10030 | 10030 |
| 10031 // Move contents of argument 0 (an array) to argument 1 (an array) | 10031 // Move contents of argument 0 (an array) to argument 1 (an array) |
| 10032 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 10032 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { |
| 10033 NoHandleAllocation ha(isolate); | 10033 RequireNewHandleScope rnhs(isolate); |
| 10034 ASSERT(args.length() == 2); | 10034 ASSERT(args.length() == 2); |
| 10035 CONVERT_ARG_CHECKED(JSArray, from, 0); | 10035 CONVERT_ARG_CHECKED(JSArray, from, 0); |
| 10036 CONVERT_ARG_CHECKED(JSArray, to, 1); | 10036 CONVERT_ARG_CHECKED(JSArray, to, 1); |
| 10037 from->ValidateElements(); | 10037 from->ValidateElements(); |
| 10038 to->ValidateElements(); | 10038 to->ValidateElements(); |
| 10039 FixedArrayBase* new_elements = from->elements(); | 10039 FixedArrayBase* new_elements = from->elements(); |
| 10040 ElementsKind from_kind = from->GetElementsKind(); | 10040 ElementsKind from_kind = from->GetElementsKind(); |
| 10041 MaybeObject* maybe_new_map; | 10041 MaybeObject* maybe_new_map; |
| 10042 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind); | 10042 maybe_new_map = to->GetElementsTransitionMap(isolate, from_kind); |
| 10043 Object* new_map; | 10043 Object* new_map; |
| 10044 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 10044 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
| 10045 to->set_map_and_elements(Map::cast(new_map), new_elements); | 10045 to->set_map_and_elements(Map::cast(new_map), new_elements); |
| 10046 to->set_length(from->length()); | 10046 to->set_length(from->length()); |
| 10047 Object* obj; | 10047 Object* obj; |
| 10048 { MaybeObject* maybe_obj = from->ResetElements(); | 10048 { MaybeObject* maybe_obj = from->ResetElements(); |
| 10049 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 10049 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 10050 } | 10050 } |
| 10051 from->set_length(Smi::FromInt(0)); | 10051 from->set_length(Smi::FromInt(0)); |
| 10052 to->ValidateElements(); | 10052 to->ValidateElements(); |
| 10053 return to; | 10053 return to; |
| 10054 } | 10054 } |
| 10055 | 10055 |
| 10056 | 10056 |
| 10057 // How many elements does this object/array have? | 10057 // How many elements does this object/array have? |
| 10058 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { | 10058 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { |
| 10059 NoHandleAllocation ha(isolate); | 10059 RequireNewHandleScope rnhs(isolate); |
| 10060 ASSERT(args.length() == 1); | 10060 ASSERT(args.length() == 1); |
| 10061 CONVERT_ARG_CHECKED(JSObject, object, 0); | 10061 CONVERT_ARG_CHECKED(JSObject, object, 0); |
| 10062 HeapObject* elements = object->elements(); | 10062 HeapObject* elements = object->elements(); |
| 10063 if (elements->IsDictionary()) { | 10063 if (elements->IsDictionary()) { |
| 10064 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); | 10064 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); |
| 10065 return Smi::FromInt(result); | 10065 return Smi::FromInt(result); |
| 10066 } else if (object->IsJSArray()) { | 10066 } else if (object->IsJSArray()) { |
| 10067 return JSArray::cast(object)->length(); | 10067 return JSArray::cast(object)->length(); |
| 10068 } else { | 10068 } else { |
| 10069 return Smi::FromInt(FixedArray::cast(elements)->length()); | 10069 return Smi::FromInt(FixedArray::cast(elements)->length()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10108 } else { | 10108 } else { |
| 10109 ASSERT(array->HasFastSmiOrObjectElements() || | 10109 ASSERT(array->HasFastSmiOrObjectElements() || |
| 10110 array->HasFastDoubleElements()); | 10110 array->HasFastDoubleElements()); |
| 10111 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 10111 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
| 10112 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 10112 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
| 10113 } | 10113 } |
| 10114 } | 10114 } |
| 10115 | 10115 |
| 10116 | 10116 |
| 10117 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { | 10117 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { |
| 10118 NoHandleAllocation ha(isolate); | 10118 RequireNewHandleScope rnhs(isolate); |
| 10119 ASSERT(args.length() == 3); | 10119 ASSERT(args.length() == 3); |
| 10120 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 10120 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); |
| 10121 CONVERT_ARG_CHECKED(Name, name, 1); | 10121 CONVERT_ARG_CHECKED(Name, name, 1); |
| 10122 CONVERT_SMI_ARG_CHECKED(flag, 2); | 10122 CONVERT_SMI_ARG_CHECKED(flag, 2); |
| 10123 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; | 10123 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; |
| 10124 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); | 10124 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); |
| 10125 return JSObject::cast(receiver)->LookupAccessor(name, component); | 10125 return JSObject::cast(receiver)->LookupAccessor(name, component); |
| 10126 } | 10126 } |
| 10127 | 10127 |
| 10128 | 10128 |
| 10129 #ifdef ENABLE_DEBUGGER_SUPPORT | 10129 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 10130 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { | 10130 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { |
| 10131 NoHandleAllocation ha(isolate); | 10131 RequireNewHandleScope rnhs(isolate); |
| 10132 ASSERT(args.length() == 0); | 10132 ASSERT(args.length() == 0); |
| 10133 return Execution::DebugBreakHelper(); | 10133 return Execution::DebugBreakHelper(); |
| 10134 } | 10134 } |
| 10135 | 10135 |
| 10136 | 10136 |
| 10137 // Helper functions for wrapping and unwrapping stack frame ids. | 10137 // Helper functions for wrapping and unwrapping stack frame ids. |
| 10138 static Smi* WrapFrameId(StackFrame::Id id) { | 10138 static Smi* WrapFrameId(StackFrame::Id id) { |
| 10139 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); | 10139 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); |
| 10140 return Smi::FromInt(id >> 2); | 10140 return Smi::FromInt(id >> 2); |
| 10141 } | 10141 } |
| 10142 | 10142 |
| 10143 | 10143 |
| 10144 static StackFrame::Id UnwrapFrameId(int wrapped) { | 10144 static StackFrame::Id UnwrapFrameId(int wrapped) { |
| 10145 return static_cast<StackFrame::Id>(wrapped << 2); | 10145 return static_cast<StackFrame::Id>(wrapped << 2); |
| 10146 } | 10146 } |
| 10147 | 10147 |
| 10148 | 10148 |
| 10149 // Adds a JavaScript function as a debug event listener. | 10149 // Adds a JavaScript function as a debug event listener. |
| 10150 // args[0]: debug event listener function to set or null or undefined for | 10150 // args[0]: debug event listener function to set or null or undefined for |
| 10151 // clearing the event listener function | 10151 // clearing the event listener function |
| 10152 // args[1]: object supplied during callback | 10152 // args[1]: object supplied during callback |
| 10153 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { | 10153 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { |
| 10154 NoHandleAllocation ha(isolate); | 10154 RequireNewHandleScope rnhs(isolate); |
| 10155 ASSERT(args.length() == 2); | 10155 ASSERT(args.length() == 2); |
| 10156 RUNTIME_ASSERT(args[0]->IsJSFunction() || | 10156 RUNTIME_ASSERT(args[0]->IsJSFunction() || |
| 10157 args[0]->IsUndefined() || | 10157 args[0]->IsUndefined() || |
| 10158 args[0]->IsNull()); | 10158 args[0]->IsNull()); |
| 10159 Handle<Object> callback = args.at<Object>(0); | 10159 Handle<Object> callback = args.at<Object>(0); |
| 10160 Handle<Object> data = args.at<Object>(1); | 10160 Handle<Object> data = args.at<Object>(1); |
| 10161 isolate->debugger()->SetEventListener(callback, data); | 10161 isolate->debugger()->SetEventListener(callback, data); |
| 10162 | 10162 |
| 10163 return isolate->heap()->undefined_value(); | 10163 return isolate->heap()->undefined_value(); |
| 10164 } | 10164 } |
| 10165 | 10165 |
| 10166 | 10166 |
| 10167 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { | 10167 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { |
| 10168 NoHandleAllocation ha(isolate); | 10168 RequireNewHandleScope rnhs(isolate); |
| 10169 ASSERT(args.length() == 0); | 10169 ASSERT(args.length() == 0); |
| 10170 isolate->stack_guard()->DebugBreak(); | 10170 isolate->stack_guard()->DebugBreak(); |
| 10171 return isolate->heap()->undefined_value(); | 10171 return isolate->heap()->undefined_value(); |
| 10172 } | 10172 } |
| 10173 | 10173 |
| 10174 | 10174 |
| 10175 static MaybeObject* DebugLookupResultValue(Heap* heap, | 10175 static MaybeObject* DebugLookupResultValue(Heap* heap, |
| 10176 Object* receiver, | 10176 Object* receiver, |
| 10177 Name* name, | 10177 Name* name, |
| 10178 LookupResult* result, | 10178 LookupResult* result, |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10356 if (result.IsFound()) { | 10356 if (result.IsFound()) { |
| 10357 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); | 10357 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); |
| 10358 } | 10358 } |
| 10359 return isolate->heap()->undefined_value(); | 10359 return isolate->heap()->undefined_value(); |
| 10360 } | 10360 } |
| 10361 | 10361 |
| 10362 | 10362 |
| 10363 // Return the property type calculated from the property details. | 10363 // Return the property type calculated from the property details. |
| 10364 // args[0]: smi with property details. | 10364 // args[0]: smi with property details. |
| 10365 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { | 10365 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { |
| 10366 NoHandleAllocation ha(isolate); | 10366 RequireNewHandleScope rnhs(isolate); |
| 10367 ASSERT(args.length() == 1); | 10367 ASSERT(args.length() == 1); |
| 10368 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10368 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 10369 return Smi::FromInt(static_cast<int>(details.type())); | 10369 return Smi::FromInt(static_cast<int>(details.type())); |
| 10370 } | 10370 } |
| 10371 | 10371 |
| 10372 | 10372 |
| 10373 // Return the property attribute calculated from the property details. | 10373 // Return the property attribute calculated from the property details. |
| 10374 // args[0]: smi with property details. | 10374 // args[0]: smi with property details. |
| 10375 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { | 10375 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { |
| 10376 NoHandleAllocation ha(isolate); | 10376 RequireNewHandleScope rnhs(isolate); |
| 10377 ASSERT(args.length() == 1); | 10377 ASSERT(args.length() == 1); |
| 10378 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10378 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 10379 return Smi::FromInt(static_cast<int>(details.attributes())); | 10379 return Smi::FromInt(static_cast<int>(details.attributes())); |
| 10380 } | 10380 } |
| 10381 | 10381 |
| 10382 | 10382 |
| 10383 // Return the property insertion index calculated from the property details. | 10383 // Return the property insertion index calculated from the property details. |
| 10384 // args[0]: smi with property details. | 10384 // args[0]: smi with property details. |
| 10385 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { | 10385 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { |
| 10386 NoHandleAllocation ha(isolate); | 10386 RequireNewHandleScope rnhs(isolate); |
| 10387 ASSERT(args.length() == 1); | 10387 ASSERT(args.length() == 1); |
| 10388 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10388 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 10389 // TODO(verwaest): Depends on the type of details. | 10389 // TODO(verwaest): Depends on the type of details. |
| 10390 return Smi::FromInt(details.dictionary_index()); | 10390 return Smi::FromInt(details.dictionary_index()); |
| 10391 } | 10391 } |
| 10392 | 10392 |
| 10393 | 10393 |
| 10394 // Return property value from named interceptor. | 10394 // Return property value from named interceptor. |
| 10395 // args[0]: object | 10395 // args[0]: object |
| 10396 // args[1]: property name | 10396 // args[1]: property name |
| (...skipping 17 matching lines...) Expand all Loading... |
| 10414 ASSERT(args.length() == 2); | 10414 ASSERT(args.length() == 2); |
| 10415 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10415 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 10416 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | 10416 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); |
| 10417 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); | 10417 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); |
| 10418 | 10418 |
| 10419 return obj->GetElementWithInterceptor(*obj, index); | 10419 return obj->GetElementWithInterceptor(*obj, index); |
| 10420 } | 10420 } |
| 10421 | 10421 |
| 10422 | 10422 |
| 10423 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { | 10423 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { |
| 10424 NoHandleAllocation ha(isolate); | 10424 RequireNewHandleScope rnhs(isolate); |
| 10425 ASSERT(args.length() >= 1); | 10425 ASSERT(args.length() >= 1); |
| 10426 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 10426 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 10427 // Check that the break id is valid. | 10427 // Check that the break id is valid. |
| 10428 if (isolate->debug()->break_id() == 0 || | 10428 if (isolate->debug()->break_id() == 0 || |
| 10429 break_id != isolate->debug()->break_id()) { | 10429 break_id != isolate->debug()->break_id()) { |
| 10430 return isolate->Throw( | 10430 return isolate->Throw( |
| 10431 isolate->heap()->illegal_execution_state_string()); | 10431 isolate->heap()->illegal_execution_state_string()); |
| 10432 } | 10432 } |
| 10433 | 10433 |
| 10434 return isolate->heap()->true_value(); | 10434 return isolate->heap()->true_value(); |
| (...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12315 } | 12315 } |
| 12316 | 12316 |
| 12317 | 12317 |
| 12318 // Helper function used by Runtime_DebugReferencedBy below. | 12318 // Helper function used by Runtime_DebugReferencedBy below. |
| 12319 static int DebugReferencedBy(HeapIterator* iterator, | 12319 static int DebugReferencedBy(HeapIterator* iterator, |
| 12320 JSObject* target, | 12320 JSObject* target, |
| 12321 Object* instance_filter, int max_references, | 12321 Object* instance_filter, int max_references, |
| 12322 FixedArray* instances, int instances_size, | 12322 FixedArray* instances, int instances_size, |
| 12323 JSFunction* arguments_function) { | 12323 JSFunction* arguments_function) { |
| 12324 Isolate* isolate = target->GetIsolate(); | 12324 Isolate* isolate = target->GetIsolate(); |
| 12325 NoHandleAllocation ha(isolate); | 12325 RequireNewHandleScope rnhs(isolate); |
| 12326 AssertNoAllocation no_alloc; | 12326 DisallowHeapAllocation no_allocation; |
| 12327 | 12327 |
| 12328 // Iterate the heap. | 12328 // Iterate the heap. |
| 12329 int count = 0; | 12329 int count = 0; |
| 12330 JSObject* last = NULL; | 12330 JSObject* last = NULL; |
| 12331 HeapObject* heap_obj = NULL; | 12331 HeapObject* heap_obj = NULL; |
| 12332 while (((heap_obj = iterator->next()) != NULL) && | 12332 while (((heap_obj = iterator->next()) != NULL) && |
| 12333 (max_references == 0 || count < max_references)) { | 12333 (max_references == 0 || count < max_references)) { |
| 12334 // Only look at all JSObjects. | 12334 // Only look at all JSObjects. |
| 12335 if (heap_obj->IsJSObject()) { | 12335 if (heap_obj->IsJSObject()) { |
| 12336 // Skip context extension objects and argument arrays as these are | 12336 // Skip context extension objects and argument arrays as these are |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12384 // Return the number of referencing objects found. | 12384 // Return the number of referencing objects found. |
| 12385 return count; | 12385 return count; |
| 12386 } | 12386 } |
| 12387 | 12387 |
| 12388 | 12388 |
| 12389 // Scan the heap for objects with direct references to an object | 12389 // Scan the heap for objects with direct references to an object |
| 12390 // args[0]: the object to find references to | 12390 // args[0]: the object to find references to |
| 12391 // args[1]: constructor function for instances to exclude (Mirror) | 12391 // args[1]: constructor function for instances to exclude (Mirror) |
| 12392 // args[2]: the the maximum number of objects to return | 12392 // args[2]: the the maximum number of objects to return |
| 12393 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugReferencedBy) { | 12393 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugReferencedBy) { |
| 12394 NoHandleAllocation ha(isolate); | 12394 RequireNewHandleScope rnhs(isolate); |
| 12395 ASSERT(args.length() == 3); | 12395 ASSERT(args.length() == 3); |
| 12396 | 12396 |
| 12397 // First perform a full GC in order to avoid references from dead objects. | 12397 // First perform a full GC in order to avoid references from dead objects. |
| 12398 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 12398 isolate->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
| 12399 "%DebugReferencedBy"); | 12399 "%DebugReferencedBy"); |
| 12400 // The heap iterator reserves the right to do a GC to make the heap iterable. | 12400 // The heap iterator reserves the right to do a GC to make the heap iterable. |
| 12401 // Due to the GC above we know it won't need to do that, but it seems cleaner | 12401 // Due to the GC above we know it won't need to do that, but it seems cleaner |
| 12402 // to get the heap iterator constructed before we start having unprotected | 12402 // to get the heap iterator constructed before we start having unprotected |
| 12403 // Object* locals that are not protected by handles. | 12403 // Object* locals that are not protected by handles. |
| 12404 | 12404 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12448 return JSArray::cast(result)->SetContent(instances); | 12448 return JSArray::cast(result)->SetContent(instances); |
| 12449 } | 12449 } |
| 12450 | 12450 |
| 12451 | 12451 |
| 12452 // Helper function used by Runtime_DebugConstructedBy below. | 12452 // Helper function used by Runtime_DebugConstructedBy below. |
| 12453 static int DebugConstructedBy(HeapIterator* iterator, | 12453 static int DebugConstructedBy(HeapIterator* iterator, |
| 12454 JSFunction* constructor, | 12454 JSFunction* constructor, |
| 12455 int max_references, | 12455 int max_references, |
| 12456 FixedArray* instances, | 12456 FixedArray* instances, |
| 12457 int instances_size) { | 12457 int instances_size) { |
| 12458 AssertNoAllocation no_alloc; | 12458 DisallowHeapAllocation no_allocation; |
| 12459 | 12459 |
| 12460 // Iterate the heap. | 12460 // Iterate the heap. |
| 12461 int count = 0; | 12461 int count = 0; |
| 12462 HeapObject* heap_obj = NULL; | 12462 HeapObject* heap_obj = NULL; |
| 12463 while (((heap_obj = iterator->next()) != NULL) && | 12463 while (((heap_obj = iterator->next()) != NULL) && |
| 12464 (max_references == 0 || count < max_references)) { | 12464 (max_references == 0 || count < max_references)) { |
| 12465 // Only look at all JSObjects. | 12465 // Only look at all JSObjects. |
| 12466 if (heap_obj->IsJSObject()) { | 12466 if (heap_obj->IsJSObject()) { |
| 12467 JSObject* obj = JSObject::cast(heap_obj); | 12467 JSObject* obj = JSObject::cast(heap_obj); |
| 12468 if (obj->map()->constructor() == constructor) { | 12468 if (obj->map()->constructor() == constructor) { |
| 12469 // Valid reference found add to instance array if supplied an update | 12469 // Valid reference found add to instance array if supplied an update |
| 12470 // count. | 12470 // count. |
| 12471 if (instances != NULL && count < instances_size) { | 12471 if (instances != NULL && count < instances_size) { |
| 12472 instances->set(count, obj); | 12472 instances->set(count, obj); |
| 12473 } | 12473 } |
| 12474 count++; | 12474 count++; |
| 12475 } | 12475 } |
| 12476 } | 12476 } |
| 12477 } | 12477 } |
| 12478 | 12478 |
| 12479 // Return the number of referencing objects found. | 12479 // Return the number of referencing objects found. |
| 12480 return count; | 12480 return count; |
| 12481 } | 12481 } |
| 12482 | 12482 |
| 12483 | 12483 |
| 12484 // Scan the heap for objects constructed by a specific function. | 12484 // Scan the heap for objects constructed by a specific function. |
| 12485 // args[0]: the constructor to find instances of | 12485 // args[0]: the constructor to find instances of |
| 12486 // args[1]: the the maximum number of objects to return | 12486 // args[1]: the the maximum number of objects to return |
| 12487 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { | 12487 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { |
| 12488 NoHandleAllocation ha(isolate); | 12488 RequireNewHandleScope rnhs(isolate); |
| 12489 ASSERT(args.length() == 2); | 12489 ASSERT(args.length() == 2); |
| 12490 | 12490 |
| 12491 // First perform a full GC in order to avoid dead objects. | 12491 // First perform a full GC in order to avoid dead objects. |
| 12492 Heap* heap = isolate->heap(); | 12492 Heap* heap = isolate->heap(); |
| 12493 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); | 12493 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); |
| 12494 | 12494 |
| 12495 // Check parameters. | 12495 // Check parameters. |
| 12496 CONVERT_ARG_CHECKED(JSFunction, constructor, 0); | 12496 CONVERT_ARG_CHECKED(JSFunction, constructor, 0); |
| 12497 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 12497 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
| 12498 RUNTIME_ASSERT(max_references >= 0); | 12498 RUNTIME_ASSERT(max_references >= 0); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 12528 isolate->context()->native_context()->array_function()); | 12528 isolate->context()->native_context()->array_function()); |
| 12529 if (!maybe_result->ToObject(&result)) return maybe_result; | 12529 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 12530 } | 12530 } |
| 12531 return JSArray::cast(result)->SetContent(instances); | 12531 return JSArray::cast(result)->SetContent(instances); |
| 12532 } | 12532 } |
| 12533 | 12533 |
| 12534 | 12534 |
| 12535 // Find the effective prototype object as returned by __proto__. | 12535 // Find the effective prototype object as returned by __proto__. |
| 12536 // args[0]: the object to find the prototype for. | 12536 // args[0]: the object to find the prototype for. |
| 12537 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { | 12537 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { |
| 12538 NoHandleAllocation ha(isolate); | 12538 RequireNewHandleScope rnhs(isolate); |
| 12539 ASSERT(args.length() == 1); | 12539 ASSERT(args.length() == 1); |
| 12540 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 12540 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
| 12541 return GetPrototypeSkipHiddenPrototypes(isolate, obj); | 12541 return GetPrototypeSkipHiddenPrototypes(isolate, obj); |
| 12542 } | 12542 } |
| 12543 | 12543 |
| 12544 | 12544 |
| 12545 // Patches script source (should be called upon BeforeCompile event). | 12545 // Patches script source (should be called upon BeforeCompile event). |
| 12546 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugSetScriptSource) { | 12546 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugSetScriptSource) { |
| 12547 HandleScope scope(isolate); | 12547 HandleScope scope(isolate); |
| 12548 ASSERT(args.length() == 2); | 12548 ASSERT(args.length() == 2); |
| 12549 | 12549 |
| 12550 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); | 12550 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); |
| 12551 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 12551 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 12552 | 12552 |
| 12553 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); | 12553 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); |
| 12554 Handle<Script> script(Script::cast(script_wrapper->value())); | 12554 Handle<Script> script(Script::cast(script_wrapper->value())); |
| 12555 | 12555 |
| 12556 int compilation_state = Smi::cast(script->compilation_state())->value(); | 12556 int compilation_state = Smi::cast(script->compilation_state())->value(); |
| 12557 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 12557 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
| 12558 script->set_source(*source); | 12558 script->set_source(*source); |
| 12559 | 12559 |
| 12560 return isolate->heap()->undefined_value(); | 12560 return isolate->heap()->undefined_value(); |
| 12561 } | 12561 } |
| 12562 | 12562 |
| 12563 | 12563 |
| 12564 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { | 12564 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { |
| 12565 NoHandleAllocation ha(isolate); | 12565 RequireNewHandleScope rnhs(isolate); |
| 12566 ASSERT(args.length() == 0); | 12566 ASSERT(args.length() == 0); |
| 12567 CPU::DebugBreak(); | 12567 CPU::DebugBreak(); |
| 12568 return isolate->heap()->undefined_value(); | 12568 return isolate->heap()->undefined_value(); |
| 12569 } | 12569 } |
| 12570 | 12570 |
| 12571 | 12571 |
| 12572 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { | 12572 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { |
| 12573 HandleScope scope(isolate); | 12573 HandleScope scope(isolate); |
| 12574 #ifdef DEBUG | 12574 #ifdef DEBUG |
| 12575 ASSERT(args.length() == 1); | 12575 ASSERT(args.length() == 1); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 12593 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { | 12593 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { |
| 12594 return Failure::Exception(); | 12594 return Failure::Exception(); |
| 12595 } | 12595 } |
| 12596 func->shared()->construct_stub()->PrintLn(); | 12596 func->shared()->construct_stub()->PrintLn(); |
| 12597 #endif // DEBUG | 12597 #endif // DEBUG |
| 12598 return isolate->heap()->undefined_value(); | 12598 return isolate->heap()->undefined_value(); |
| 12599 } | 12599 } |
| 12600 | 12600 |
| 12601 | 12601 |
| 12602 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { | 12602 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { |
| 12603 NoHandleAllocation ha(isolate); | 12603 RequireNewHandleScope rnhs(isolate); |
| 12604 ASSERT(args.length() == 1); | 12604 ASSERT(args.length() == 1); |
| 12605 | 12605 |
| 12606 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 12606 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 12607 return f->shared()->inferred_name(); | 12607 return f->shared()->inferred_name(); |
| 12608 } | 12608 } |
| 12609 | 12609 |
| 12610 | 12610 |
| 12611 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, | 12611 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
| 12612 Script* script, | 12612 Script* script, |
| 12613 FixedArray* buffer) { | 12613 FixedArray* buffer) { |
| 12614 AssertNoAllocation no_allocations; | 12614 DisallowHeapAllocation no_allocation; |
| 12615 int counter = 0; | 12615 int counter = 0; |
| 12616 int buffer_size = buffer->length(); | 12616 int buffer_size = buffer->length(); |
| 12617 for (HeapObject* obj = iterator->next(); | 12617 for (HeapObject* obj = iterator->next(); |
| 12618 obj != NULL; | 12618 obj != NULL; |
| 12619 obj = iterator->next()) { | 12619 obj = iterator->next()) { |
| 12620 ASSERT(obj != NULL); | 12620 ASSERT(obj != NULL); |
| 12621 if (!obj->IsSharedFunctionInfo()) { | 12621 if (!obj->IsSharedFunctionInfo()) { |
| 12622 continue; | 12622 continue; |
| 12623 } | 12623 } |
| 12624 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); | 12624 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 12647 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 12647 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
| 12648 | 12648 |
| 12649 const int kBufferSize = 32; | 12649 const int kBufferSize = 32; |
| 12650 | 12650 |
| 12651 Handle<FixedArray> array; | 12651 Handle<FixedArray> array; |
| 12652 array = isolate->factory()->NewFixedArray(kBufferSize); | 12652 array = isolate->factory()->NewFixedArray(kBufferSize); |
| 12653 int number; | 12653 int number; |
| 12654 Heap* heap = isolate->heap(); | 12654 Heap* heap = isolate->heap(); |
| 12655 { | 12655 { |
| 12656 heap->EnsureHeapIsIterable(); | 12656 heap->EnsureHeapIsIterable(); |
| 12657 AssertNoAllocation no_allocations; | 12657 DisallowHeapAllocation no_allocation; |
| 12658 HeapIterator heap_iterator(heap); | 12658 HeapIterator heap_iterator(heap); |
| 12659 Script* scr = *script; | 12659 Script* scr = *script; |
| 12660 FixedArray* arr = *array; | 12660 FixedArray* arr = *array; |
| 12661 number = FindSharedFunctionInfosForScript(&heap_iterator, scr, arr); | 12661 number = FindSharedFunctionInfosForScript(&heap_iterator, scr, arr); |
| 12662 } | 12662 } |
| 12663 if (number > kBufferSize) { | 12663 if (number > kBufferSize) { |
| 12664 array = isolate->factory()->NewFixedArray(number); | 12664 array = isolate->factory()->NewFixedArray(number); |
| 12665 heap->EnsureHeapIsIterable(); | 12665 heap->EnsureHeapIsIterable(); |
| 12666 AssertNoAllocation no_allocations; | 12666 DisallowHeapAllocation no_allocation; |
| 12667 HeapIterator heap_iterator(heap); | 12667 HeapIterator heap_iterator(heap); |
| 12668 Script* scr = *script; | 12668 Script* scr = *script; |
| 12669 FixedArray* arr = *array; | 12669 FixedArray* arr = *array; |
| 12670 FindSharedFunctionInfosForScript(&heap_iterator, scr, arr); | 12670 FindSharedFunctionInfosForScript(&heap_iterator, scr, arr); |
| 12671 } | 12671 } |
| 12672 | 12672 |
| 12673 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array); | 12673 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array); |
| 12674 result->set_length(Smi::FromInt(number)); | 12674 result->set_length(Smi::FromInt(number)); |
| 12675 | 12675 |
| 12676 LiveEdit::WrapSharedFunctionInfos(result); | 12676 LiveEdit::WrapSharedFunctionInfos(result); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12941 if (!pending_exception) { | 12941 if (!pending_exception) { |
| 12942 return *result; | 12942 return *result; |
| 12943 } else { | 12943 } else { |
| 12944 return Failure::Exception(); | 12944 return Failure::Exception(); |
| 12945 } | 12945 } |
| 12946 } | 12946 } |
| 12947 | 12947 |
| 12948 | 12948 |
| 12949 // Sets a v8 flag. | 12949 // Sets a v8 flag. |
| 12950 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { | 12950 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { |
| 12951 NoHandleAllocation ha(isolate); | 12951 RequireNewHandleScope rnhs(isolate); |
| 12952 CONVERT_ARG_CHECKED(String, arg, 0); | 12952 CONVERT_ARG_CHECKED(String, arg, 0); |
| 12953 SmartArrayPointer<char> flags = | 12953 SmartArrayPointer<char> flags = |
| 12954 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 12954 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
| 12955 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); | 12955 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); |
| 12956 return isolate->heap()->undefined_value(); | 12956 return isolate->heap()->undefined_value(); |
| 12957 } | 12957 } |
| 12958 | 12958 |
| 12959 | 12959 |
| 12960 // Performs a GC. | 12960 // Performs a GC. |
| 12961 // Presently, it only does a full GC. | 12961 // Presently, it only does a full GC. |
| 12962 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { | 12962 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { |
| 12963 NoHandleAllocation ha(isolate); | 12963 RequireNewHandleScope rnhs(isolate); |
| 12964 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); | 12964 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); |
| 12965 return isolate->heap()->undefined_value(); | 12965 return isolate->heap()->undefined_value(); |
| 12966 } | 12966 } |
| 12967 | 12967 |
| 12968 | 12968 |
| 12969 // Gets the current heap usage. | 12969 // Gets the current heap usage. |
| 12970 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { | 12970 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { |
| 12971 NoHandleAllocation ha(isolate); | 12971 RequireNewHandleScope rnhs(isolate); |
| 12972 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); | 12972 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); |
| 12973 if (!Smi::IsValid(usage)) { | 12973 if (!Smi::IsValid(usage)) { |
| 12974 return *isolate->factory()->NewNumberFromInt(usage); | 12974 return *isolate->factory()->NewNumberFromInt(usage); |
| 12975 } | 12975 } |
| 12976 return Smi::FromInt(usage); | 12976 return Smi::FromInt(usage); |
| 12977 } | 12977 } |
| 12978 | 12978 |
| 12979 #endif // ENABLE_DEBUGGER_SUPPORT | 12979 #endif // ENABLE_DEBUGGER_SUPPORT |
| 12980 | 12980 |
| 12981 | 12981 |
| 12982 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { | 12982 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { |
| 12983 NoHandleAllocation ha(isolate); | 12983 RequireNewHandleScope rnhs(isolate); |
| 12984 v8::V8::ResumeProfiler(); | 12984 v8::V8::ResumeProfiler(); |
| 12985 return isolate->heap()->undefined_value(); | 12985 return isolate->heap()->undefined_value(); |
| 12986 } | 12986 } |
| 12987 | 12987 |
| 12988 | 12988 |
| 12989 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { | 12989 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { |
| 12990 NoHandleAllocation ha(isolate); | 12990 RequireNewHandleScope rnhs(isolate); |
| 12991 v8::V8::PauseProfiler(); | 12991 v8::V8::PauseProfiler(); |
| 12992 return isolate->heap()->undefined_value(); | 12992 return isolate->heap()->undefined_value(); |
| 12993 } | 12993 } |
| 12994 | 12994 |
| 12995 | 12995 |
| 12996 // Finds the script object from the script data. NOTE: This operation uses | 12996 // Finds the script object from the script data. NOTE: This operation uses |
| 12997 // heap traversal to find the function generated for the source position | 12997 // heap traversal to find the function generated for the source position |
| 12998 // for the requested break point. For lazily compiled functions several heap | 12998 // for the requested break point. For lazily compiled functions several heap |
| 12999 // traversals might be required rendering this operation as a rather slow | 12999 // traversals might be required rendering this operation as a rather slow |
| 13000 // operation. However for setting break points which is normally done through | 13000 // operation. However for setting break points which is normally done through |
| 13001 // some kind of user interaction the performance is not crucial. | 13001 // some kind of user interaction the performance is not crucial. |
| 13002 static Handle<Object> Runtime_GetScriptFromScriptName( | 13002 static Handle<Object> Runtime_GetScriptFromScriptName( |
| 13003 Handle<String> script_name) { | 13003 Handle<String> script_name) { |
| 13004 // Scan the heap for Script objects to find the script with the requested | 13004 // Scan the heap for Script objects to find the script with the requested |
| 13005 // script data. | 13005 // script data. |
| 13006 Handle<Script> script; | 13006 Handle<Script> script; |
| 13007 Heap* heap = script_name->GetHeap(); | 13007 Heap* heap = script_name->GetHeap(); |
| 13008 heap->EnsureHeapIsIterable(); | 13008 heap->EnsureHeapIsIterable(); |
| 13009 AssertNoAllocation no_allocation_during_heap_iteration; | 13009 DisallowHeapAllocation no_allocation_during_heap_iteration; |
| 13010 HeapIterator iterator(heap); | 13010 HeapIterator iterator(heap); |
| 13011 HeapObject* obj = NULL; | 13011 HeapObject* obj = NULL; |
| 13012 while (script.is_null() && ((obj = iterator.next()) != NULL)) { | 13012 while (script.is_null() && ((obj = iterator.next()) != NULL)) { |
| 13013 // If a script is found check if it has the script data requested. | 13013 // If a script is found check if it has the script data requested. |
| 13014 if (obj->IsScript()) { | 13014 if (obj->IsScript()) { |
| 13015 if (Script::cast(obj)->name()->IsString()) { | 13015 if (Script::cast(obj)->name()->IsString()) { |
| 13016 if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) { | 13016 if (String::cast(Script::cast(obj)->name())->Equals(*script_name)) { |
| 13017 script = Handle<Script>(Script::cast(obj)); | 13017 script = Handle<Script>(Script::cast(obj)); |
| 13018 } | 13018 } |
| 13019 } | 13019 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13100 } else { | 13100 } else { |
| 13101 RUNTIME_ASSERT(value->IsString()); | 13101 RUNTIME_ASSERT(value->IsString()); |
| 13102 JSObject::SetHiddenProperty(error_object, key, value); | 13102 JSObject::SetHiddenProperty(error_object, key, value); |
| 13103 } | 13103 } |
| 13104 return *error_object; | 13104 return *error_object; |
| 13105 } | 13105 } |
| 13106 | 13106 |
| 13107 | 13107 |
| 13108 // Returns V8 version as a string. | 13108 // Returns V8 version as a string. |
| 13109 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 13109 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
| 13110 NoHandleAllocation ha(isolate); | 13110 RequireNewHandleScope rnhs(isolate); |
| 13111 ASSERT_EQ(args.length(), 0); | 13111 ASSERT_EQ(args.length(), 0); |
| 13112 | 13112 |
| 13113 const char* version_string = v8::V8::GetVersion(); | 13113 const char* version_string = v8::V8::GetVersion(); |
| 13114 | 13114 |
| 13115 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), | 13115 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), |
| 13116 NOT_TENURED); | 13116 NOT_TENURED); |
| 13117 } | 13117 } |
| 13118 | 13118 |
| 13119 | 13119 |
| 13120 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { | 13120 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { |
| 13121 NoHandleAllocation ha(isolate); | 13121 RequireNewHandleScope rnhs(isolate); |
| 13122 ASSERT(args.length() == 2); | 13122 ASSERT(args.length() == 2); |
| 13123 OS::PrintError("abort: %s\n", | 13123 OS::PrintError("abort: %s\n", |
| 13124 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); | 13124 reinterpret_cast<char*>(args[0]) + args.smi_at(1)); |
| 13125 isolate->PrintStack(stderr); | 13125 isolate->PrintStack(stderr); |
| 13126 OS::Abort(); | 13126 OS::Abort(); |
| 13127 UNREACHABLE(); | 13127 UNREACHABLE(); |
| 13128 return NULL; | 13128 return NULL; |
| 13129 } | 13129 } |
| 13130 | 13130 |
| 13131 | 13131 |
| 13132 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { | 13132 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { |
| 13133 HandleScope scope(isolate); | 13133 HandleScope scope(isolate); |
| 13134 ASSERT(args.length() == 1); | 13134 ASSERT(args.length() == 1); |
| 13135 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 13135 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
| 13136 FlattenString(str); | 13136 FlattenString(str); |
| 13137 return isolate->heap()->undefined_value(); | 13137 return isolate->heap()->undefined_value(); |
| 13138 } | 13138 } |
| 13139 | 13139 |
| 13140 | 13140 |
| 13141 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { | 13141 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { |
| 13142 NoHandleAllocation ha(isolate); | 13142 RequireNewHandleScope rnhs(isolate); |
| 13143 // This is only called from codegen, so checks might be more lax. | 13143 // This is only called from codegen, so checks might be more lax. |
| 13144 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); | 13144 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); |
| 13145 Object* key = args[1]; | 13145 Object* key = args[1]; |
| 13146 | 13146 |
| 13147 int finger_index = cache->finger_index(); | 13147 int finger_index = cache->finger_index(); |
| 13148 Object* o = cache->get(finger_index); | 13148 Object* o = cache->get(finger_index); |
| 13149 if (o == key) { | 13149 if (o == key) { |
| 13150 // The fastest case: hit the same place again. | 13150 // The fastest case: hit the same place again. |
| 13151 return cache->get(finger_index + 1); | 13151 return cache->get(finger_index + 1); |
| 13152 } | 13152 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13230 if (FLAG_verify_heap) { | 13230 if (FLAG_verify_heap) { |
| 13231 cache_handle->JSFunctionResultCacheVerify(); | 13231 cache_handle->JSFunctionResultCacheVerify(); |
| 13232 } | 13232 } |
| 13233 #endif | 13233 #endif |
| 13234 | 13234 |
| 13235 return *value; | 13235 return *value; |
| 13236 } | 13236 } |
| 13237 | 13237 |
| 13238 | 13238 |
| 13239 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { | 13239 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { |
| 13240 NoHandleAllocation ha(isolate); | 13240 RequireNewHandleScope rnhs(isolate); |
| 13241 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 13241 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
| 13242 return Smi::FromInt(message->start_position()); | 13242 return Smi::FromInt(message->start_position()); |
| 13243 } | 13243 } |
| 13244 | 13244 |
| 13245 | 13245 |
| 13246 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { | 13246 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { |
| 13247 NoHandleAllocation ha(isolate); | 13247 RequireNewHandleScope rnhs(isolate); |
| 13248 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 13248 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
| 13249 return message->script(); | 13249 return message->script(); |
| 13250 } | 13250 } |
| 13251 | 13251 |
| 13252 | 13252 |
| 13253 #ifdef DEBUG | 13253 #ifdef DEBUG |
| 13254 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 13254 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
| 13255 // Exclude the code in release mode. | 13255 // Exclude the code in release mode. |
| 13256 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { | 13256 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { |
| 13257 HandleScope scope(isolate); | 13257 HandleScope scope(isolate); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13291 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 13291 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
| 13292 #undef ADD_ENTRY | 13292 #undef ADD_ENTRY |
| 13293 ASSERT_EQ(index, entry_count); | 13293 ASSERT_EQ(index, entry_count); |
| 13294 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 13294 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
| 13295 return *result; | 13295 return *result; |
| 13296 } | 13296 } |
| 13297 #endif | 13297 #endif |
| 13298 | 13298 |
| 13299 | 13299 |
| 13300 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { | 13300 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { |
| 13301 NoHandleAllocation ha(isolate); | 13301 RequireNewHandleScope rnhs(isolate); |
| 13302 ASSERT(args.length() == 2); | 13302 ASSERT(args.length() == 2); |
| 13303 CONVERT_ARG_CHECKED(String, format, 0); | 13303 CONVERT_ARG_CHECKED(String, format, 0); |
| 13304 CONVERT_ARG_CHECKED(JSArray, elms, 1); | 13304 CONVERT_ARG_CHECKED(JSArray, elms, 1); |
| 13305 AssertNoAllocation no_gc; | 13305 DisallowHeapAllocation no_gc; |
| 13306 String::FlatContent format_content = format->GetFlatContent(); | 13306 String::FlatContent format_content = format->GetFlatContent(); |
| 13307 RUNTIME_ASSERT(format_content.IsAscii()); | 13307 RUNTIME_ASSERT(format_content.IsAscii()); |
| 13308 Vector<const uint8_t> chars = format_content.ToOneByteVector(); | 13308 Vector<const uint8_t> chars = format_content.ToOneByteVector(); |
| 13309 isolate->logger()->LogRuntime(Vector<const char>::cast(chars), elms); | 13309 isolate->logger()->LogRuntime(Vector<const char>::cast(chars), elms); |
| 13310 return isolate->heap()->undefined_value(); | 13310 return isolate->heap()->undefined_value(); |
| 13311 } | 13311 } |
| 13312 | 13312 |
| 13313 | 13313 |
| 13314 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { | 13314 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { |
| 13315 UNREACHABLE(); // implemented as macro in the parser | 13315 UNREACHABLE(); // implemented as macro in the parser |
| (...skipping 24 matching lines...) Expand all Loading... |
| 13340 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) | 13340 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalUnsignedIntElements) |
| 13341 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) | 13341 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalFloatElements) |
| 13342 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) | 13342 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalDoubleElements) |
| 13343 // Properties test sitting with elements tests - not fooling anyone. | 13343 // Properties test sitting with elements tests - not fooling anyone. |
| 13344 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) | 13344 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) |
| 13345 | 13345 |
| 13346 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION | 13346 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION |
| 13347 | 13347 |
| 13348 | 13348 |
| 13349 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 13349 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { |
| 13350 NoHandleAllocation ha(isolate); | 13350 RequireNewHandleScope rnhs(isolate); |
| 13351 ASSERT(args.length() == 2); | 13351 ASSERT(args.length() == 2); |
| 13352 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 13352 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
| 13353 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 13353 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
| 13354 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 13354 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
| 13355 } | 13355 } |
| 13356 | 13356 |
| 13357 | 13357 |
| 13358 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { | 13358 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { |
| 13359 NoHandleAllocation ha(isolate); | 13359 RequireNewHandleScope rnhs(isolate); |
| 13360 ASSERT(args.length() == 1); | 13360 ASSERT(args.length() == 1); |
| 13361 | 13361 |
| 13362 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); | 13362 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); |
| 13363 JSReceiver* obj = JSReceiver::cast(args[0]); | 13363 JSReceiver* obj = JSReceiver::cast(args[0]); |
| 13364 if (obj->IsJSGlobalProxy()) { | 13364 if (obj->IsJSGlobalProxy()) { |
| 13365 Object* proto = obj->GetPrototype(); | 13365 Object* proto = obj->GetPrototype(); |
| 13366 if (proto->IsNull()) return isolate->heap()->false_value(); | 13366 if (proto->IsNull()) return isolate->heap()->false_value(); |
| 13367 ASSERT(proto->IsJSGlobalObject()); | 13367 ASSERT(proto->IsJSGlobalObject()); |
| 13368 obj = JSReceiver::cast(proto); | 13368 obj = JSReceiver::cast(proto); |
| 13369 } | 13369 } |
| 13370 return isolate->heap()->ToBoolean(obj->map()->is_observed()); | 13370 return isolate->heap()->ToBoolean(obj->map()->is_observed()); |
| 13371 } | 13371 } |
| 13372 | 13372 |
| 13373 | 13373 |
| 13374 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { | 13374 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { |
| 13375 NoHandleAllocation ha(isolate); | 13375 RequireNewHandleScope rnhs(isolate); |
| 13376 ASSERT(args.length() == 2); | 13376 ASSERT(args.length() == 2); |
| 13377 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 13377 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
| 13378 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1); | 13378 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1); |
| 13379 if (obj->IsJSGlobalProxy()) { | 13379 if (obj->IsJSGlobalProxy()) { |
| 13380 Object* proto = obj->GetPrototype(); | 13380 Object* proto = obj->GetPrototype(); |
| 13381 if (proto->IsNull()) return isolate->heap()->undefined_value(); | 13381 if (proto->IsNull()) return isolate->heap()->undefined_value(); |
| 13382 ASSERT(proto->IsJSGlobalObject()); | 13382 ASSERT(proto->IsJSGlobalObject()); |
| 13383 obj = JSReceiver::cast(proto); | 13383 obj = JSReceiver::cast(proto); |
| 13384 } | 13384 } |
| 13385 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && | 13385 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && |
| (...skipping 10 matching lines...) Expand all Loading... |
| 13396 Map* map; | 13396 Map* map; |
| 13397 if (!maybe->To(&map)) return maybe; | 13397 if (!maybe->To(&map)) return maybe; |
| 13398 map->set_is_observed(is_observed); | 13398 map->set_is_observed(is_observed); |
| 13399 obj->set_map(map); | 13399 obj->set_map(map); |
| 13400 } | 13400 } |
| 13401 return isolate->heap()->undefined_value(); | 13401 return isolate->heap()->undefined_value(); |
| 13402 } | 13402 } |
| 13403 | 13403 |
| 13404 | 13404 |
| 13405 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { | 13405 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { |
| 13406 NoHandleAllocation ha(isolate); | 13406 RequireNewHandleScope rnhs(isolate); |
| 13407 ASSERT(args.length() == 0); | 13407 ASSERT(args.length() == 0); |
| 13408 isolate->set_observer_delivery_pending(true); | 13408 isolate->set_observer_delivery_pending(true); |
| 13409 return isolate->heap()->undefined_value(); | 13409 return isolate->heap()->undefined_value(); |
| 13410 } | 13410 } |
| 13411 | 13411 |
| 13412 | 13412 |
| 13413 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { | 13413 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { |
| 13414 NoHandleAllocation ha(isolate); | 13414 RequireNewHandleScope rnhs(isolate); |
| 13415 ASSERT(args.length() == 0); | 13415 ASSERT(args.length() == 0); |
| 13416 return isolate->heap()->observation_state(); | 13416 return isolate->heap()->observation_state(); |
| 13417 } | 13417 } |
| 13418 | 13418 |
| 13419 | 13419 |
| 13420 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) { | 13420 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) { |
| 13421 HandleScope scope(isolate); | 13421 HandleScope scope(isolate); |
| 13422 ASSERT(args.length() == 0); | 13422 ASSERT(args.length() == 0); |
| 13423 // TODO(adamk): Currently this runtime function is only called three times per | 13423 // TODO(adamk): Currently this runtime function is only called three times per |
| 13424 // isolate. If it's called more often, the map should be moved into the | 13424 // isolate. If it's called more often, the map should be moved into the |
| 13425 // strong root list. | 13425 // strong root list. |
| 13426 Handle<Map> map = | 13426 Handle<Map> map = |
| 13427 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); | 13427 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
| 13428 Handle<JSWeakMap> weakmap = | 13428 Handle<JSWeakMap> weakmap = |
| 13429 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); | 13429 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); |
| 13430 return WeakMapInitialize(isolate, weakmap); | 13430 return WeakMapInitialize(isolate, weakmap); |
| 13431 } | 13431 } |
| 13432 | 13432 |
| 13433 | 13433 |
| 13434 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) { | 13434 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) { |
| 13435 NoHandleAllocation ha(isolate); | 13435 RequireNewHandleScope rnhs(isolate); |
| 13436 ASSERT(args.length() == 1); | 13436 ASSERT(args.length() == 1); |
| 13437 Object* object = args[0]; | 13437 Object* object = args[0]; |
| 13438 if (object->IsJSGlobalProxy()) { | 13438 if (object->IsJSGlobalProxy()) { |
| 13439 object = object->GetPrototype(isolate); | 13439 object = object->GetPrototype(isolate); |
| 13440 if (object->IsNull()) return isolate->heap()->undefined_value(); | 13440 if (object->IsNull()) return isolate->heap()->undefined_value(); |
| 13441 } | 13441 } |
| 13442 return object; | 13442 return object; |
| 13443 } | 13443 } |
| 13444 | 13444 |
| 13445 | 13445 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13522 // Handle last resort GC and make sure to allow future allocations | 13522 // Handle last resort GC and make sure to allow future allocations |
| 13523 // to grow the heap without causing GCs (if possible). | 13523 // to grow the heap without causing GCs (if possible). |
| 13524 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13524 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13525 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13525 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13526 "Runtime::PerformGC"); | 13526 "Runtime::PerformGC"); |
| 13527 } | 13527 } |
| 13528 } | 13528 } |
| 13529 | 13529 |
| 13530 | 13530 |
| 13531 } } // namespace v8::internal | 13531 } } // namespace v8::internal |
| OLD | NEW |