OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 NoHandleAllocation ha; | 515 NoHandleAllocation ha; |
516 ASSERT(args.length() == 0); | 516 ASSERT(args.length() == 0); |
517 JavaScriptFrameIterator it; | 517 JavaScriptFrameIterator it; |
518 return Heap::ToBoolean(it.frame()->IsConstructor()); | 518 return Heap::ToBoolean(it.frame()->IsConstructor()); |
519 } | 519 } |
520 | 520 |
521 | 521 |
522 static Object* Runtime_RegExpCompile(Arguments args) { | 522 static Object* Runtime_RegExpCompile(Arguments args) { |
523 HandleScope scope; | 523 HandleScope scope; |
524 ASSERT(args.length() == 3); | 524 ASSERT(args.length() == 3); |
525 CONVERT_CHECKED(JSRegExp, raw_re, args[0]); | 525 CONVERT_ARG_CHECKED(JSRegExp, re, 0); |
526 Handle<JSRegExp> re(raw_re); | 526 CONVERT_ARG_CHECKED(String, pattern, 1); |
527 CONVERT_CHECKED(String, raw_pattern, args[1]); | 527 CONVERT_ARG_CHECKED(String, flags, 2); |
528 Handle<String> pattern(raw_pattern); | |
529 CONVERT_CHECKED(String, raw_flags, args[2]); | |
530 Handle<String> flags(raw_flags); | |
531 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); | 528 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); |
532 if (result.is_null()) return Failure::Exception(); | 529 if (result.is_null()) return Failure::Exception(); |
533 return *result; | 530 return *result; |
534 } | 531 } |
535 | 532 |
536 | 533 |
537 static Object* Runtime_CreateApiFunction(Arguments args) { | 534 static Object* Runtime_CreateApiFunction(Arguments args) { |
538 HandleScope scope; | 535 HandleScope scope; |
539 ASSERT(args.length() == 1); | 536 ASSERT(args.length() == 1); |
540 CONVERT_CHECKED(FunctionTemplateInfo, raw_data, args[0]); | 537 CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0); |
541 Handle<FunctionTemplateInfo> data(raw_data); | |
542 return *Factory::CreateApiFunction(data); | 538 return *Factory::CreateApiFunction(data); |
543 } | 539 } |
544 | 540 |
545 | 541 |
546 static Object* Runtime_IsTemplate(Arguments args) { | 542 static Object* Runtime_IsTemplate(Arguments args) { |
547 ASSERT(args.length() == 1); | 543 ASSERT(args.length() == 1); |
548 Object* arg = args[0]; | 544 Object* arg = args[0]; |
549 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 545 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
550 return Heap::ToBoolean(result); | 546 return Heap::ToBoolean(result); |
551 } | 547 } |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 } | 1055 } |
1060 } | 1056 } |
1061 | 1057 |
1062 return *value; | 1058 return *value; |
1063 } | 1059 } |
1064 | 1060 |
1065 | 1061 |
1066 static Object* Runtime_RegExpExec(Arguments args) { | 1062 static Object* Runtime_RegExpExec(Arguments args) { |
1067 HandleScope scope; | 1063 HandleScope scope; |
1068 ASSERT(args.length() == 4); | 1064 ASSERT(args.length() == 4); |
1069 CONVERT_CHECKED(JSRegExp, raw_regexp, args[0]); | 1065 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
1070 Handle<JSRegExp> regexp(raw_regexp); | 1066 CONVERT_ARG_CHECKED(String, subject, 1); |
1071 CONVERT_CHECKED(String, raw_subject, args[1]); | |
1072 Handle<String> subject(raw_subject); | |
1073 // Due to the way the JS files are constructed this must be less than the | 1067 // Due to the way the JS files are constructed this must be less than the |
1074 // length of a string, i.e. it is always a Smi. We check anyway for security. | 1068 // length of a string, i.e. it is always a Smi. We check anyway for security. |
1075 CONVERT_CHECKED(Smi, index, args[2]); | 1069 CONVERT_CHECKED(Smi, index, args[2]); |
1076 CONVERT_CHECKED(JSArray, raw_last_match_info, args[3]); | 1070 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); |
1077 Handle<JSArray> last_match_info(raw_last_match_info); | |
1078 RUNTIME_ASSERT(last_match_info->HasFastElements()); | 1071 RUNTIME_ASSERT(last_match_info->HasFastElements()); |
1079 RUNTIME_ASSERT(index->value() >= 0); | 1072 RUNTIME_ASSERT(index->value() >= 0); |
1080 RUNTIME_ASSERT(index->value() <= subject->length()); | 1073 RUNTIME_ASSERT(index->value() <= subject->length()); |
1081 Handle<Object> result = RegExpImpl::Exec(regexp, | 1074 Handle<Object> result = RegExpImpl::Exec(regexp, |
1082 subject, | 1075 subject, |
1083 index->value(), | 1076 index->value(), |
1084 last_match_info); | 1077 last_match_info); |
1085 if (result.is_null()) return Failure::Exception(); | 1078 if (result.is_null()) return Failure::Exception(); |
1086 return *result; | 1079 return *result; |
1087 } | 1080 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 // the API. | 1203 // the API. |
1211 return !f->shared()->function_data()->IsUndefined() ? Heap::true_value() | 1204 return !f->shared()->function_data()->IsUndefined() ? Heap::true_value() |
1212 : Heap::false_value(); | 1205 : Heap::false_value(); |
1213 } | 1206 } |
1214 | 1207 |
1215 | 1208 |
1216 static Object* Runtime_SetCode(Arguments args) { | 1209 static Object* Runtime_SetCode(Arguments args) { |
1217 HandleScope scope; | 1210 HandleScope scope; |
1218 ASSERT(args.length() == 2); | 1211 ASSERT(args.length() == 2); |
1219 | 1212 |
1220 CONVERT_CHECKED(JSFunction, raw_target, args[0]); | 1213 CONVERT_ARG_CHECKED(JSFunction, target, 0); |
1221 Handle<JSFunction> target(raw_target); | |
1222 Handle<Object> code = args.at<Object>(1); | 1214 Handle<Object> code = args.at<Object>(1); |
1223 | 1215 |
1224 Handle<Context> context(target->context()); | 1216 Handle<Context> context(target->context()); |
1225 | 1217 |
1226 if (!code->IsNull()) { | 1218 if (!code->IsNull()) { |
1227 RUNTIME_ASSERT(code->IsJSFunction()); | 1219 RUNTIME_ASSERT(code->IsJSFunction()); |
1228 Handle<JSFunction> fun = Handle<JSFunction>::cast(code); | 1220 Handle<JSFunction> fun = Handle<JSFunction>::cast(code); |
1229 SetExpectedNofProperties(target, fun->shared()->expected_nof_properties()); | 1221 SetExpectedNofProperties(target, fun->shared()->expected_nof_properties()); |
1230 if (!fun->is_compiled() && !CompileLazy(fun, KEEP_EXCEPTION)) { | 1222 if (!fun->is_compiled() && !CompileLazy(fun, KEEP_EXCEPTION)) { |
1231 return Failure::Exception(); | 1223 return Failure::Exception(); |
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 } | 2957 } |
2966 | 2958 |
2967 PropertyAttributes att = object->GetLocalPropertyAttribute(key); | 2959 PropertyAttributes att = object->GetLocalPropertyAttribute(key); |
2968 return Heap::ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); | 2960 return Heap::ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); |
2969 } | 2961 } |
2970 | 2962 |
2971 | 2963 |
2972 static Object* Runtime_GetPropertyNames(Arguments args) { | 2964 static Object* Runtime_GetPropertyNames(Arguments args) { |
2973 HandleScope scope; | 2965 HandleScope scope; |
2974 ASSERT(args.length() == 1); | 2966 ASSERT(args.length() == 1); |
2975 | 2967 CONVERT_ARG_CHECKED(JSObject, object, 0); |
2976 CONVERT_CHECKED(JSObject, raw_object, args[0]); | |
2977 Handle<JSObject> object(raw_object); | |
2978 return *GetKeysFor(object); | 2968 return *GetKeysFor(object); |
2979 } | 2969 } |
2980 | 2970 |
2981 | 2971 |
2982 // Returns either a FixedArray as Runtime_GetPropertyNames, | 2972 // Returns either a FixedArray as Runtime_GetPropertyNames, |
2983 // or, if the given object has an enum cache that contains | 2973 // or, if the given object has an enum cache that contains |
2984 // all enumerable properties of the object and its prototypes | 2974 // all enumerable properties of the object and its prototypes |
2985 // have none, the map of the object. This is used to speed up | 2975 // have none, the map of the object. This is used to speed up |
2986 // the check for deletions during a for-in. | 2976 // the check for deletions during a for-in. |
2987 static Object* Runtime_GetPropertyNamesFast(Arguments args) { | 2977 static Object* Runtime_GetPropertyNamesFast(Arguments args) { |
(...skipping 3668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6656 | 6646 |
6657 // Convert to JS array and return. | 6647 // Convert to JS array and return. |
6658 return *Factory::NewJSArrayWithElements(details); | 6648 return *Factory::NewJSArrayWithElements(details); |
6659 } | 6649 } |
6660 | 6650 |
6661 | 6651 |
6662 static Object* Runtime_GetBreakLocations(Arguments args) { | 6652 static Object* Runtime_GetBreakLocations(Arguments args) { |
6663 HandleScope scope; | 6653 HandleScope scope; |
6664 ASSERT(args.length() == 1); | 6654 ASSERT(args.length() == 1); |
6665 | 6655 |
6666 CONVERT_ARG_CHECKED(JSFunction, raw_fun, 0); | 6656 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
6667 Handle<SharedFunctionInfo> shared(raw_fun->shared()); | 6657 Handle<SharedFunctionInfo> shared(fun->shared()); |
6668 // Find the number of break points | 6658 // Find the number of break points |
6669 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); | 6659 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); |
6670 if (break_locations->IsUndefined()) return Heap::undefined_value(); | 6660 if (break_locations->IsUndefined()) return Heap::undefined_value(); |
6671 // Return array as JS array | 6661 // Return array as JS array |
6672 return *Factory::NewJSArrayWithElements( | 6662 return *Factory::NewJSArrayWithElements( |
6673 Handle<FixedArray>::cast(break_locations)); | 6663 Handle<FixedArray>::cast(break_locations)); |
6674 } | 6664 } |
6675 | 6665 |
6676 | 6666 |
6677 // Set a break point in a function | 6667 // Set a break point in a function |
6678 // args[0]: function | 6668 // args[0]: function |
6679 // args[1]: number: break source position (within the function source) | 6669 // args[1]: number: break source position (within the function source) |
6680 // args[2]: number: break point object | 6670 // args[2]: number: break point object |
6681 static Object* Runtime_SetFunctionBreakPoint(Arguments args) { | 6671 static Object* Runtime_SetFunctionBreakPoint(Arguments args) { |
6682 HandleScope scope; | 6672 HandleScope scope; |
6683 ASSERT(args.length() == 3); | 6673 ASSERT(args.length() == 3); |
6684 CONVERT_ARG_CHECKED(JSFunction, raw_fun, 0); | 6674 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
6685 Handle<SharedFunctionInfo> shared(raw_fun->shared()); | 6675 Handle<SharedFunctionInfo> shared(fun->shared()); |
6686 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 6676 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
6687 RUNTIME_ASSERT(source_position >= 0); | 6677 RUNTIME_ASSERT(source_position >= 0); |
6688 Handle<Object> break_point_object_arg = args.at<Object>(2); | 6678 Handle<Object> break_point_object_arg = args.at<Object>(2); |
6689 | 6679 |
6690 // Set break point. | 6680 // Set break point. |
6691 Debug::SetBreakPoint(shared, source_position, break_point_object_arg); | 6681 Debug::SetBreakPoint(shared, source_position, break_point_object_arg); |
6692 | 6682 |
6693 return Heap::undefined_value(); | 6683 return Heap::undefined_value(); |
6694 } | 6684 } |
6695 | 6685 |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7509 } else { | 7499 } else { |
7510 // Handle last resort GC and make sure to allow future allocations | 7500 // Handle last resort GC and make sure to allow future allocations |
7511 // to grow the heap without causing GCs (if possible). | 7501 // to grow the heap without causing GCs (if possible). |
7512 Counters::gc_last_resort_from_js.Increment(); | 7502 Counters::gc_last_resort_from_js.Increment(); |
7513 Heap::CollectAllGarbage(); | 7503 Heap::CollectAllGarbage(); |
7514 } | 7504 } |
7515 } | 7505 } |
7516 | 7506 |
7517 | 7507 |
7518 } } // namespace v8::internal | 7508 } } // namespace v8::internal |
OLD | NEW |