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

Side by Side Diff: src/runtime.cc

Issue 12254007: Make the Isolate parameter mandatory for internal HandleScopes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 3539 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 return value->SubString(start, end); 3550 return value->SubString(start, end);
3551 } 3551 }
3552 3552
3553 3553
3554 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { 3554 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
3555 ASSERT_EQ(3, args.length()); 3555 ASSERT_EQ(3, args.length());
3556 3556
3557 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 3557 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
3558 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 3558 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
3559 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); 3559 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
3560 HandleScope handles; 3560 HandleScope handles(isolate);
3561 3561
3562 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); 3562 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate);
3563 if (global_cache.HasException()) return Failure::Exception(); 3563 if (global_cache.HasException()) return Failure::Exception();
3564 3564
3565 int capture_count = regexp->CaptureCount(); 3565 int capture_count = regexp->CaptureCount();
3566 3566
3567 Zone* zone = isolate->runtime_zone(); 3567 Zone* zone = isolate->runtime_zone();
3568 ZoneScope zone_space(zone, DELETE_ON_EXIT); 3568 ZoneScope zone_space(zone, DELETE_ON_EXIT);
3569 ZoneList<int> offsets(8, zone); 3569 ZoneList<int> offsets(8, zone);
3570 3570
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
4448 } 4448 }
4449 4449
4450 4450
4451 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { 4451 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
4452 RUNTIME_ASSERT(args.length() == 5); 4452 RUNTIME_ASSERT(args.length() == 5);
4453 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 4453 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
4454 CONVERT_SMI_ARG_CHECKED(store_index, 1); 4454 CONVERT_SMI_ARG_CHECKED(store_index, 1);
4455 Handle<Object> value = args.at<Object>(2); 4455 Handle<Object> value = args.at<Object>(2);
4456 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); 4456 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3);
4457 CONVERT_SMI_ARG_CHECKED(literal_index, 4); 4457 CONVERT_SMI_ARG_CHECKED(literal_index, 4);
4458 HandleScope scope; 4458 HandleScope scope(isolate);
4459 4459
4460 Object* raw_boilerplate_object = literals->get(literal_index); 4460 Object* raw_boilerplate_object = literals->get(literal_index);
4461 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); 4461 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object));
4462 ElementsKind elements_kind = object->GetElementsKind(); 4462 ElementsKind elements_kind = object->GetElementsKind();
4463 ASSERT(IsFastElementsKind(elements_kind)); 4463 ASSERT(IsFastElementsKind(elements_kind));
4464 // Smis should never trigger transitions. 4464 // Smis should never trigger transitions.
4465 ASSERT(!value->IsSmi()); 4465 ASSERT(!value->IsSmi());
4466 4466
4467 if (value->IsNumber()) { 4467 if (value->IsNumber()) {
4468 ASSERT(IsFastSmiElementsKind(elements_kind)); 4468 ASSERT(IsFastSmiElementsKind(elements_kind));
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
6149 ASSERT(result->HasFastObjectElements()); 6149 ASSERT(result->HasFastObjectElements());
6150 6150
6151 if (part_count == 1 && indices.at(0) == subject_length) { 6151 if (part_count == 1 && indices.at(0) == subject_length) {
6152 FixedArray::cast(result->elements())->set(0, *subject); 6152 FixedArray::cast(result->elements())->set(0, *subject);
6153 return *result; 6153 return *result;
6154 } 6154 }
6155 6155
6156 Handle<FixedArray> elements(FixedArray::cast(result->elements())); 6156 Handle<FixedArray> elements(FixedArray::cast(result->elements()));
6157 int part_start = 0; 6157 int part_start = 0;
6158 for (int i = 0; i < part_count; i++) { 6158 for (int i = 0; i < part_count; i++) {
6159 HandleScope local_loop_handle; 6159 HandleScope local_loop_handle(isolate);
6160 int part_end = indices.at(i); 6160 int part_end = indices.at(i);
6161 Handle<String> substring = 6161 Handle<String> substring =
6162 isolate->factory()->NewProperSubString(subject, part_start, part_end); 6162 isolate->factory()->NewProperSubString(subject, part_start, part_end);
6163 elements->set(i, *substring); 6163 elements->set(i, *substring);
6164 part_start = part_end + pattern_length; 6164 part_start = part_end + pattern_length;
6165 } 6165 }
6166 6166
6167 if (limit == 0xffffffffu) { 6167 if (limit == 0xffffffffu) {
6168 if (result->HasFastObjectElements()) { 6168 if (result->HasFastObjectElements()) {
6169 RegExpResultsCache::Enter(isolate->heap(), 6169 RegExpResultsCache::Enter(isolate->heap(),
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
7562 context, 7562 context,
7563 pretenure_flag); 7563 pretenure_flag);
7564 return *result; 7564 return *result;
7565 } 7565 }
7566 7566
7567 7567
7568 // Find the arguments of the JavaScript function invocation that called 7568 // Find the arguments of the JavaScript function invocation that called
7569 // into C++ code. Collect these in a newly allocated array of handles (possibly 7569 // into C++ code. Collect these in a newly allocated array of handles (possibly
7570 // prefixed by a number of empty handles). 7570 // prefixed by a number of empty handles).
7571 static SmartArrayPointer<Handle<Object> > GetCallerArguments( 7571 static SmartArrayPointer<Handle<Object> > GetCallerArguments(
7572 Isolate* isolate,
7572 int prefix_argc, 7573 int prefix_argc,
7573 int* total_argc) { 7574 int* total_argc) {
7574 // Find frame containing arguments passed to the caller. 7575 // Find frame containing arguments passed to the caller.
7575 JavaScriptFrameIterator it; 7576 JavaScriptFrameIterator it(isolate);
7576 JavaScriptFrame* frame = it.frame(); 7577 JavaScriptFrame* frame = it.frame();
7577 List<JSFunction*> functions(2); 7578 List<JSFunction*> functions(2);
7578 frame->GetFunctions(&functions); 7579 frame->GetFunctions(&functions);
7579 if (functions.length() > 1) { 7580 if (functions.length() > 1) {
7580 int inlined_jsframe_index = functions.length() - 1; 7581 int inlined_jsframe_index = functions.length() - 1;
7581 JSFunction* inlined_function = functions[inlined_jsframe_index]; 7582 JSFunction* inlined_function = functions[inlined_jsframe_index];
7582 Vector<SlotRef> args_slots = 7583 Vector<SlotRef> args_slots =
7583 SlotRef::ComputeSlotMappingForArguments( 7584 SlotRef::ComputeSlotMappingForArguments(
7584 frame, 7585 frame,
7585 inlined_jsframe_index, 7586 inlined_jsframe_index,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
7619 HandleScope scope(isolate); 7620 HandleScope scope(isolate);
7620 ASSERT(args.length() == 4); 7621 ASSERT(args.length() == 4);
7621 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0); 7622 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0);
7622 RUNTIME_ASSERT(args[3]->IsNumber()); 7623 RUNTIME_ASSERT(args[3]->IsNumber());
7623 Handle<Object> bindee = args.at<Object>(1); 7624 Handle<Object> bindee = args.at<Object>(1);
7624 7625
7625 // TODO(lrn): Create bound function in C++ code from premade shared info. 7626 // TODO(lrn): Create bound function in C++ code from premade shared info.
7626 bound_function->shared()->set_bound(true); 7627 bound_function->shared()->set_bound(true);
7627 // Get all arguments of calling function (Function.prototype.bind). 7628 // Get all arguments of calling function (Function.prototype.bind).
7628 int argc = 0; 7629 int argc = 0;
7629 SmartArrayPointer<Handle<Object> > arguments = GetCallerArguments(0, &argc); 7630 SmartArrayPointer<Handle<Object> > arguments =
7631 GetCallerArguments(isolate, 0, &argc);
7630 // Don't count the this-arg. 7632 // Don't count the this-arg.
7631 if (argc > 0) { 7633 if (argc > 0) {
7632 ASSERT(*arguments[0] == args[2]); 7634 ASSERT(*arguments[0] == args[2]);
7633 argc--; 7635 argc--;
7634 } else { 7636 } else {
7635 ASSERT(args[2]->IsUndefined()); 7637 ASSERT(args[2]->IsUndefined());
7636 } 7638 }
7637 // Initialize array of bindings (function, this, and any existing arguments 7639 // Initialize array of bindings (function, this, and any existing arguments
7638 // if the function was already bound). 7640 // if the function was already bound).
7639 Handle<FixedArray> new_bindings; 7641 Handle<FixedArray> new_bindings;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
7701 Handle<FixedArray> bound_args = 7703 Handle<FixedArray> bound_args =
7702 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); 7704 Handle<FixedArray>(FixedArray::cast(function->function_bindings()));
7703 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex; 7705 int bound_argc = bound_args->length() - JSFunction::kBoundArgumentsStartIndex;
7704 Handle<Object> bound_function( 7706 Handle<Object> bound_function(
7705 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex))); 7707 JSReceiver::cast(bound_args->get(JSFunction::kBoundFunctionIndex)));
7706 ASSERT(!bound_function->IsJSFunction() || 7708 ASSERT(!bound_function->IsJSFunction() ||
7707 !Handle<JSFunction>::cast(bound_function)->shared()->bound()); 7709 !Handle<JSFunction>::cast(bound_function)->shared()->bound());
7708 7710
7709 int total_argc = 0; 7711 int total_argc = 0;
7710 SmartArrayPointer<Handle<Object> > param_data = 7712 SmartArrayPointer<Handle<Object> > param_data =
7711 GetCallerArguments(bound_argc, &total_argc); 7713 GetCallerArguments(isolate, bound_argc, &total_argc);
7712 for (int i = 0; i < bound_argc; i++) { 7714 for (int i = 0; i < bound_argc; i++) {
7713 param_data[i] = Handle<Object>(bound_args->get( 7715 param_data[i] = Handle<Object>(bound_args->get(
7714 JSFunction::kBoundArgumentsStartIndex + i)); 7716 JSFunction::kBoundArgumentsStartIndex + i));
7715 } 7717 }
7716 7718
7717 if (!bound_function->IsJSFunction()) { 7719 if (!bound_function->IsJSFunction()) {
7718 bool exception_thrown; 7720 bool exception_thrown;
7719 bound_function = Execution::TryGetConstructorDelegate(bound_function, 7721 bound_function = Execution::TryGetConstructorDelegate(bound_function,
7720 &exception_thrown); 7722 &exception_thrown);
7721 if (exception_thrown) return Failure::Exception(); 7723 if (exception_thrown) return Failure::Exception();
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
8908 return Execution::HandleStackGuardInterrupt(isolate); 8910 return Execution::HandleStackGuardInterrupt(isolate);
8909 } 8911 }
8910 8912
8911 8913
8912 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) { 8914 RUNTIME_FUNCTION(MaybeObject*, Runtime_Interrupt) {
8913 ASSERT(args.length() == 0); 8915 ASSERT(args.length() == 0);
8914 return Execution::HandleStackGuardInterrupt(isolate); 8916 return Execution::HandleStackGuardInterrupt(isolate);
8915 } 8917 }
8916 8918
8917 8919
8918 static int StackSize() { 8920 static int StackSize(Isolate* isolate) {
8919 int n = 0; 8921 int n = 0;
8920 for (JavaScriptFrameIterator it; !it.done(); it.Advance()) n++; 8922 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++;
8921 return n; 8923 return n;
8922 } 8924 }
8923 8925
8924 8926
8925 static void PrintTransition(Object* result) { 8927 static void PrintTransition(Isolate* isolate, Object* result) {
8926 // indentation 8928 // indentation
8927 { const int nmax = 80; 8929 { const int nmax = 80;
8928 int n = StackSize(); 8930 int n = StackSize(isolate);
8929 if (n <= nmax) 8931 if (n <= nmax)
8930 PrintF("%4d:%*s", n, n, ""); 8932 PrintF("%4d:%*s", n, n, "");
8931 else 8933 else
8932 PrintF("%4d:%*s", n, nmax, "..."); 8934 PrintF("%4d:%*s", n, nmax, "...");
8933 } 8935 }
8934 8936
8935 if (result == NULL) { 8937 if (result == NULL) {
8936 JavaScriptFrame::PrintTop(stdout, true, false); 8938 JavaScriptFrame::PrintTop(isolate, stdout, true, false);
8937 PrintF(" {\n"); 8939 PrintF(" {\n");
8938 } else { 8940 } else {
8939 // function result 8941 // function result
8940 PrintF("} -> "); 8942 PrintF("} -> ");
8941 result->ShortPrint(); 8943 result->ShortPrint();
8942 PrintF("\n"); 8944 PrintF("\n");
8943 } 8945 }
8944 } 8946 }
8945 8947
8946 8948
8947 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { 8949 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) {
8948 ASSERT(args.length() == 0); 8950 ASSERT(args.length() == 0);
8949 NoHandleAllocation ha; 8951 NoHandleAllocation ha;
8950 PrintTransition(NULL); 8952 PrintTransition(isolate, NULL);
8951 return isolate->heap()->undefined_value(); 8953 return isolate->heap()->undefined_value();
8952 } 8954 }
8953 8955
8954 8956
8955 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { 8957 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) {
8956 NoHandleAllocation ha; 8958 NoHandleAllocation ha;
8957 PrintTransition(args[0]); 8959 PrintTransition(isolate, args[0]);
8958 return args[0]; // return TOS 8960 return args[0]; // return TOS
8959 } 8961 }
8960 8962
8961 8963
8962 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { 8964 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) {
8963 NoHandleAllocation ha; 8965 NoHandleAllocation ha;
8964 ASSERT(args.length() == 1); 8966 ASSERT(args.length() == 1);
8965 8967
8966 #ifdef DEBUG 8968 #ifdef DEBUG
8967 if (args[0]->IsString()) { 8969 if (args[0]->IsString()) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
9359 private: 9361 private:
9360 // Convert storage to dictionary mode. 9362 // Convert storage to dictionary mode.
9361 void SetDictionaryMode(uint32_t index) { 9363 void SetDictionaryMode(uint32_t index) {
9362 ASSERT(fast_elements_); 9364 ASSERT(fast_elements_);
9363 Handle<FixedArray> current_storage(*storage_); 9365 Handle<FixedArray> current_storage(*storage_);
9364 Handle<SeededNumberDictionary> slow_storage( 9366 Handle<SeededNumberDictionary> slow_storage(
9365 isolate_->factory()->NewSeededNumberDictionary( 9367 isolate_->factory()->NewSeededNumberDictionary(
9366 current_storage->length())); 9368 current_storage->length()));
9367 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); 9369 uint32_t current_length = static_cast<uint32_t>(current_storage->length());
9368 for (uint32_t i = 0; i < current_length; i++) { 9370 for (uint32_t i = 0; i < current_length; i++) {
9369 HandleScope loop_scope; 9371 HandleScope loop_scope(isolate_);
9370 Handle<Object> element(current_storage->get(i)); 9372 Handle<Object> element(current_storage->get(i));
9371 if (!element->IsTheHole()) { 9373 if (!element->IsTheHole()) {
9372 Handle<SeededNumberDictionary> new_storage = 9374 Handle<SeededNumberDictionary> new_storage =
9373 isolate_->factory()->DictionaryAtNumberPut(slow_storage, i, element); 9375 isolate_->factory()->DictionaryAtNumberPut(slow_storage, i, element);
9374 if (!new_storage.is_identical_to(slow_storage)) { 9376 if (!new_storage.is_identical_to(slow_storage)) {
9375 slow_storage = loop_scope.CloseAndEscape(new_storage); 9377 slow_storage = loop_scope.CloseAndEscape(new_storage);
9376 } 9378 }
9377 } 9379 }
9378 } 9380 }
9379 clear_storage(); 9381 clear_storage();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
9474 bool elements_are_guaranteed_smis, 9476 bool elements_are_guaranteed_smis,
9475 ArrayConcatVisitor* visitor) { 9477 ArrayConcatVisitor* visitor) {
9476 Handle<ExternalArrayClass> array( 9478 Handle<ExternalArrayClass> array(
9477 ExternalArrayClass::cast(receiver->elements())); 9479 ExternalArrayClass::cast(receiver->elements()));
9478 uint32_t len = static_cast<uint32_t>(array->length()); 9480 uint32_t len = static_cast<uint32_t>(array->length());
9479 9481
9480 ASSERT(visitor != NULL); 9482 ASSERT(visitor != NULL);
9481 if (elements_are_ints) { 9483 if (elements_are_ints) {
9482 if (elements_are_guaranteed_smis) { 9484 if (elements_are_guaranteed_smis) {
9483 for (uint32_t j = 0; j < len; j++) { 9485 for (uint32_t j = 0; j < len; j++) {
9484 HandleScope loop_scope; 9486 HandleScope loop_scope(isolate);
9485 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j)))); 9487 Handle<Smi> e(Smi::FromInt(static_cast<int>(array->get_scalar(j))));
9486 visitor->visit(j, e); 9488 visitor->visit(j, e);
9487 } 9489 }
9488 } else { 9490 } else {
9489 for (uint32_t j = 0; j < len; j++) { 9491 for (uint32_t j = 0; j < len; j++) {
9490 HandleScope loop_scope; 9492 HandleScope loop_scope(isolate);
9491 int64_t val = static_cast<int64_t>(array->get_scalar(j)); 9493 int64_t val = static_cast<int64_t>(array->get_scalar(j));
9492 if (Smi::IsValid(static_cast<intptr_t>(val))) { 9494 if (Smi::IsValid(static_cast<intptr_t>(val))) {
9493 Handle<Smi> e(Smi::FromInt(static_cast<int>(val))); 9495 Handle<Smi> e(Smi::FromInt(static_cast<int>(val)));
9494 visitor->visit(j, e); 9496 visitor->visit(j, e);
9495 } else { 9497 } else {
9496 Handle<Object> e = 9498 Handle<Object> e =
9497 isolate->factory()->NewNumber(static_cast<ElementType>(val)); 9499 isolate->factory()->NewNumber(static_cast<ElementType>(val));
9498 visitor->visit(j, e); 9500 visitor->visit(j, e);
9499 } 9501 }
9500 } 9502 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9540 case FAST_DOUBLE_ELEMENTS: { 9542 case FAST_DOUBLE_ELEMENTS: {
9541 // TODO(1810): Decide if it's worthwhile to implement this. 9543 // TODO(1810): Decide if it's worthwhile to implement this.
9542 UNREACHABLE(); 9544 UNREACHABLE();
9543 break; 9545 break;
9544 } 9546 }
9545 case DICTIONARY_ELEMENTS: { 9547 case DICTIONARY_ELEMENTS: {
9546 Handle<SeededNumberDictionary> dict( 9548 Handle<SeededNumberDictionary> dict(
9547 SeededNumberDictionary::cast(object->elements())); 9549 SeededNumberDictionary::cast(object->elements()));
9548 uint32_t capacity = dict->Capacity(); 9550 uint32_t capacity = dict->Capacity();
9549 for (uint32_t j = 0; j < capacity; j++) { 9551 for (uint32_t j = 0; j < capacity; j++) {
9550 HandleScope loop_scope; 9552 HandleScope loop_scope(object->GetIsolate());
9551 Handle<Object> k(dict->KeyAt(j)); 9553 Handle<Object> k(dict->KeyAt(j));
9552 if (dict->IsKey(*k)) { 9554 if (dict->IsKey(*k)) {
9553 ASSERT(k->IsNumber()); 9555 ASSERT(k->IsNumber());
9554 uint32_t index = static_cast<uint32_t>(k->Number()); 9556 uint32_t index = static_cast<uint32_t>(k->Number());
9555 if (index < range) { 9557 if (index < range) {
9556 indices->Add(index); 9558 indices->Add(index);
9557 } 9559 }
9558 } 9560 }
9559 } 9561 }
9560 break; 9562 break;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
9703 case DICTIONARY_ELEMENTS: { 9705 case DICTIONARY_ELEMENTS: {
9704 Handle<SeededNumberDictionary> dict(receiver->element_dictionary()); 9706 Handle<SeededNumberDictionary> dict(receiver->element_dictionary());
9705 List<uint32_t> indices(dict->Capacity() / 2); 9707 List<uint32_t> indices(dict->Capacity() / 2);
9706 // Collect all indices in the object and the prototypes less 9708 // Collect all indices in the object and the prototypes less
9707 // than length. This might introduce duplicates in the indices list. 9709 // than length. This might introduce duplicates in the indices list.
9708 CollectElementIndices(receiver, length, &indices); 9710 CollectElementIndices(receiver, length, &indices);
9709 indices.Sort(&compareUInt32); 9711 indices.Sort(&compareUInt32);
9710 int j = 0; 9712 int j = 0;
9711 int n = indices.length(); 9713 int n = indices.length();
9712 while (j < n) { 9714 while (j < n) {
9713 HandleScope loop_scope; 9715 HandleScope loop_scope(isolate);
9714 uint32_t index = indices[j]; 9716 uint32_t index = indices[j];
9715 Handle<Object> element = Object::GetElement(receiver, index); 9717 Handle<Object> element = Object::GetElement(receiver, index);
9716 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false); 9718 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, element, false);
9717 visitor->visit(index, element); 9719 visitor->visit(index, element);
9718 // Skip to next different index (i.e., omit duplicates). 9720 // Skip to next different index (i.e., omit duplicates).
9719 do { 9721 do {
9720 j++; 9722 j++;
9721 } while (j < n && indices[j] == index); 9723 } while (j < n && indices[j] == index);
9722 } 9724 }
9723 break; 9725 break;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
9798 // Pass 1: estimate the length and number of elements of the result. 9800 // Pass 1: estimate the length and number of elements of the result.
9799 // The actual length can be larger if any of the arguments have getters 9801 // The actual length can be larger if any of the arguments have getters
9800 // that mutate other arguments (but will otherwise be precise). 9802 // that mutate other arguments (but will otherwise be precise).
9801 // The number of elements is precise if there are no inherited elements. 9803 // The number of elements is precise if there are no inherited elements.
9802 9804
9803 ElementsKind kind = FAST_SMI_ELEMENTS; 9805 ElementsKind kind = FAST_SMI_ELEMENTS;
9804 9806
9805 uint32_t estimate_result_length = 0; 9807 uint32_t estimate_result_length = 0;
9806 uint32_t estimate_nof_elements = 0; 9808 uint32_t estimate_nof_elements = 0;
9807 for (int i = 0; i < argument_count; i++) { 9809 for (int i = 0; i < argument_count; i++) {
9808 HandleScope loop_scope; 9810 HandleScope loop_scope(isolate);
9809 Handle<Object> obj(elements->get(i)); 9811 Handle<Object> obj(elements->get(i));
9810 uint32_t length_estimate; 9812 uint32_t length_estimate;
9811 uint32_t element_estimate; 9813 uint32_t element_estimate;
9812 if (obj->IsJSArray()) { 9814 if (obj->IsJSArray()) {
9813 Handle<JSArray> array(Handle<JSArray>::cast(obj)); 9815 Handle<JSArray> array(Handle<JSArray>::cast(obj));
9814 length_estimate = static_cast<uint32_t>(array->length()->Number()); 9816 length_estimate = static_cast<uint32_t>(array->length()->Number());
9815 if (length_estimate != 0) { 9817 if (length_estimate != 0) {
9816 ElementsKind array_kind = 9818 ElementsKind array_kind =
9817 GetPackedElementsKind(array->map()->elements_kind()); 9819 GetPackedElementsKind(array->map()->elements_kind());
9818 if (IsMoreGeneralElementsKindTransition(kind, array_kind)) { 9820 if (IsMoreGeneralElementsKindTransition(kind, array_kind)) {
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after
11681 return isolate->heap()->ToBoolean(res); 11683 return isolate->heap()->ToBoolean(res);
11682 } 11684 }
11683 11685
11684 11686
11685 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { 11687 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) {
11686 HandleScope scope(isolate); 11688 HandleScope scope(isolate);
11687 ASSERT(args.length() == 0); 11689 ASSERT(args.length() == 0);
11688 11690
11689 #ifdef DEBUG 11691 #ifdef DEBUG
11690 // Print the scopes for the top frame. 11692 // Print the scopes for the top frame.
11691 StackFrameLocator locator; 11693 StackFrameLocator locator(isolate);
11692 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); 11694 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
11693 for (ScopeIterator it(isolate, frame, 0); 11695 for (ScopeIterator it(isolate, frame, 0);
11694 !it.Done(); 11696 !it.Done();
11695 it.Next()) { 11697 it.Next()) {
11696 it.DebugPrint(); 11698 it.DebugPrint();
11697 } 11699 }
11698 #endif 11700 #endif
11699 return isolate->heap()->undefined_value(); 11701 return isolate->heap()->undefined_value();
11700 } 11702 }
11701 11703
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
13268 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); 13270 CONVERT_ARG_CHECKED(JSMessageObject, message, 0);
13269 return message->script(); 13271 return message->script();
13270 } 13272 }
13271 13273
13272 13274
13273 #ifdef DEBUG 13275 #ifdef DEBUG
13274 // ListNatives is ONLY used by the fuzz-natives.js in debug mode 13276 // ListNatives is ONLY used by the fuzz-natives.js in debug mode
13275 // Exclude the code in release mode. 13277 // Exclude the code in release mode.
13276 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { 13278 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) {
13277 ASSERT(args.length() == 0); 13279 ASSERT(args.length() == 0);
13278 HandleScope scope; 13280 HandleScope scope(isolate);
13279 #define COUNT_ENTRY(Name, argc, ressize) + 1 13281 #define COUNT_ENTRY(Name, argc, ressize) + 1
13280 int entry_count = 0 13282 int entry_count = 0
13281 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) 13283 RUNTIME_FUNCTION_LIST(COUNT_ENTRY)
13282 INLINE_FUNCTION_LIST(COUNT_ENTRY) 13284 INLINE_FUNCTION_LIST(COUNT_ENTRY)
13283 INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY); 13285 INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY);
13284 #undef COUNT_ENTRY 13286 #undef COUNT_ENTRY
13285 Factory* factory = isolate->factory(); 13287 Factory* factory = isolate->factory();
13286 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); 13288 Handle<FixedArray> elements = factory->NewFixedArray(entry_count);
13287 int index = 0; 13289 int index = 0;
13288 bool inline_runtime_functions = false; 13290 bool inline_runtime_functions = false;
13289 #define ADD_ENTRY(Name, argc, ressize) \ 13291 #define ADD_ENTRY(Name, argc, ressize) \
13290 { \ 13292 { \
13291 HandleScope inner; \ 13293 HandleScope inner(isolate); \
13292 Handle<String> name; \ 13294 Handle<String> name; \
13293 /* Inline runtime functions have an underscore in front of the name. */ \ 13295 /* Inline runtime functions have an underscore in front of the name. */ \
13294 if (inline_runtime_functions) { \ 13296 if (inline_runtime_functions) { \
13295 name = factory->NewStringFromAscii( \ 13297 name = factory->NewStringFromAscii( \
13296 Vector<const char>("_" #Name, StrLength("_" #Name))); \ 13298 Vector<const char>("_" #Name, StrLength("_" #Name))); \
13297 } else { \ 13299 } else { \
13298 name = factory->NewStringFromAscii( \ 13300 name = factory->NewStringFromAscii( \
13299 Vector<const char>(#Name, StrLength(#Name))); \ 13301 Vector<const char>(#Name, StrLength(#Name))); \
13300 } \ 13302 } \
13301 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \ 13303 Handle<FixedArray> pair_elements = factory->NewFixedArray(2); \
(...skipping 15 matching lines...) Expand all
13317 #endif 13319 #endif
13318 13320
13319 13321
13320 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { 13322 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) {
13321 ASSERT(args.length() == 2); 13323 ASSERT(args.length() == 2);
13322 CONVERT_ARG_CHECKED(String, format, 0); 13324 CONVERT_ARG_CHECKED(String, format, 0);
13323 CONVERT_ARG_CHECKED(JSArray, elms, 1); 13325 CONVERT_ARG_CHECKED(JSArray, elms, 1);
13324 String::FlatContent format_content = format->GetFlatContent(); 13326 String::FlatContent format_content = format->GetFlatContent();
13325 RUNTIME_ASSERT(format_content.IsAscii()); 13327 RUNTIME_ASSERT(format_content.IsAscii());
13326 Vector<const uint8_t> chars = format_content.ToOneByteVector(); 13328 Vector<const uint8_t> chars = format_content.ToOneByteVector();
13327 LOGGER->LogRuntime(Vector<const char>::cast(chars), elms); 13329 LOGGER->LogRuntime(isolate, Vector<const char>::cast(chars), elms);
13328 return isolate->heap()->undefined_value(); 13330 return isolate->heap()->undefined_value();
13329 } 13331 }
13330 13332
13331 13333
13332 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { 13334 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) {
13333 UNREACHABLE(); // implemented as macro in the parser 13335 UNREACHABLE(); // implemented as macro in the parser
13334 return NULL; 13336 return NULL;
13335 } 13337 }
13336 13338
13337 13339
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
13531 // Handle last resort GC and make sure to allow future allocations 13533 // Handle last resort GC and make sure to allow future allocations
13532 // to grow the heap without causing GCs (if possible). 13534 // to grow the heap without causing GCs (if possible).
13533 isolate->counters()->gc_last_resort_from_js()->Increment(); 13535 isolate->counters()->gc_last_resort_from_js()->Increment();
13534 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13536 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13535 "Runtime::PerformGC"); 13537 "Runtime::PerformGC");
13536 } 13538 }
13537 } 13539 }
13538 13540
13539 13541
13540 } } // namespace v8::internal 13542 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698