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

Side by Side Diff: src/runtime.cc

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