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

Side by Side Diff: src/runtime.cc

Issue 239543010: Revert "Move functions from handles.cc to where they belong." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/objects-inl.h ('k') | test/cctest/test-compiler.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 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after
2863 2863
2864 2864
2865 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { 2865 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) {
2866 HandleScope scope(isolate); 2866 HandleScope scope(isolate);
2867 ASSERT(args.length() == 1); 2867 ASSERT(args.length() == 1);
2868 2868
2869 CONVERT_ARG_CHECKED(JSFunction, fun, 0); 2869 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
2870 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); 2870 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate);
2871 if (!script->IsScript()) return isolate->heap()->undefined_value(); 2871 if (!script->IsScript()) return isolate->heap()->undefined_value();
2872 2872
2873 return *Script::GetWrapper(Handle<Script>::cast(script)); 2873 return *GetScriptWrapper(Handle<Script>::cast(script));
2874 } 2874 }
2875 2875
2876 2876
2877 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) { 2877 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) {
2878 HandleScope scope(isolate); 2878 HandleScope scope(isolate);
2879 ASSERT(args.length() == 1); 2879 ASSERT(args.length() == 1);
2880 2880
2881 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); 2881 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0);
2882 Handle<SharedFunctionInfo> shared(f->shared()); 2882 Handle<SharedFunctionInfo> shared(f->shared());
2883 return *shared->GetSourceCode(); 2883 return *shared->GetSourceCode();
(...skipping 2836 matching lines...) Expand 10 before | Expand all | Expand 10 after
5720 5720
5721 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { 5721 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) {
5722 HandleScope scope(isolate); 5722 HandleScope scope(isolate);
5723 ASSERT(args.length() == 1); 5723 ASSERT(args.length() == 1);
5724 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); 5724 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
5725 Handle<JSArray> result; 5725 Handle<JSArray> result;
5726 5726
5727 isolate->counters()->for_in()->Increment(); 5727 isolate->counters()->for_in()->Increment();
5728 Handle<FixedArray> elements; 5728 Handle<FixedArray> elements;
5729 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5729 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5730 isolate, elements, 5730 isolate, elements, GetKeysInFixedArrayFor(object, INCLUDE_PROTOS));
5731 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS));
5732 return *isolate->factory()->NewJSArrayWithElements(elements); 5731 return *isolate->factory()->NewJSArrayWithElements(elements);
5733 } 5732 }
5734 5733
5735 5734
5736 // Returns either a FixedArray as Runtime_GetPropertyNames, 5735 // Returns either a FixedArray as Runtime_GetPropertyNames,
5737 // or, if the given object has an enum cache that contains 5736 // or, if the given object has an enum cache that contains
5738 // all enumerable properties of the object and its prototypes 5737 // all enumerable properties of the object and its prototypes
5739 // have none, the map of the object. This is used to speed up 5738 // have none, the map of the object. This is used to speed up
5740 // the check for deletions during a for-in. 5739 // the check for deletions during a for-in.
5741 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { 5740 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) {
5742 SealHandleScope shs(isolate); 5741 SealHandleScope shs(isolate);
5743 ASSERT(args.length() == 1); 5742 ASSERT(args.length() == 1);
5744 5743
5745 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); 5744 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0);
5746 5745
5747 if (raw_object->IsSimpleEnum()) return raw_object->map(); 5746 if (raw_object->IsSimpleEnum()) return raw_object->map();
5748 5747
5749 HandleScope scope(isolate); 5748 HandleScope scope(isolate);
5750 Handle<JSReceiver> object(raw_object); 5749 Handle<JSReceiver> object(raw_object);
5751 Handle<FixedArray> content; 5750 Handle<FixedArray> content;
5752 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5751 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5753 isolate, content, 5752 isolate, content, GetKeysInFixedArrayFor(object, INCLUDE_PROTOS));
5754 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS));
5755 5753
5756 // Test again, since cache may have been built by preceding call. 5754 // Test again, since cache may have been built by preceding call.
5757 if (object->IsSimpleEnum()) return object->map(); 5755 if (object->IsSimpleEnum()) return object->map();
5758 5756
5759 return *content; 5757 return *content;
5760 } 5758 }
5761 5759
5762 5760
5763 // Find the length of the prototype chain that is to to handled as one. If a 5761 // Find the length of the prototype chain that is to to handled as one. If a
5764 // prototype object is hidden it is to be viewed as part of the the object it 5762 // prototype object is hidden it is to be viewed as part of the the object it
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
5926 5924
5927 5925
5928 // Return property names from named interceptor. 5926 // Return property names from named interceptor.
5929 // args[0]: object 5927 // args[0]: object
5930 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetNamedInterceptorPropertyNames) { 5928 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetNamedInterceptorPropertyNames) {
5931 HandleScope scope(isolate); 5929 HandleScope scope(isolate);
5932 ASSERT(args.length() == 1); 5930 ASSERT(args.length() == 1);
5933 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 5931 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
5934 5932
5935 if (obj->HasNamedInterceptor()) { 5933 if (obj->HasNamedInterceptor()) {
5936 Handle<JSArray> result; 5934 v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj);
5937 if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) { 5935 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
5938 return *result;
5939 }
5940 } 5936 }
5941 return isolate->heap()->undefined_value(); 5937 return isolate->heap()->undefined_value();
5942 } 5938 }
5943 5939
5944 5940
5945 // Return element names from indexed interceptor. 5941 // Return element names from indexed interceptor.
5946 // args[0]: object 5942 // args[0]: object
5947 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetIndexedInterceptorElementNames) { 5943 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetIndexedInterceptorElementNames) {
5948 HandleScope scope(isolate); 5944 HandleScope scope(isolate);
5949 ASSERT(args.length() == 1); 5945 ASSERT(args.length() == 1);
5950 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 5946 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
5951 5947
5952 if (obj->HasIndexedInterceptor()) { 5948 if (obj->HasIndexedInterceptor()) {
5953 Handle<JSArray> result; 5949 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj);
5954 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { 5950 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
5955 return *result;
5956 }
5957 } 5951 }
5958 return isolate->heap()->undefined_value(); 5952 return isolate->heap()->undefined_value();
5959 } 5953 }
5960 5954
5961 5955
5962 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { 5956 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) {
5963 HandleScope scope(isolate); 5957 HandleScope scope(isolate);
5964 ASSERT_EQ(args.length(), 1); 5958 ASSERT_EQ(args.length(), 1);
5965 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); 5959 CONVERT_ARG_CHECKED(JSObject, raw_object, 0);
5966 Handle<JSObject> object(raw_object); 5960 Handle<JSObject> object(raw_object);
5967 5961
5968 if (object->IsJSGlobalProxy()) { 5962 if (object->IsJSGlobalProxy()) {
5969 // Do access checks before going to the global object. 5963 // Do access checks before going to the global object.
5970 if (object->IsAccessCheckNeeded() && 5964 if (object->IsAccessCheckNeeded() &&
5971 !isolate->MayNamedAccess( 5965 !isolate->MayNamedAccess(
5972 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { 5966 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) {
5973 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); 5967 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS);
5974 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5968 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5975 return *isolate->factory()->NewJSArray(0); 5969 return *isolate->factory()->NewJSArray(0);
5976 } 5970 }
5977 5971
5978 Handle<Object> proto(object->GetPrototype(), isolate); 5972 Handle<Object> proto(object->GetPrototype(), isolate);
5979 // If proxy is detached we simply return an empty array. 5973 // If proxy is detached we simply return an empty array.
5980 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); 5974 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0);
5981 object = Handle<JSObject>::cast(proto); 5975 object = Handle<JSObject>::cast(proto);
5982 } 5976 }
5983 5977
5984 Handle<FixedArray> contents; 5978 Handle<FixedArray> contents;
5985 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 5979 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5986 isolate, contents, 5980 isolate, contents, GetKeysInFixedArrayFor(object, LOCAL_ONLY));
5987 JSReceiver::GetKeys(object, JSReceiver::LOCAL_ONLY));
5988 5981
5989 // Some fast paths through GetKeysInFixedArrayFor reuse a cached 5982 // Some fast paths through GetKeysInFixedArrayFor reuse a cached
5990 // property array and since the result is mutable we have to create 5983 // property array and since the result is mutable we have to create
5991 // a fresh clone on each invocation. 5984 // a fresh clone on each invocation.
5992 int length = contents->length(); 5985 int length = contents->length();
5993 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); 5986 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length);
5994 for (int i = 0; i < length; i++) { 5987 for (int i = 0; i < length; i++) {
5995 Object* entry = contents->get(i); 5988 Object* entry = contents->get(i);
5996 if (entry->IsString()) { 5989 if (entry->IsString()) {
5997 copy->set(i, entry); 5990 copy->set(i, entry);
(...skipping 5450 matching lines...) Expand 10 before | Expand all | Expand 10 after
11448 } 11441 }
11449 11442
11450 // Finally copy any properties from the function context extension. 11443 // Finally copy any properties from the function context extension.
11451 // These will be variables introduced by eval. 11444 // These will be variables introduced by eval.
11452 if (function_context->closure() == *function) { 11445 if (function_context->closure() == *function) {
11453 if (function_context->has_extension() && 11446 if (function_context->has_extension() &&
11454 !function_context->IsNativeContext()) { 11447 !function_context->IsNativeContext()) {
11455 Handle<JSObject> ext(JSObject::cast(function_context->extension())); 11448 Handle<JSObject> ext(JSObject::cast(function_context->extension()));
11456 Handle<FixedArray> keys; 11449 Handle<FixedArray> keys;
11457 ASSIGN_RETURN_ON_EXCEPTION( 11450 ASSIGN_RETURN_ON_EXCEPTION(
11458 isolate, keys, 11451 isolate, keys, GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS), JSObject);
11459 JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS),
11460 JSObject);
11461 11452
11462 for (int i = 0; i < keys->length(); i++) { 11453 for (int i = 0; i < keys->length(); i++) {
11463 // Names of variables introduced by eval are strings. 11454 // Names of variables introduced by eval are strings.
11464 ASSERT(keys->get(i)->IsString()); 11455 ASSERT(keys->get(i)->IsString());
11465 Handle<String> key(String::cast(keys->get(i))); 11456 Handle<String> key(String::cast(keys->get(i)));
11466 Handle<Object> value; 11457 Handle<Object> value;
11467 ASSIGN_RETURN_ON_EXCEPTION( 11458 ASSIGN_RETURN_ON_EXCEPTION(
11468 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); 11459 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
11469 RETURN_ON_EXCEPTION( 11460 RETURN_ON_EXCEPTION(
11470 isolate, 11461 isolate,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
11605 scope_info, context, closure_scope)) { 11596 scope_info, context, closure_scope)) {
11606 return MaybeHandle<JSObject>(); 11597 return MaybeHandle<JSObject>();
11607 } 11598 }
11608 11599
11609 // Finally copy any properties from the function context extension. This will 11600 // Finally copy any properties from the function context extension. This will
11610 // be variables introduced by eval. 11601 // be variables introduced by eval.
11611 if (context->has_extension()) { 11602 if (context->has_extension()) {
11612 Handle<JSObject> ext(JSObject::cast(context->extension())); 11603 Handle<JSObject> ext(JSObject::cast(context->extension()));
11613 Handle<FixedArray> keys; 11604 Handle<FixedArray> keys;
11614 ASSIGN_RETURN_ON_EXCEPTION( 11605 ASSIGN_RETURN_ON_EXCEPTION(
11615 isolate, keys, 11606 isolate, keys, GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS), JSObject);
11616 JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), JSObject);
11617 11607
11618 for (int i = 0; i < keys->length(); i++) { 11608 for (int i = 0; i < keys->length(); i++) {
11619 HandleScope scope(isolate); 11609 HandleScope scope(isolate);
11620 // Names of variables introduced by eval are strings. 11610 // Names of variables introduced by eval are strings.
11621 ASSERT(keys->get(i)->IsString()); 11611 ASSERT(keys->get(i)->IsString());
11622 Handle<String> key(String::cast(keys->get(i))); 11612 Handle<String> key(String::cast(keys->get(i)));
11623 Handle<Object> value; 11613 Handle<Object> value;
11624 ASSIGN_RETURN_ON_EXCEPTION( 11614 ASSIGN_RETURN_ON_EXCEPTION(
11625 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject); 11615 isolate, value, Object::GetPropertyOrElement(ext, key), JSObject);
11626 RETURN_ON_EXCEPTION( 11616 RETURN_ON_EXCEPTION(
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
12940 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); 12930 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts();
12941 12931
12942 // Convert the script objects to proper JS objects. 12932 // Convert the script objects to proper JS objects.
12943 for (int i = 0; i < instances->length(); i++) { 12933 for (int i = 0; i < instances->length(); i++) {
12944 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); 12934 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i)));
12945 // Get the script wrapper in a local handle before calling GetScriptWrapper, 12935 // Get the script wrapper in a local handle before calling GetScriptWrapper,
12946 // because using 12936 // because using
12947 // instances->set(i, *GetScriptWrapper(script)) 12937 // instances->set(i, *GetScriptWrapper(script))
12948 // is unsafe as GetScriptWrapper might call GC and the C++ compiler might 12938 // is unsafe as GetScriptWrapper might call GC and the C++ compiler might
12949 // already have dereferenced the instances handle. 12939 // already have dereferenced the instances handle.
12950 Handle<JSObject> wrapper = Script::GetWrapper(script); 12940 Handle<JSValue> wrapper = GetScriptWrapper(script);
12951 instances->set(i, *wrapper); 12941 instances->set(i, *wrapper);
12952 } 12942 }
12953 12943
12954 // Return result as a JS array. 12944 // Return result as a JS array.
12955 Handle<JSObject> result = 12945 Handle<JSObject> result =
12956 isolate->factory()->NewJSObject(isolate->array_function()); 12946 isolate->factory()->NewJSObject(isolate->array_function());
12957 JSArray::SetContent(Handle<JSArray>::cast(result), instances); 12947 JSArray::SetContent(Handle<JSArray>::cast(result), instances);
12958 return *result; 12948 return *result;
12959 } 12949 }
12960 12950
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
13351 Handle<Object> old_script_name(args[2], isolate); 13341 Handle<Object> old_script_name(args[2], isolate);
13352 13342
13353 RUNTIME_ASSERT(original_script_value->value()->IsScript()); 13343 RUNTIME_ASSERT(original_script_value->value()->IsScript());
13354 Handle<Script> original_script(Script::cast(original_script_value->value())); 13344 Handle<Script> original_script(Script::cast(original_script_value->value()));
13355 13345
13356 Handle<Object> old_script = LiveEdit::ChangeScriptSource( 13346 Handle<Object> old_script = LiveEdit::ChangeScriptSource(
13357 original_script, new_source, old_script_name); 13347 original_script, new_source, old_script_name);
13358 13348
13359 if (old_script->IsScript()) { 13349 if (old_script->IsScript()) {
13360 Handle<Script> script_handle = Handle<Script>::cast(old_script); 13350 Handle<Script> script_handle = Handle<Script>::cast(old_script);
13361 return *Script::GetWrapper(script_handle); 13351 return *(GetScriptWrapper(script_handle));
13362 } else { 13352 } else {
13363 return isolate->heap()->null_value(); 13353 return isolate->heap()->null_value();
13364 } 13354 }
13365 } 13355 }
13366 13356
13367 13357
13368 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) { 13358 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) {
13369 HandleScope scope(isolate); 13359 HandleScope scope(isolate);
13370 CHECK(isolate->debugger()->live_edit_enabled()); 13360 CHECK(isolate->debugger()->live_edit_enabled());
13371 ASSERT(args.length() == 1); 13361 ASSERT(args.length() == 1);
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
14367 script = Handle<Script>(Script::cast(obj)); 14357 script = Handle<Script>(Script::cast(obj));
14368 } 14358 }
14369 } 14359 }
14370 } 14360 }
14371 } 14361 }
14372 14362
14373 // If no script with the requested script data is found return undefined. 14363 // If no script with the requested script data is found return undefined.
14374 if (script.is_null()) return factory->undefined_value(); 14364 if (script.is_null()) return factory->undefined_value();
14375 14365
14376 // Return the script found. 14366 // Return the script found.
14377 return Script::GetWrapper(script); 14367 return GetScriptWrapper(script);
14378 } 14368 }
14379 14369
14380 14370
14381 // Get the script object from script data. NOTE: Regarding performance 14371 // Get the script object from script data. NOTE: Regarding performance
14382 // see the NOTE for GetScriptFromScriptData. 14372 // see the NOTE for GetScriptFromScriptData.
14383 // args[0]: script data for the script to find the source for 14373 // args[0]: script data for the script to find the source for
14384 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) { 14374 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) {
14385 HandleScope scope(isolate); 14375 HandleScope scope(isolate);
14386 14376
14387 ASSERT(args.length() == 1); 14377 ASSERT(args.length() == 1);
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
15094 } 15084 }
15095 } 15085 }
15096 15086
15097 15087
15098 void Runtime::OutOfMemory() { 15088 void Runtime::OutOfMemory() {
15099 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15089 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15100 UNREACHABLE(); 15090 UNREACHABLE();
15101 } 15091 }
15102 15092
15103 } } // namespace v8::internal 15093 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698