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 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 return -1; | 2216 return -1; |
2217 } | 2217 } |
2218 Vector<const char> ascii_vector = | 2218 Vector<const char> ascii_vector = |
2219 sub->ToAsciiVector().SubVector(start_index, subject_length); | 2219 sub->ToAsciiVector().SubVector(start_index, subject_length); |
2220 const void* pos = memchr(ascii_vector.start(), | 2220 const void* pos = memchr(ascii_vector.start(), |
2221 static_cast<const char>(pchar), | 2221 static_cast<const char>(pchar), |
2222 static_cast<size_t>(ascii_vector.length())); | 2222 static_cast<size_t>(ascii_vector.length())); |
2223 if (pos == NULL) { | 2223 if (pos == NULL) { |
2224 return -1; | 2224 return -1; |
2225 } | 2225 } |
2226 return reinterpret_cast<const char*>(pos) - ascii_vector.start() | 2226 return static_cast<int>(reinterpret_cast<const char*>(pos) |
2227 + start_index; | 2227 - ascii_vector.start() + start_index); |
2228 } | 2228 } |
2229 return SingleCharIndexOf(sub->ToUC16Vector(), pat->Get(0), start_index); | 2229 return SingleCharIndexOf(sub->ToUC16Vector(), pat->Get(0), start_index); |
2230 } | 2230 } |
2231 | 2231 |
2232 if (!pat->IsFlat()) { | 2232 if (!pat->IsFlat()) { |
2233 FlattenString(pat); | 2233 FlattenString(pat); |
2234 } | 2234 } |
2235 | 2235 |
2236 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid | 2236 AssertNoAllocation no_heap_allocation; // ensure vectors stay valid |
2237 // dispatch on type of strings | 2237 // dispatch on type of strings |
(...skipping 4571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6809 Handle<FixedArray> frames_array = Factory::NewFixedArray(frames_count); | 6809 Handle<FixedArray> frames_array = Factory::NewFixedArray(frames_count); |
6810 for (int i = 0; i < frames_count; i++) { | 6810 for (int i = 0; i < frames_count; i++) { |
6811 Handle<JSObject> frame_value = Factory::NewJSObject(Top::object_function()); | 6811 Handle<JSObject> frame_value = Factory::NewJSObject(Top::object_function()); |
6812 frame_value->SetProperty( | 6812 frame_value->SetProperty( |
6813 *address_str, | 6813 *address_str, |
6814 *Factory::NewNumberFromInt(reinterpret_cast<int>(frames[i].address)), | 6814 *Factory::NewNumberFromInt(reinterpret_cast<int>(frames[i].address)), |
6815 NONE); | 6815 NONE); |
6816 | 6816 |
6817 // Get the stack walk text for this frame. | 6817 // Get the stack walk text for this frame. |
6818 Handle<String> frame_text; | 6818 Handle<String> frame_text; |
6819 if (strlen(frames[i].text) > 0) { | 6819 int frame_text_length = StrLength(frames[i].text); |
6820 Vector<const char> str(frames[i].text, strlen(frames[i].text)); | 6820 if (frame_text_length > 0) { |
| 6821 Vector<const char> str(frames[i].text, frame_text_length); |
6821 frame_text = Factory::NewStringFromAscii(str); | 6822 frame_text = Factory::NewStringFromAscii(str); |
6822 } | 6823 } |
6823 | 6824 |
6824 if (!frame_text.is_null()) { | 6825 if (!frame_text.is_null()) { |
6825 frame_value->SetProperty(*text_str, *frame_text, NONE); | 6826 frame_value->SetProperty(*text_str, *frame_text, NONE); |
6826 } | 6827 } |
6827 | 6828 |
6828 frames_array->set(i, *frame_value); | 6829 frames_array->set(i, *frame_value); |
6829 } | 6830 } |
6830 return *Factory::NewJSArrayWithElements(frames_array); | 6831 return *Factory::NewJSArrayWithElements(frames_array); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7277 Handle<Context> function_context(frame_context->fcontext()); | 7278 Handle<Context> function_context(frame_context->fcontext()); |
7278 context = CopyWithContextChain(frame_context, context); | 7279 context = CopyWithContextChain(frame_context, context); |
7279 | 7280 |
7280 // Wrap the evaluation statement in a new function compiled in the newly | 7281 // Wrap the evaluation statement in a new function compiled in the newly |
7281 // created context. The function has one parameter which has to be called | 7282 // created context. The function has one parameter which has to be called |
7282 // 'arguments'. This it to have access to what would have been 'arguments' in | 7283 // 'arguments'. This it to have access to what would have been 'arguments' in |
7283 // the function being debugged. | 7284 // the function being debugged. |
7284 // function(arguments,__source__) {return eval(__source__);} | 7285 // function(arguments,__source__) {return eval(__source__);} |
7285 static const char* source_str = | 7286 static const char* source_str = |
7286 "(function(arguments,__source__){return eval(__source__);})"; | 7287 "(function(arguments,__source__){return eval(__source__);})"; |
7287 static const int source_str_length = strlen(source_str); | 7288 static const int source_str_length = StrLength(source_str); |
7288 Handle<String> function_source = | 7289 Handle<String> function_source = |
7289 Factory::NewStringFromAscii(Vector<const char>(source_str, | 7290 Factory::NewStringFromAscii(Vector<const char>(source_str, |
7290 source_str_length)); | 7291 source_str_length)); |
7291 Handle<JSFunction> boilerplate = | 7292 Handle<JSFunction> boilerplate = |
7292 Compiler::CompileEval(function_source, | 7293 Compiler::CompileEval(function_source, |
7293 context, | 7294 context, |
7294 context->IsGlobalContext(), | 7295 context->IsGlobalContext(), |
7295 Compiler::DONT_VALIDATE_JSON); | 7296 Compiler::DONT_VALIDATE_JSON); |
7296 if (boilerplate.is_null()) return Failure::Exception(); | 7297 if (boilerplate.is_null()) return Failure::Exception(); |
7297 Handle<JSFunction> compiled_function = | 7298 Handle<JSFunction> compiled_function = |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7742 int frames_seen = 0; | 7743 int frames_seen = 0; |
7743 while (!iter.done() && frames_seen < limit) { | 7744 while (!iter.done() && frames_seen < limit) { |
7744 StackFrame* raw_frame = iter.frame(); | 7745 StackFrame* raw_frame = iter.frame(); |
7745 if (ShowFrameInStackTrace(raw_frame, *caller, &seen_caller)) { | 7746 if (ShowFrameInStackTrace(raw_frame, *caller, &seen_caller)) { |
7746 frames_seen++; | 7747 frames_seen++; |
7747 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); | 7748 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); |
7748 Object* recv = frame->receiver(); | 7749 Object* recv = frame->receiver(); |
7749 Object* fun = frame->function(); | 7750 Object* fun = frame->function(); |
7750 Address pc = frame->pc(); | 7751 Address pc = frame->pc(); |
7751 Address start = frame->code()->address(); | 7752 Address start = frame->code()->address(); |
7752 Smi* offset = Smi::FromInt(pc - start); | 7753 Smi* offset = Smi::FromInt(static_cast<int>(pc - start)); |
7753 FixedArray* elements = FixedArray::cast(result->elements()); | 7754 FixedArray* elements = FixedArray::cast(result->elements()); |
7754 if (cursor + 2 < elements->length()) { | 7755 if (cursor + 2 < elements->length()) { |
7755 elements->set(cursor++, recv); | 7756 elements->set(cursor++, recv); |
7756 elements->set(cursor++, fun); | 7757 elements->set(cursor++, fun); |
7757 elements->set(cursor++, offset, SKIP_WRITE_BARRIER); | 7758 elements->set(cursor++, offset, SKIP_WRITE_BARRIER); |
7758 } else { | 7759 } else { |
7759 HandleScope scope; | 7760 HandleScope scope; |
7760 Handle<Object> recv_handle(recv); | 7761 Handle<Object> recv_handle(recv); |
7761 Handle<Object> fun_handle(fun); | 7762 Handle<Object> fun_handle(fun); |
7762 SetElement(result, cursor++, recv_handle); | 7763 SetElement(result, cursor++, recv_handle); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7808 // Exclude the code in release mode. | 7809 // Exclude the code in release mode. |
7809 static Object* Runtime_ListNatives(Arguments args) { | 7810 static Object* Runtime_ListNatives(Arguments args) { |
7810 ASSERT(args.length() == 0); | 7811 ASSERT(args.length() == 0); |
7811 HandleScope scope; | 7812 HandleScope scope; |
7812 Handle<JSArray> result = Factory::NewJSArray(0); | 7813 Handle<JSArray> result = Factory::NewJSArray(0); |
7813 int index = 0; | 7814 int index = 0; |
7814 #define ADD_ENTRY(Name, argc, ressize) \ | 7815 #define ADD_ENTRY(Name, argc, ressize) \ |
7815 { \ | 7816 { \ |
7816 HandleScope inner; \ | 7817 HandleScope inner; \ |
7817 Handle<String> name = \ | 7818 Handle<String> name = \ |
7818 Factory::NewStringFromAscii(Vector<const char>(#Name, strlen(#Name))); \ | 7819 Factory::NewStringFromAscii( \ |
| 7820 Vector<const char>(#Name, StrLength(#Name))); \ |
7819 Handle<JSArray> pair = Factory::NewJSArray(0); \ | 7821 Handle<JSArray> pair = Factory::NewJSArray(0); \ |
7820 SetElement(pair, 0, name); \ | 7822 SetElement(pair, 0, name); \ |
7821 SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc))); \ | 7823 SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc))); \ |
7822 SetElement(result, index++, pair); \ | 7824 SetElement(result, index++, pair); \ |
7823 } | 7825 } |
7824 RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 7826 RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
7825 #undef ADD_ENTRY | 7827 #undef ADD_ENTRY |
7826 return *result; | 7828 return *result; |
7827 } | 7829 } |
7828 #endif | 7830 #endif |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7884 } else { | 7886 } else { |
7885 // Handle last resort GC and make sure to allow future allocations | 7887 // Handle last resort GC and make sure to allow future allocations |
7886 // to grow the heap without causing GCs (if possible). | 7888 // to grow the heap without causing GCs (if possible). |
7887 Counters::gc_last_resort_from_js.Increment(); | 7889 Counters::gc_last_resort_from_js.Increment(); |
7888 Heap::CollectAllGarbage(false); | 7890 Heap::CollectAllGarbage(false); |
7889 } | 7891 } |
7890 } | 7892 } |
7891 | 7893 |
7892 | 7894 |
7893 } } // namespace v8::internal | 7895 } } // namespace v8::internal |
OLD | NEW |