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

Side by Side Diff: src/runtime.cc

Issue 2866008: [Isolates] Move contents of Top into Isolate.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: ensure we're synced Created 10 years, 6 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/regexp-stack.cc ('k') | src/serialize.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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "scopeinfo.h" 46 #include "scopeinfo.h"
47 #include "smart-pointer.h" 47 #include "smart-pointer.h"
48 #include "stub-cache.h" 48 #include "stub-cache.h"
49 #include "v8threads.h" 49 #include "v8threads.h"
50 50
51 namespace v8 { 51 namespace v8 {
52 namespace internal { 52 namespace internal {
53 53
54 54
55 #define RUNTIME_ASSERT(value) \ 55 #define RUNTIME_ASSERT(value) \
56 if (!(value)) return Top::ThrowIllegalOperation(); 56 if (!(value)) return Isolate::Current()->ThrowIllegalOperation();
57 57
58 // Cast the given object to a value of the specified type and store 58 // Cast the given object to a value of the specified type and store
59 // it in a variable with the given name. If the object is not of the 59 // it in a variable with the given name. If the object is not of the
60 // expected type call IllegalOperation and return. 60 // expected type call IllegalOperation and return.
61 #define CONVERT_CHECKED(Type, name, obj) \ 61 #define CONVERT_CHECKED(Type, name, obj) \
62 RUNTIME_ASSERT(obj->Is##Type()); \ 62 RUNTIME_ASSERT(obj->Is##Type()); \
63 Type* name = Type::cast(obj); 63 Type* name = Type::cast(obj);
64 64
65 #define CONVERT_ARG_CHECKED(Type, name, index) \ 65 #define CONVERT_ARG_CHECKED(Type, name, index) \
66 RUNTIME_ASSERT(args[index]->Is##Type()); \ 66 RUNTIME_ASSERT(args[index]->Is##Type()); \
(...skipping 26 matching lines...) Expand all
93 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ 93 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
94 RUNTIME_ASSERT(obj->IsNumber()); \ 94 RUNTIME_ASSERT(obj->IsNumber()); \
95 type name = NumberTo##Type(obj); 95 type name = NumberTo##Type(obj);
96 96
97 // Non-reentrant string buffer for efficient general use in this file. 97 // Non-reentrant string buffer for efficient general use in this file.
98 static StaticResource<StringInputBuffer> runtime_string_input_buffer; 98 static StaticResource<StringInputBuffer> runtime_string_input_buffer;
99 99
100 100
101 static Object* DeepCopyBoilerplate(Heap* heap, JSObject* boilerplate) { 101 static Object* DeepCopyBoilerplate(Heap* heap, JSObject* boilerplate) {
102 StackLimitCheck check; 102 StackLimitCheck check;
103 if (check.HasOverflowed()) return Top::StackOverflow(); 103 if (check.HasOverflowed()) return Isolate::Current()->StackOverflow();
104 104
105 Object* result = heap->CopyJSObject(boilerplate); 105 Object* result = heap->CopyJSObject(boilerplate);
106 if (result->IsFailure()) return result; 106 if (result->IsFailure()) return result;
107 JSObject* copy = JSObject::cast(result); 107 JSObject* copy = JSObject::cast(result);
108 108
109 // Deep copy local properties. 109 // Deep copy local properties.
110 if (copy->HasFastProperties()) { 110 if (copy->HasFastProperties()) {
111 FixedArray* properties = copy->properties(); 111 FixedArray* properties = copy->properties();
112 for (int i = 0; i < properties->length(); i++) { 112 for (int i = 0; i < properties->length(); i++) {
113 Object* value = properties->get(i); 113 Object* value = properties->get(i);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 return HEAP->CopyJSObject(JSObject::cast(*boilerplate)); 467 return HEAP->CopyJSObject(JSObject::cast(*boilerplate));
468 } 468 }
469 469
470 470
471 static Object* Runtime_CreateCatchExtensionObject(Arguments args) { 471 static Object* Runtime_CreateCatchExtensionObject(Arguments args) {
472 ASSERT(args.length() == 2); 472 ASSERT(args.length() == 2);
473 CONVERT_CHECKED(String, key, args[0]); 473 CONVERT_CHECKED(String, key, args[0]);
474 Object* value = args[1]; 474 Object* value = args[1];
475 // Create a catch context extension object. 475 // Create a catch context extension object.
476 JSFunction* constructor = 476 JSFunction* constructor =
477 Top::context()->global_context()->context_extension_function(); 477 Isolate::Current()->context()->global_context()->
478 context_extension_function();
478 Object* object = HEAP->AllocateJSObject(constructor); 479 Object* object = HEAP->AllocateJSObject(constructor);
479 if (object->IsFailure()) return object; 480 if (object->IsFailure()) return object;
480 // Assign the exception value to the catch variable and make sure 481 // Assign the exception value to the catch variable and make sure
481 // that the catch variable is DontDelete. 482 // that the catch variable is DontDelete.
482 value = JSObject::cast(object)->SetProperty(key, value, DONT_DELETE); 483 value = JSObject::cast(object)->SetProperty(key, value, DONT_DELETE);
483 if (value->IsFailure()) return value; 484 if (value->IsFailure()) return value;
484 return object; 485 return object;
485 } 486 }
486 487
487 488
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 return HEAP->undefined_value(); 766 return HEAP->undefined_value();
766 } 767 }
767 768
768 769
769 static Object* ThrowRedeclarationError(const char* type, Handle<String> name) { 770 static Object* ThrowRedeclarationError(const char* type, Handle<String> name) {
770 HandleScope scope; 771 HandleScope scope;
771 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type)); 772 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type));
772 Handle<Object> args[2] = { type_handle, name }; 773 Handle<Object> args[2] = { type_handle, name };
773 Handle<Object> error = 774 Handle<Object> error =
774 Factory::NewTypeError("redeclaration", HandleVector(args, 2)); 775 Factory::NewTypeError("redeclaration", HandleVector(args, 2));
775 return Top::Throw(*error); 776 return Isolate::Current()->Throw(*error);
776 } 777 }
777 778
778 779
779 static Object* Runtime_DeclareGlobals(Arguments args) { 780 static Object* Runtime_DeclareGlobals(Arguments args) {
780 HandleScope scope; 781 HandleScope scope;
781 Handle<GlobalObject> global = Handle<GlobalObject>(Top::context()->global()); 782 Handle<GlobalObject> global = Handle<GlobalObject>(
783 Isolate::Current()->context()->global());
782 784
783 Handle<Context> context = args.at<Context>(0); 785 Handle<Context> context = args.at<Context>(0);
784 CONVERT_ARG_CHECKED(FixedArray, pairs, 1); 786 CONVERT_ARG_CHECKED(FixedArray, pairs, 1);
785 bool is_eval = Smi::cast(args[2])->value() == 1; 787 bool is_eval = Smi::cast(args[2])->value() == 1;
786 788
787 // Compute the property attributes. According to ECMA-262, section 789 // Compute the property attributes. According to ECMA-262, section
788 // 13, page 71, the property must be read-only and 790 // 13, page 71, the property must be read-only and
789 // non-deletable. However, neither SpiderMonkey nor KJS creates the 791 // non-deletable. However, neither SpiderMonkey nor KJS creates the
790 // property as read-only, so we don't either. 792 // property as read-only, so we don't either.
791 PropertyAttributes base = is_eval ? NONE : DONT_DELETE; 793 PropertyAttributes base = is_eval ? NONE : DONT_DELETE;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 // The property is not in the function context. It needs to be 946 // The property is not in the function context. It needs to be
945 // "declared" in the function context's extension context, or in the 947 // "declared" in the function context's extension context, or in the
946 // global context. 948 // global context.
947 Handle<JSObject> context_ext; 949 Handle<JSObject> context_ext;
948 if (context->has_extension()) { 950 if (context->has_extension()) {
949 // The function context's extension context exists - use it. 951 // The function context's extension context exists - use it.
950 context_ext = Handle<JSObject>(context->extension()); 952 context_ext = Handle<JSObject>(context->extension());
951 } else { 953 } else {
952 // The function context's extension context does not exists - allocate 954 // The function context's extension context does not exists - allocate
953 // it. 955 // it.
954 context_ext = Factory::NewJSObject(Top::context_extension_function()); 956 context_ext = Factory::NewJSObject(
957 Isolate::Current()->context_extension_function());
955 // And store it in the extension slot. 958 // And store it in the extension slot.
956 context->set_extension(*context_ext); 959 context->set_extension(*context_ext);
957 } 960 }
958 ASSERT(*context_ext != NULL); 961 ASSERT(*context_ext != NULL);
959 962
960 // Declare the property by setting it to the initial value if provided, 963 // Declare the property by setting it to the initial value if provided,
961 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for 964 // or undefined, and use the correct mode (e.g. READ_ONLY attribute for
962 // constant declarations). 965 // constant declarations).
963 ASSERT(!context_ext->HasLocalProperty(*name)); 966 ASSERT(!context_ext->HasLocalProperty(*name));
964 Handle<Object> value(HEAP->undefined_value()); 967 Handle<Object> value(HEAP->undefined_value());
965 if (*initial_value != NULL) value = initial_value; 968 if (*initial_value != NULL) value = initial_value;
966 SetProperty(context_ext, name, value, mode); 969 SetProperty(context_ext, name, value, mode);
967 ASSERT(context_ext->GetLocalPropertyAttribute(*name) == mode); 970 ASSERT(context_ext->GetLocalPropertyAttribute(*name) == mode);
968 } 971 }
969 972
970 return HEAP->undefined_value(); 973 return HEAP->undefined_value();
971 } 974 }
972 975
973 976
974 static Object* Runtime_InitializeVarGlobal(Arguments args) { 977 static Object* Runtime_InitializeVarGlobal(Arguments args) {
975 NoHandleAllocation nha; 978 NoHandleAllocation nha;
976 979
977 // Determine if we need to assign to the variable if it already 980 // Determine if we need to assign to the variable if it already
978 // exists (based on the number of arguments). 981 // exists (based on the number of arguments).
979 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); 982 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
980 bool assign = args.length() == 2; 983 bool assign = args.length() == 2;
981 984
982 CONVERT_ARG_CHECKED(String, name, 0); 985 CONVERT_ARG_CHECKED(String, name, 0);
983 GlobalObject* global = Top::context()->global(); 986 GlobalObject* global = Isolate::Current()->context()->global();
984 987
985 // According to ECMA-262, section 12.2, page 62, the property must 988 // According to ECMA-262, section 12.2, page 62, the property must
986 // not be deletable. 989 // not be deletable.
987 PropertyAttributes attributes = DONT_DELETE; 990 PropertyAttributes attributes = DONT_DELETE;
988 991
989 // Lookup the property locally in the global object. If it isn't 992 // Lookup the property locally in the global object. If it isn't
990 // there, there is a property with this name in the prototype chain. 993 // there, there is a property with this name in the prototype chain.
991 // We follow Safari and Firefox behavior and only set the property 994 // We follow Safari and Firefox behavior and only set the property
992 // locally if there is an explicit initialization value that we have 995 // locally if there is an explicit initialization value that we have
993 // to assign to the property. When adding the property we take 996 // to assign to the property. When adding the property we take
994 // special precautions to always add it as a local property even in 997 // special precautions to always add it as a local property even in
995 // case of callbacks in the prototype chain (this rules out using 998 // case of callbacks in the prototype chain (this rules out using
996 // SetProperty). We have IgnoreAttributesAndSetLocalProperty for 999 // SetProperty). We have IgnoreAttributesAndSetLocalProperty for
997 // this. 1000 // this.
998 // Note that objects can have hidden prototypes, so we need to traverse 1001 // Note that objects can have hidden prototypes, so we need to traverse
999 // the whole chain of hidden prototypes to do a 'local' lookup. 1002 // the whole chain of hidden prototypes to do a 'local' lookup.
1000 JSObject* real_holder = global; 1003 JSObject* real_holder = global;
1001 LookupResult lookup; 1004 LookupResult lookup;
1002 while (true) { 1005 while (true) {
1003 real_holder->LocalLookup(*name, &lookup); 1006 real_holder->LocalLookup(*name, &lookup);
1004 if (lookup.IsProperty()) { 1007 if (lookup.IsProperty()) {
1005 // Determine if this is a redeclaration of something read-only. 1008 // Determine if this is a redeclaration of something read-only.
1006 if (lookup.IsReadOnly()) { 1009 if (lookup.IsReadOnly()) {
1007 // If we found readonly property on one of hidden prototypes, 1010 // If we found readonly property on one of hidden prototypes,
1008 // just shadow it. 1011 // just shadow it.
1009 if (real_holder != Top::context()->global()) break; 1012 if (real_holder != Isolate::Current()->context()->global()) break;
1010 return ThrowRedeclarationError("const", name); 1013 return ThrowRedeclarationError("const", name);
1011 } 1014 }
1012 1015
1013 // Determine if this is a redeclaration of an intercepted read-only 1016 // Determine if this is a redeclaration of an intercepted read-only
1014 // property and figure out if the property exists at all. 1017 // property and figure out if the property exists at all.
1015 bool found = true; 1018 bool found = true;
1016 PropertyType type = lookup.type(); 1019 PropertyType type = lookup.type();
1017 if (type == INTERCEPTOR) { 1020 if (type == INTERCEPTOR) {
1018 HandleScope handle_scope; 1021 HandleScope handle_scope;
1019 Handle<JSObject> holder(real_holder); 1022 Handle<JSObject> holder(real_holder);
1020 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); 1023 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name);
1021 real_holder = *holder; 1024 real_holder = *holder;
1022 if (intercepted == ABSENT) { 1025 if (intercepted == ABSENT) {
1023 // The interceptor claims the property isn't there. We need to 1026 // The interceptor claims the property isn't there. We need to
1024 // make sure to introduce it. 1027 // make sure to introduce it.
1025 found = false; 1028 found = false;
1026 } else if ((intercepted & READ_ONLY) != 0) { 1029 } else if ((intercepted & READ_ONLY) != 0) {
1027 // The property is present, but read-only. Since we're trying to 1030 // The property is present, but read-only. Since we're trying to
1028 // overwrite it with a variable declaration we must throw a 1031 // overwrite it with a variable declaration we must throw a
1029 // re-declaration error. However if we found readonly property 1032 // re-declaration error. However if we found readonly property
1030 // on one of hidden prototypes, just shadow it. 1033 // on one of hidden prototypes, just shadow it.
1031 if (real_holder != Top::context()->global()) break; 1034 if (real_holder != Isolate::Current()->context()->global()) break;
1032 return ThrowRedeclarationError("const", name); 1035 return ThrowRedeclarationError("const", name);
1033 } 1036 }
1034 } 1037 }
1035 1038
1036 if (found && !assign) { 1039 if (found && !assign) {
1037 // The global property is there and we're not assigning any value 1040 // The global property is there and we're not assigning any value
1038 // to it. Just return. 1041 // to it. Just return.
1039 return HEAP->undefined_value(); 1042 return HEAP->undefined_value();
1040 } 1043 }
1041 1044
1042 // Assign the value (or undefined) to the property. 1045 // Assign the value (or undefined) to the property.
1043 Object* value = (assign) ? args[1] : HEAP->undefined_value(); 1046 Object* value = (assign) ? args[1] : HEAP->undefined_value();
1044 return real_holder->SetProperty(&lookup, *name, value, attributes); 1047 return real_holder->SetProperty(&lookup, *name, value, attributes);
1045 } 1048 }
1046 1049
1047 Object* proto = real_holder->GetPrototype(); 1050 Object* proto = real_holder->GetPrototype();
1048 if (!proto->IsJSObject()) 1051 if (!proto->IsJSObject())
1049 break; 1052 break;
1050 1053
1051 if (!JSObject::cast(proto)->map()->is_hidden_prototype()) 1054 if (!JSObject::cast(proto)->map()->is_hidden_prototype())
1052 break; 1055 break;
1053 1056
1054 real_holder = JSObject::cast(proto); 1057 real_holder = JSObject::cast(proto);
1055 } 1058 }
1056 1059
1057 global = Top::context()->global(); 1060 global = Isolate::Current()->context()->global();
1058 if (assign) { 1061 if (assign) {
1059 return global->IgnoreAttributesAndSetLocalProperty(*name, 1062 return global->IgnoreAttributesAndSetLocalProperty(*name,
1060 args[1], 1063 args[1],
1061 attributes); 1064 attributes);
1062 } 1065 }
1063 return HEAP->undefined_value(); 1066 return HEAP->undefined_value();
1064 } 1067 }
1065 1068
1066 1069
1067 static Object* Runtime_InitializeConstGlobal(Arguments args) { 1070 static Object* Runtime_InitializeConstGlobal(Arguments args) {
1068 // All constants are declared with an initial value. The name 1071 // All constants are declared with an initial value. The name
1069 // of the constant is the first argument and the initial value 1072 // of the constant is the first argument and the initial value
1070 // is the second. 1073 // is the second.
1071 RUNTIME_ASSERT(args.length() == 2); 1074 RUNTIME_ASSERT(args.length() == 2);
1072 CONVERT_ARG_CHECKED(String, name, 0); 1075 CONVERT_ARG_CHECKED(String, name, 0);
1073 Handle<Object> value = args.at<Object>(1); 1076 Handle<Object> value = args.at<Object>(1);
1074 1077
1075 // Get the current global object from top. 1078 // Get the current global object from top.
1076 GlobalObject* global = Top::context()->global(); 1079 GlobalObject* global = Isolate::Current()->context()->global();
1077 1080
1078 // According to ECMA-262, section 12.2, page 62, the property must 1081 // According to ECMA-262, section 12.2, page 62, the property must
1079 // not be deletable. Since it's a const, it must be READ_ONLY too. 1082 // not be deletable. Since it's a const, it must be READ_ONLY too.
1080 PropertyAttributes attributes = 1083 PropertyAttributes attributes =
1081 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 1084 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
1082 1085
1083 // Lookup the property locally in the global object. If it isn't 1086 // Lookup the property locally in the global object. If it isn't
1084 // there, we add the property and take special precautions to always 1087 // there, we add the property and take special precautions to always
1085 // add it as a local property even in case of callbacks in the 1088 // add it as a local property even in case of callbacks in the
1086 // prototype chain (this rules out using SetProperty). 1089 // prototype chain (this rules out using SetProperty).
(...skipping 18 matching lines...) Expand all
1105 1108
1106 // Throw re-declaration error if the intercepted property is present 1109 // Throw re-declaration error if the intercepted property is present
1107 // but not read-only. 1110 // but not read-only.
1108 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { 1111 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
1109 return ThrowRedeclarationError("var", name); 1112 return ThrowRedeclarationError("var", name);
1110 } 1113 }
1111 1114
1112 // Restore global object from context (in case of GC) and continue 1115 // Restore global object from context (in case of GC) and continue
1113 // with setting the value because the property is either absent or 1116 // with setting the value because the property is either absent or
1114 // read-only. We also have to do redo the lookup. 1117 // read-only. We also have to do redo the lookup.
1115 global = Top::context()->global(); 1118 global = Isolate::Current()->context()->global();
1116 1119
1117 // BUG 1213579: Handle the case where we have to set a read-only 1120 // BUG 1213579: Handle the case where we have to set a read-only
1118 // property through an interceptor and only do it if it's 1121 // property through an interceptor and only do it if it's
1119 // uninitialized, e.g. the hole. Nirk... 1122 // uninitialized, e.g. the hole. Nirk...
1120 global->SetProperty(*name, *value, attributes); 1123 global->SetProperty(*name, *value, attributes);
1121 return *value; 1124 return *value;
1122 } 1125 }
1123 1126
1124 // Set the value, but only we're assigning the initial value to a 1127 // Set the value, but only we're assigning the initial value to a
1125 // constant. For now, we determine this by checking if the 1128 // constant. For now, we determine this by checking if the
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 // The holder is an arguments object. 1193 // The holder is an arguments object.
1191 ASSERT((attributes & READ_ONLY) == 0); 1194 ASSERT((attributes & READ_ONLY) == 0);
1192 Handle<JSObject>::cast(holder)->SetElement(index, *value); 1195 Handle<JSObject>::cast(holder)->SetElement(index, *value);
1193 } 1196 }
1194 return *value; 1197 return *value;
1195 } 1198 }
1196 1199
1197 // The property could not be found, we introduce it in the global 1200 // The property could not be found, we introduce it in the global
1198 // context. 1201 // context.
1199 if (attributes == ABSENT) { 1202 if (attributes == ABSENT) {
1200 Handle<JSObject> global = Handle<JSObject>(Top::context()->global()); 1203 Handle<JSObject> global = Handle<JSObject>(
1204 Isolate::Current()->context()->global());
1201 SetProperty(global, name, value, NONE); 1205 SetProperty(global, name, value, NONE);
1202 return *value; 1206 return *value;
1203 } 1207 }
1204 1208
1205 // The property was present in a context extension object. 1209 // The property was present in a context extension object.
1206 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder); 1210 Handle<JSObject> context_ext = Handle<JSObject>::cast(holder);
1207 1211
1208 if (*context_ext == context->extension()) { 1212 if (*context_ext == context->extension()) {
1209 // This is the property that was introduced by the const 1213 // This is the property that was introduced by the const
1210 // declaration. Set it if it hasn't been set before. NOTE: We 1214 // declaration. Set it if it hasn't been set before. NOTE: We
(...skipping 22 matching lines...) Expand all
1233 } 1237 }
1234 } else { 1238 } else {
1235 // The property was found in a different context extension object. 1239 // The property was found in a different context extension object.
1236 // Set it if it is not a read-only property. 1240 // Set it if it is not a read-only property.
1237 if ((attributes & READ_ONLY) == 0) { 1241 if ((attributes & READ_ONLY) == 0) {
1238 Handle<Object> set = SetProperty(context_ext, name, value, attributes); 1242 Handle<Object> set = SetProperty(context_ext, name, value, attributes);
1239 // Setting a property might throw an exception. Exceptions 1243 // Setting a property might throw an exception. Exceptions
1240 // are converted to empty handles in handle operations. We 1244 // are converted to empty handles in handle operations. We
1241 // need to convert back to exceptions here. 1245 // need to convert back to exceptions here.
1242 if (set.is_null()) { 1246 if (set.is_null()) {
1243 ASSERT(Top::has_pending_exception()); 1247 ASSERT(Isolate::Current()->has_pending_exception());
1244 return Failure::Exception(); 1248 return Failure::Exception();
1245 } 1249 }
1246 } 1250 }
1247 } 1251 }
1248 1252
1249 return *value; 1253 return *value;
1250 } 1254 }
1251 1255
1252 1256
1253 static Object* Runtime_OptimizeObjectForAddingMultipleProperties( 1257 static Object* Runtime_OptimizeObjectForAddingMultipleProperties(
(...skipping 28 matching lines...) Expand all
1282 last_match_info); 1286 last_match_info);
1283 if (result.is_null()) return Failure::Exception(); 1287 if (result.is_null()) return Failure::Exception();
1284 return *result; 1288 return *result;
1285 } 1289 }
1286 1290
1287 1291
1288 static Object* Runtime_RegExpConstructResult(Arguments args) { 1292 static Object* Runtime_RegExpConstructResult(Arguments args) {
1289 ASSERT(args.length() == 3); 1293 ASSERT(args.length() == 3);
1290 CONVERT_SMI_CHECKED(elements_count, args[0]); 1294 CONVERT_SMI_CHECKED(elements_count, args[0]);
1291 if (elements_count > JSArray::kMaxFastElementsLength) { 1295 if (elements_count > JSArray::kMaxFastElementsLength) {
1292 return Top::ThrowIllegalOperation(); 1296 return Isolate::Current()->ThrowIllegalOperation();
1293 } 1297 }
1294 Object* new_object = HEAP->AllocateFixedArrayWithHoles(elements_count); 1298 Object* new_object = HEAP->AllocateFixedArrayWithHoles(elements_count);
1295 if (new_object->IsFailure()) return new_object; 1299 if (new_object->IsFailure()) return new_object;
1296 FixedArray* elements = FixedArray::cast(new_object); 1300 FixedArray* elements = FixedArray::cast(new_object);
1297 new_object = HEAP->AllocateRaw(JSRegExpResult::kSize, 1301 new_object = HEAP->AllocateRaw(JSRegExpResult::kSize,
1298 NEW_SPACE, 1302 NEW_SPACE,
1299 OLD_POINTER_SPACE); 1303 OLD_POINTER_SPACE);
1300 if (new_object->IsFailure()) return new_object; 1304 if (new_object->IsFailure()) return new_object;
1301 { 1305 {
1302 AssertNoAllocation no_gc; 1306 AssertNoAllocation no_gc;
1303 HandleScope scope; 1307 HandleScope scope;
1304 reinterpret_cast<HeapObject*>(new_object)-> 1308 reinterpret_cast<HeapObject*>(new_object)->
1305 set_map(Top::global_context()->regexp_result_map()); 1309 set_map(Isolate::Current()->global_context()->regexp_result_map());
1306 } 1310 }
1307 JSArray* array = JSArray::cast(new_object); 1311 JSArray* array = JSArray::cast(new_object);
1308 array->set_properties(HEAP->empty_fixed_array()); 1312 array->set_properties(HEAP->empty_fixed_array());
1309 array->set_elements(elements); 1313 array->set_elements(elements);
1310 array->set_length(Smi::FromInt(elements_count)); 1314 array->set_length(Smi::FromInt(elements_count));
1311 // Write in-object properties after the length of the array. 1315 // Write in-object properties after the length of the array.
1312 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); 1316 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]);
1313 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); 1317 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]);
1314 return array; 1318 return array;
1315 } 1319 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 InstallBuiltin(holder, "slice", Builtins::ArraySlice); 1414 InstallBuiltin(holder, "slice", Builtins::ArraySlice);
1411 InstallBuiltin(holder, "splice", Builtins::ArraySplice); 1415 InstallBuiltin(holder, "splice", Builtins::ArraySplice);
1412 InstallBuiltin(holder, "concat", Builtins::ArrayConcat); 1416 InstallBuiltin(holder, "concat", Builtins::ArrayConcat);
1413 1417
1414 return *holder; 1418 return *holder;
1415 } 1419 }
1416 1420
1417 1421
1418 static Object* Runtime_GetGlobalReceiver(Arguments args) { 1422 static Object* Runtime_GetGlobalReceiver(Arguments args) {
1419 // Returns a real global receiver, not one of builtins object. 1423 // Returns a real global receiver, not one of builtins object.
1420 Context* global_context = Top::context()->global()->global_context(); 1424 Context* global_context =
1425 Isolate::Current()->context()->global()->global_context();
1421 return global_context->global()->global_receiver(); 1426 return global_context->global()->global_receiver();
1422 } 1427 }
1423 1428
1424 1429
1425 static Object* Runtime_MaterializeRegExpLiteral(Arguments args) { 1430 static Object* Runtime_MaterializeRegExpLiteral(Arguments args) {
1426 HandleScope scope; 1431 HandleScope scope;
1427 ASSERT(args.length() == 4); 1432 ASSERT(args.length() == 4);
1428 CONVERT_ARG_CHECKED(FixedArray, literals, 0); 1433 CONVERT_ARG_CHECKED(FixedArray, literals, 0);
1429 int index = Smi::cast(args[1])->value(); 1434 int index = Smi::cast(args[1])->value();
1430 Handle<String> pattern = args.at<String>(2); 1435 Handle<String> pattern = args.at<String>(2);
1431 Handle<String> flags = args.at<String>(3); 1436 Handle<String> flags = args.at<String>(3);
1432 1437
1433 // Get the RegExp function from the context in the literals array. 1438 // Get the RegExp function from the context in the literals array.
1434 // This is the RegExp function from the context in which the 1439 // This is the RegExp function from the context in which the
1435 // function was created. We do not use the RegExp function from the 1440 // function was created. We do not use the RegExp function from the
1436 // current global context because this might be the RegExp function 1441 // current global context because this might be the RegExp function
1437 // from another context which we should not have access to. 1442 // from another context which we should not have access to.
1438 Handle<JSFunction> constructor = 1443 Handle<JSFunction> constructor =
1439 Handle<JSFunction>( 1444 Handle<JSFunction>(
1440 JSFunction::GlobalContextFromLiterals(*literals)->regexp_function()); 1445 JSFunction::GlobalContextFromLiterals(*literals)->regexp_function());
1441 // Compute the regular expression literal. 1446 // Compute the regular expression literal.
1442 bool has_pending_exception; 1447 bool has_pending_exception;
1443 Handle<Object> regexp = 1448 Handle<Object> regexp =
1444 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags, 1449 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags,
1445 &has_pending_exception); 1450 &has_pending_exception);
1446 if (has_pending_exception) { 1451 if (has_pending_exception) {
1447 ASSERT(Top::has_pending_exception()); 1452 ASSERT(Isolate::Current()->has_pending_exception());
1448 return Failure::Exception(); 1453 return Failure::Exception();
1449 } 1454 }
1450 literals->set(index, *regexp); 1455 literals->set(index, *regexp);
1451 return *regexp; 1456 return *regexp;
1452 } 1457 }
1453 1458
1454 1459
1455 static Object* Runtime_FunctionGetName(Arguments args) { 1460 static Object* Runtime_FunctionGetName(Arguments args) {
1456 NoHandleAllocation ha; 1461 NoHandleAllocation ha;
1457 ASSERT(args.length() == 1); 1462 ASSERT(args.length() == 1);
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3696 3701
3697 3702
3698 Object* Runtime::GetObjectProperty(Handle<Object> object, Handle<Object> key) { 3703 Object* Runtime::GetObjectProperty(Handle<Object> object, Handle<Object> key) {
3699 HandleScope scope; 3704 HandleScope scope;
3700 3705
3701 if (object->IsUndefined() || object->IsNull()) { 3706 if (object->IsUndefined() || object->IsNull()) {
3702 Handle<Object> args[2] = { key, object }; 3707 Handle<Object> args[2] = { key, object };
3703 Handle<Object> error = 3708 Handle<Object> error =
3704 Factory::NewTypeError("non_object_property_load", 3709 Factory::NewTypeError("non_object_property_load",
3705 HandleVector(args, 2)); 3710 HandleVector(args, 2));
3706 return Top::Throw(*error); 3711 return Isolate::Current()->Throw(*error);
3707 } 3712 }
3708 3713
3709 // Check if the given key is an array index. 3714 // Check if the given key is an array index.
3710 uint32_t index; 3715 uint32_t index;
3711 if (key->ToArrayIndex(&index)) { 3716 if (key->ToArrayIndex(&index)) {
3712 return GetElementOrCharAt(object, index); 3717 return GetElementOrCharAt(object, index);
3713 } 3718 }
3714 3719
3715 // Convert the key to a string - possibly by calling back into JavaScript. 3720 // Convert the key to a string - possibly by calling back into JavaScript.
3716 Handle<String> name; 3721 Handle<String> name;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3898 Handle<Object> key, 3903 Handle<Object> key,
3899 Handle<Object> value, 3904 Handle<Object> value,
3900 PropertyAttributes attr) { 3905 PropertyAttributes attr) {
3901 HandleScope scope; 3906 HandleScope scope;
3902 3907
3903 if (object->IsUndefined() || object->IsNull()) { 3908 if (object->IsUndefined() || object->IsNull()) {
3904 Handle<Object> args[2] = { key, object }; 3909 Handle<Object> args[2] = { key, object };
3905 Handle<Object> error = 3910 Handle<Object> error =
3906 Factory::NewTypeError("non_object_property_store", 3911 Factory::NewTypeError("non_object_property_store",
3907 HandleVector(args, 2)); 3912 HandleVector(args, 2));
3908 return Top::Throw(*error); 3913 return Isolate::Current()->Throw(*error);
3909 } 3914 }
3910 3915
3911 // If the object isn't a JavaScript object, we ignore the store. 3916 // If the object isn't a JavaScript object, we ignore the store.
3912 if (!object->IsJSObject()) return *value; 3917 if (!object->IsJSObject()) return *value;
3913 3918
3914 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 3919 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
3915 3920
3916 // Check if the given key is an array index. 3921 // Check if the given key is an array index.
3917 uint32_t index; 3922 uint32_t index;
3918 if (key->ToArrayIndex(&index)) { 3923 if (key->ToArrayIndex(&index)) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
4244 if (!args[0]->IsJSObject()) { 4249 if (!args[0]->IsJSObject()) {
4245 return HEAP->undefined_value(); 4250 return HEAP->undefined_value();
4246 } 4251 }
4247 CONVERT_ARG_CHECKED(JSObject, obj, 0); 4252 CONVERT_ARG_CHECKED(JSObject, obj, 0);
4248 4253
4249 // Skip the global proxy as it has no properties and always delegates to the 4254 // Skip the global proxy as it has no properties and always delegates to the
4250 // real global object. 4255 // real global object.
4251 if (obj->IsJSGlobalProxy()) { 4256 if (obj->IsJSGlobalProxy()) {
4252 // Only collect names if access is permitted. 4257 // Only collect names if access is permitted.
4253 if (obj->IsAccessCheckNeeded() && 4258 if (obj->IsAccessCheckNeeded() &&
4254 !Top::MayNamedAccess(*obj, HEAP->undefined_value(), v8::ACCESS_KEYS)) { 4259 !Isolate::Current()->MayNamedAccess(*obj,
4255 Top::ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS); 4260 HEAP->undefined_value(),
4261 v8::ACCESS_KEYS)) {
4262 Isolate::Current()->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS);
4256 return *Factory::NewJSArray(0); 4263 return *Factory::NewJSArray(0);
4257 } 4264 }
4258 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); 4265 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype()));
4259 } 4266 }
4260 4267
4261 // Find the number of objects making up this. 4268 // Find the number of objects making up this.
4262 int length = LocalPrototypeChainLength(*obj); 4269 int length = LocalPrototypeChainLength(*obj);
4263 4270
4264 // Find the number of local properties for each of the objects. 4271 // Find the number of local properties for each of the objects.
4265 ScopedVector<int> local_property_count(length); 4272 ScopedVector<int> local_property_count(length);
4266 int total_property_count = 0; 4273 int total_property_count = 0;
4267 Handle<JSObject> jsproto = obj; 4274 Handle<JSObject> jsproto = obj;
4268 for (int i = 0; i < length; i++) { 4275 for (int i = 0; i < length; i++) {
4269 // Only collect names if access is permitted. 4276 // Only collect names if access is permitted.
4270 if (jsproto->IsAccessCheckNeeded() && 4277 if (jsproto->IsAccessCheckNeeded() &&
4271 !Top::MayNamedAccess(*jsproto, 4278 !Isolate::Current()->MayNamedAccess(*jsproto,
4272 HEAP->undefined_value(), 4279 HEAP->undefined_value(),
4273 v8::ACCESS_KEYS)) { 4280 v8::ACCESS_KEYS)) {
4274 Top::ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS); 4281 Isolate::Current()->ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS);
4275 return *Factory::NewJSArray(0); 4282 return *Factory::NewJSArray(0);
4276 } 4283 }
4277 int n; 4284 int n;
4278 n = jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE)); 4285 n = jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE));
4279 local_property_count[i] = n; 4286 local_property_count[i] = n;
4280 total_property_count += n; 4287 total_property_count += n;
4281 if (i < length - 1) { 4288 if (i < length - 1) {
4282 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 4289 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
4283 } 4290 }
4284 } 4291 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 Handle<Object> converted = 4444 Handle<Object> converted =
4438 Execution::ToString(args.at<Object>(0), &exception); 4445 Execution::ToString(args.at<Object>(0), &exception);
4439 if (exception) return Failure::Exception(); 4446 if (exception) return Failure::Exception();
4440 Handle<String> key = Handle<String>::cast(converted); 4447 Handle<String> key = Handle<String>::cast(converted);
4441 4448
4442 // Try to convert the string key into an array index. 4449 // Try to convert the string key into an array index.
4443 if (key->AsArrayIndex(&index)) { 4450 if (key->AsArrayIndex(&index)) {
4444 if (index < n) { 4451 if (index < n) {
4445 return frame->GetParameter(index); 4452 return frame->GetParameter(index);
4446 } else { 4453 } else {
4447 return Top::initial_object_prototype()->GetElement(index); 4454 return Isolate::Current()->initial_object_prototype()->GetElement(index);
4448 } 4455 }
4449 } 4456 }
4450 4457
4451 // Handle special arguments properties. 4458 // Handle special arguments properties.
4452 if (key->Equals(HEAP->length_symbol())) return Smi::FromInt(n); 4459 if (key->Equals(HEAP->length_symbol())) return Smi::FromInt(n);
4453 if (key->Equals(HEAP->callee_symbol())) return frame->function(); 4460 if (key->Equals(HEAP->callee_symbol())) return frame->function();
4454 4461
4455 // Lookup in the initial Object.prototype object. 4462 // Lookup in the initial Object.prototype object.
4456 return Top::initial_object_prototype()->GetProperty(*key); 4463 return Isolate::Current()->initial_object_prototype()->GetProperty(*key);
4457 } 4464 }
4458 4465
4459 4466
4460 static Object* Runtime_ToFastProperties(Arguments args) { 4467 static Object* Runtime_ToFastProperties(Arguments args) {
4461 HandleScope scope; 4468 HandleScope scope;
4462 4469
4463 ASSERT(args.length() == 1); 4470 ASSERT(args.length() == 1);
4464 Handle<Object> object = args.at<Object>(0); 4471 Handle<Object> object = args.at<Object>(0);
4465 if (object->IsJSObject()) { 4472 if (object->IsJSObject()) {
4466 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 4473 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4683 if (character >= 256) { 4690 if (character >= 256) {
4684 escaped_length += 6; 4691 escaped_length += 6;
4685 } else if (IsNotEscaped(character)) { 4692 } else if (IsNotEscaped(character)) {
4686 escaped_length++; 4693 escaped_length++;
4687 } else { 4694 } else {
4688 escaped_length += 3; 4695 escaped_length += 3;
4689 } 4696 }
4690 // We don't allow strings that are longer than a maximal length. 4697 // We don't allow strings that are longer than a maximal length.
4691 ASSERT(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow. 4698 ASSERT(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow.
4692 if (escaped_length > String::kMaxLength) { 4699 if (escaped_length > String::kMaxLength) {
4693 Top::context()->mark_out_of_memory(); 4700 Isolate::Current()->context()->mark_out_of_memory();
4694 return Failure::OutOfMemoryException(); 4701 return Failure::OutOfMemoryException();
4695 } 4702 }
4696 } 4703 }
4697 } 4704 }
4698 // No length change implies no change. Return original string if no change. 4705 // No length change implies no change. Return original string if no change.
4699 if (escaped_length == length) { 4706 if (escaped_length == length) {
4700 return source; 4707 return source;
4701 } 4708 }
4702 Object* o = HEAP->AllocateRawAsciiString(escaped_length); 4709 Object* o = HEAP->AllocateRawAsciiString(escaped_length);
4703 if (o->IsFailure()) return o; 4710 if (o->IsFailure()) return o;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
4914 while (buffer->has_more()) { 4921 while (buffer->has_more()) {
4915 current = buffer->GetNext(); 4922 current = buffer->GetNext();
4916 // NOTE: we use 0 as the next character here because, while 4923 // NOTE: we use 0 as the next character here because, while
4917 // the next character may affect what a character converts to, 4924 // the next character may affect what a character converts to,
4918 // it does not in any case affect the length of what it convert 4925 // it does not in any case affect the length of what it convert
4919 // to. 4926 // to.
4920 int char_length = mapping->get(current, 0, chars); 4927 int char_length = mapping->get(current, 0, chars);
4921 if (char_length == 0) char_length = 1; 4928 if (char_length == 0) char_length = 1;
4922 current_length += char_length; 4929 current_length += char_length;
4923 if (current_length > Smi::kMaxValue) { 4930 if (current_length > Smi::kMaxValue) {
4924 Top::context()->mark_out_of_memory(); 4931 Isolate::Current()->context()->mark_out_of_memory();
4925 return Failure::OutOfMemoryException(); 4932 return Failure::OutOfMemoryException();
4926 } 4933 }
4927 } 4934 }
4928 // Try again with the real length. 4935 // Try again with the real length.
4929 return Smi::FromInt(current_length); 4936 return Smi::FromInt(current_length);
4930 } else { 4937 } else {
4931 for (int j = 0; j < char_length; j++) { 4938 for (int j = 0; j < char_length; j++) {
4932 result->Set(i, chars[j]); 4939 result->Set(i, chars[j]);
4933 i++; 4940 i++;
4934 } 4941 }
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
5534 } 5541 }
5535 } 5542 }
5536 } 5543 }
5537 5544
5538 5545
5539 static Object* Runtime_StringBuilderConcat(Arguments args) { 5546 static Object* Runtime_StringBuilderConcat(Arguments args) {
5540 NoHandleAllocation ha; 5547 NoHandleAllocation ha;
5541 ASSERT(args.length() == 3); 5548 ASSERT(args.length() == 3);
5542 CONVERT_CHECKED(JSArray, array, args[0]); 5549 CONVERT_CHECKED(JSArray, array, args[0]);
5543 if (!args[1]->IsSmi()) { 5550 if (!args[1]->IsSmi()) {
5544 Top::context()->mark_out_of_memory(); 5551 Isolate::Current()->context()->mark_out_of_memory();
5545 return Failure::OutOfMemoryException(); 5552 return Failure::OutOfMemoryException();
5546 } 5553 }
5547 int array_length = Smi::cast(args[1])->value(); 5554 int array_length = Smi::cast(args[1])->value();
5548 CONVERT_CHECKED(String, special, args[2]); 5555 CONVERT_CHECKED(String, special, args[2]);
5549 5556
5550 // This assumption is used by the slice encoding in one or two smis. 5557 // This assumption is used by the slice encoding in one or two smis.
5551 ASSERT(Smi::kMaxValue >= String::kMaxLength); 5558 ASSERT(Smi::kMaxValue >= String::kMaxLength);
5552 5559
5553 int special_length = special->length(); 5560 int special_length = special->length();
5554 if (!array->HasFastElements()) { 5561 if (!array->HasFastElements()) {
5555 return Top::Throw(HEAP->illegal_argument_symbol()); 5562 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
5556 } 5563 }
5557 FixedArray* fixed_array = FixedArray::cast(array->elements()); 5564 FixedArray* fixed_array = FixedArray::cast(array->elements());
5558 if (fixed_array->length() < array_length) { 5565 if (fixed_array->length() < array_length) {
5559 array_length = fixed_array->length(); 5566 array_length = fixed_array->length();
5560 } 5567 }
5561 5568
5562 if (array_length == 0) { 5569 if (array_length == 0) {
5563 return HEAP->empty_string(); 5570 return HEAP->empty_string();
5564 } else if (array_length == 1) { 5571 } else if (array_length == 1) {
5565 Object* first = fixed_array->get(0); 5572 Object* first = fixed_array->get(0);
(...skipping 13 matching lines...) Expand all
5579 if (smi_value > 0) { 5586 if (smi_value > 0) {
5580 // Position and length encoded in one smi. 5587 // Position and length encoded in one smi.
5581 pos = StringBuilderSubstringPosition::decode(smi_value); 5588 pos = StringBuilderSubstringPosition::decode(smi_value);
5582 len = StringBuilderSubstringLength::decode(smi_value); 5589 len = StringBuilderSubstringLength::decode(smi_value);
5583 } else { 5590 } else {
5584 // Position and length encoded in two smis. 5591 // Position and length encoded in two smis.
5585 len = -smi_value; 5592 len = -smi_value;
5586 // Get the position and check that it is a positive smi. 5593 // Get the position and check that it is a positive smi.
5587 i++; 5594 i++;
5588 if (i >= array_length) { 5595 if (i >= array_length) {
5589 return Top::Throw(HEAP->illegal_argument_symbol()); 5596 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
5590 } 5597 }
5591 Object* next_smi = fixed_array->get(i); 5598 Object* next_smi = fixed_array->get(i);
5592 if (!next_smi->IsSmi()) { 5599 if (!next_smi->IsSmi()) {
5593 return Top::Throw(HEAP->illegal_argument_symbol()); 5600 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
5594 } 5601 }
5595 pos = Smi::cast(next_smi)->value(); 5602 pos = Smi::cast(next_smi)->value();
5596 if (pos < 0) { 5603 if (pos < 0) {
5597 return Top::Throw(HEAP->illegal_argument_symbol()); 5604 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
5598 } 5605 }
5599 } 5606 }
5600 ASSERT(pos >= 0); 5607 ASSERT(pos >= 0);
5601 ASSERT(len >= 0); 5608 ASSERT(len >= 0);
5602 if (pos > special_length || len > special_length - pos) { 5609 if (pos > special_length || len > special_length - pos) {
5603 return Top::Throw(HEAP->illegal_argument_symbol()); 5610 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
5604 } 5611 }
5605 increment = len; 5612 increment = len;
5606 } else if (elt->IsString()) { 5613 } else if (elt->IsString()) {
5607 String* element = String::cast(elt); 5614 String* element = String::cast(elt);
5608 int element_length = element->length(); 5615 int element_length = element->length();
5609 increment = element_length; 5616 increment = element_length;
5610 if (ascii && !element->IsAsciiRepresentation()) { 5617 if (ascii && !element->IsAsciiRepresentation()) {
5611 ascii = false; 5618 ascii = false;
5612 } 5619 }
5613 } else { 5620 } else {
5614 return Top::Throw(HEAP->illegal_argument_symbol()); 5621 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
5615 } 5622 }
5616 if (increment > String::kMaxLength - position) { 5623 if (increment > String::kMaxLength - position) {
5617 Top::context()->mark_out_of_memory(); 5624 Isolate::Current()->context()->mark_out_of_memory();
5618 return Failure::OutOfMemoryException(); 5625 return Failure::OutOfMemoryException();
5619 } 5626 }
5620 position += increment; 5627 position += increment;
5621 } 5628 }
5622 5629
5623 int length = position; 5630 int length = position;
5624 Object* object; 5631 Object* object;
5625 5632
5626 if (ascii) { 5633 if (ascii) {
5627 object = HEAP->AllocateRawAsciiString(length); 5634 object = HEAP->AllocateRawAsciiString(length);
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
6610 HandleScope scope; 6617 HandleScope scope;
6611 ASSERT(args.length() == 1); 6618 ASSERT(args.length() == 1);
6612 6619
6613 Handle<Object> constructor = args.at<Object>(0); 6620 Handle<Object> constructor = args.at<Object>(0);
6614 6621
6615 // If the constructor isn't a proper function we throw a type error. 6622 // If the constructor isn't a proper function we throw a type error.
6616 if (!constructor->IsJSFunction()) { 6623 if (!constructor->IsJSFunction()) {
6617 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); 6624 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
6618 Handle<Object> type_error = 6625 Handle<Object> type_error =
6619 Factory::NewTypeError("not_constructor", arguments); 6626 Factory::NewTypeError("not_constructor", arguments);
6620 return Top::Throw(*type_error); 6627 return Isolate::Current()->Throw(*type_error);
6621 } 6628 }
6622 6629
6623 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); 6630 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor);
6624 6631
6625 // If function should not have prototype, construction is not allowed. In this 6632 // If function should not have prototype, construction is not allowed. In this
6626 // case generated code bailouts here, since function has no initial_map. 6633 // case generated code bailouts here, since function has no initial_map.
6627 if (!function->should_have_prototype()) { 6634 if (!function->should_have_prototype()) {
6628 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); 6635 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
6629 Handle<Object> type_error = 6636 Handle<Object> type_error =
6630 Factory::NewTypeError("not_constructor", arguments); 6637 Factory::NewTypeError("not_constructor", arguments);
6631 return Top::Throw(*type_error); 6638 return Isolate::Current()->Throw(*type_error);
6632 } 6639 }
6633 6640
6634 #ifdef ENABLE_DEBUGGER_SUPPORT 6641 #ifdef ENABLE_DEBUGGER_SUPPORT
6635 // Handle stepping into constructors if step into is active. 6642 // Handle stepping into constructors if step into is active.
6636 if (Debug::StepInActive()) { 6643 if (Debug::StepInActive()) {
6637 Debug::HandleStepIn(function, Handle<Object>::null(), 0, true); 6644 Debug::HandleStepIn(function, Handle<Object>::null(), 0, true);
6638 } 6645 }
6639 #endif 6646 #endif
6640 6647
6641 if (function->has_initial_map()) { 6648 if (function->has_initial_map()) {
6642 if (function->initial_map()->instance_type() == JS_FUNCTION_TYPE) { 6649 if (function->initial_map()->instance_type() == JS_FUNCTION_TYPE) {
6643 // The 'Function' function ignores the receiver object when 6650 // The 'Function' function ignores the receiver object when
6644 // called using 'new' and creates a new JSFunction object that 6651 // called using 'new' and creates a new JSFunction object that
6645 // is returned. The receiver object is only used for error 6652 // is returned. The receiver object is only used for error
6646 // reporting if an error occurs when constructing the new 6653 // reporting if an error occurs when constructing the new
6647 // JSFunction. Factory::NewJSObject() should not be used to 6654 // JSFunction. Factory::NewJSObject() should not be used to
6648 // allocate JSFunctions since it does not properly initialize 6655 // allocate JSFunctions since it does not properly initialize
6649 // the shared part of the function. Since the receiver is 6656 // the shared part of the function. Since the receiver is
6650 // ignored anyway, we use the global object as the receiver 6657 // ignored anyway, we use the global object as the receiver
6651 // instead of a new JSFunction object. This way, errors are 6658 // instead of a new JSFunction object. This way, errors are
6652 // reported the same way whether or not 'Function' is called 6659 // reported the same way whether or not 'Function' is called
6653 // using 'new'. 6660 // using 'new'.
6654 return Top::context()->global(); 6661 return Isolate::Current()->context()->global();
6655 } 6662 }
6656 } 6663 }
6657 6664
6658 // The function should be compiled for the optimization hints to be available. 6665 // The function should be compiled for the optimization hints to be available.
6659 Handle<SharedFunctionInfo> shared(function->shared()); 6666 Handle<SharedFunctionInfo> shared(function->shared());
6660 EnsureCompiled(shared, CLEAR_EXCEPTION); 6667 EnsureCompiled(shared, CLEAR_EXCEPTION);
6661 6668
6662 bool first_allocation = !function->has_initial_map(); 6669 bool first_allocation = !function->has_initial_map();
6663 Handle<JSObject> result = Factory::NewJSObject(function); 6670 Handle<JSObject> result = Factory::NewJSObject(function);
6664 if (first_allocation) { 6671 if (first_allocation) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6721 6728
6722 static Object* Runtime_NewContext(Arguments args) { 6729 static Object* Runtime_NewContext(Arguments args) {
6723 NoHandleAllocation ha; 6730 NoHandleAllocation ha;
6724 ASSERT(args.length() == 1); 6731 ASSERT(args.length() == 1);
6725 6732
6726 CONVERT_CHECKED(JSFunction, function, args[0]); 6733 CONVERT_CHECKED(JSFunction, function, args[0]);
6727 int length = ScopeInfo<>::NumberOfContextSlots(function->code()); 6734 int length = ScopeInfo<>::NumberOfContextSlots(function->code());
6728 Object* result = HEAP->AllocateFunctionContext(length, function); 6735 Object* result = HEAP->AllocateFunctionContext(length, function);
6729 if (result->IsFailure()) return result; 6736 if (result->IsFailure()) return result;
6730 6737
6731 Top::set_context(Context::cast(result)); 6738 Isolate::Current()->set_context(Context::cast(result));
6732 6739
6733 return result; // non-failure 6740 return result; // non-failure
6734 } 6741 }
6735 6742
6736 static Object* PushContextHelper(Object* object, bool is_catch_context) { 6743 static Object* PushContextHelper(Object* object, bool is_catch_context) {
6737 // Convert the object to a proper JavaScript object. 6744 // Convert the object to a proper JavaScript object.
6738 Object* js_object = object; 6745 Object* js_object = object;
6739 if (!js_object->IsJSObject()) { 6746 if (!js_object->IsJSObject()) {
6740 js_object = js_object->ToObject(); 6747 js_object = js_object->ToObject();
6741 if (js_object->IsFailure()) { 6748 if (js_object->IsFailure()) {
6742 if (!Failure::cast(js_object)->IsInternalError()) return js_object; 6749 if (!Failure::cast(js_object)->IsInternalError()) return js_object;
6743 HandleScope scope; 6750 HandleScope scope;
6744 Handle<Object> handle(object); 6751 Handle<Object> handle(object);
6745 Handle<Object> result = 6752 Handle<Object> result =
6746 Factory::NewTypeError("with_expression", HandleVector(&handle, 1)); 6753 Factory::NewTypeError("with_expression", HandleVector(&handle, 1));
6747 return Top::Throw(*result); 6754 return Isolate::Current()->Throw(*result);
6748 } 6755 }
6749 } 6756 }
6750 6757
6751 Object* result = 6758 Object* result =
6752 HEAP->AllocateWithContext(Top::context(), 6759 HEAP->AllocateWithContext(Isolate::Current()->context(),
6753 JSObject::cast(js_object), 6760 JSObject::cast(js_object),
6754 is_catch_context); 6761 is_catch_context);
6755 if (result->IsFailure()) return result; 6762 if (result->IsFailure()) return result;
6756 6763
6757 Context* context = Context::cast(result); 6764 Context* context = Context::cast(result);
6758 Top::set_context(context); 6765 Isolate::Current()->set_context(context);
6759 6766
6760 return result; 6767 return result;
6761 } 6768 }
6762 6769
6763 6770
6764 static Object* Runtime_PushContext(Arguments args) { 6771 static Object* Runtime_PushContext(Arguments args) {
6765 NoHandleAllocation ha; 6772 NoHandleAllocation ha;
6766 ASSERT(args.length() == 1); 6773 ASSERT(args.length() == 1);
6767 return PushContextHelper(args[0], false); 6774 return PushContextHelper(args[0], false);
6768 } 6775 }
(...skipping 18 matching lines...) Expand all
6787 ContextLookupFlags flags = FOLLOW_CHAINS; 6794 ContextLookupFlags flags = FOLLOW_CHAINS;
6788 Handle<Object> holder = 6795 Handle<Object> holder =
6789 context->Lookup(name, flags, &index, &attributes); 6796 context->Lookup(name, flags, &index, &attributes);
6790 6797
6791 if (index < 0 && !holder.is_null()) { 6798 if (index < 0 && !holder.is_null()) {
6792 ASSERT(holder->IsJSObject()); 6799 ASSERT(holder->IsJSObject());
6793 return *holder; 6800 return *holder;
6794 } 6801 }
6795 6802
6796 // No intermediate context found. Use global object by default. 6803 // No intermediate context found. Use global object by default.
6797 return Top::context()->global(); 6804 return Isolate::Current()->context()->global();
6798 } 6805 }
6799 6806
6800 6807
6801 // A mechanism to return a pair of Object pointers in registers (if possible). 6808 // A mechanism to return a pair of Object pointers in registers (if possible).
6802 // How this is achieved is calling convention-dependent. 6809 // How this is achieved is calling convention-dependent.
6803 // All currently supported x86 compiles uses calling conventions that are cdecl 6810 // All currently supported x86 compiles uses calling conventions that are cdecl
6804 // variants where a 64-bit value is returned in two 32-bit registers 6811 // variants where a 64-bit value is returned in two 32-bit registers
6805 // (edx:eax on ia32, r1:r0 on ARM). 6812 // (edx:eax on ia32, r1:r0 on ARM).
6806 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. 6813 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax.
6807 // In Win64 calling convention, a struct of two pointers is returned in memory, 6814 // In Win64 calling convention, a struct of two pointers is returned in memory,
(...skipping 21 matching lines...) Expand all
6829 6836
6830 static inline Object* Unhole(Object* x, PropertyAttributes attributes) { 6837 static inline Object* Unhole(Object* x, PropertyAttributes attributes) {
6831 ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0); 6838 ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0);
6832 USE(attributes); 6839 USE(attributes);
6833 return x->IsTheHole() ? HEAP->undefined_value() : x; 6840 return x->IsTheHole() ? HEAP->undefined_value() : x;
6834 } 6841 }
6835 6842
6836 6843
6837 static JSObject* ComputeReceiverForNonGlobal(JSObject* holder) { 6844 static JSObject* ComputeReceiverForNonGlobal(JSObject* holder) {
6838 ASSERT(!holder->IsGlobalObject()); 6845 ASSERT(!holder->IsGlobalObject());
6839 Context* top = Top::context(); 6846 Context* top = Isolate::Current()->context();
6840 // Get the context extension function. 6847 // Get the context extension function.
6841 JSFunction* context_extension_function = 6848 JSFunction* context_extension_function =
6842 top->global_context()->context_extension_function(); 6849 top->global_context()->context_extension_function();
6843 // If the holder isn't a context extension object, we just return it 6850 // If the holder isn't a context extension object, we just return it
6844 // as the receiver. This allows arguments objects to be used as 6851 // as the receiver. This allows arguments objects to be used as
6845 // receivers, but only if they are put in the context scope chain 6852 // receivers, but only if they are put in the context scope chain
6846 // explicitly via a with-statement. 6853 // explicitly via a with-statement.
6847 Object* constructor = holder->map()->constructor(); 6854 Object* constructor = holder->map()->constructor();
6848 if (constructor != context_extension_function) return holder; 6855 if (constructor != context_extension_function) return holder;
6849 // Fall back to using the global object as the receiver if the 6856 // Fall back to using the global object as the receiver if the
6850 // property turns out to be a local variable allocated in a context 6857 // property turns out to be a local variable allocated in a context
6851 // extension object - introduced via eval. 6858 // extension object - introduced via eval.
6852 return top->global()->global_receiver(); 6859 return top->global()->global_receiver();
6853 } 6860 }
6854 6861
6855 6862
6856 static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) { 6863 static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) {
6857 HandleScope scope; 6864 HandleScope scope;
6858 ASSERT_EQ(2, args.length()); 6865 ASSERT_EQ(2, args.length());
6859 6866
6860 if (!args[0]->IsContext() || !args[1]->IsString()) { 6867 if (!args[0]->IsContext() || !args[1]->IsString()) {
6861 return MakePair(Top::ThrowIllegalOperation(), NULL); 6868 return MakePair(Isolate::Current()->ThrowIllegalOperation(), NULL);
6862 } 6869 }
6863 Handle<Context> context = args.at<Context>(0); 6870 Handle<Context> context = args.at<Context>(0);
6864 Handle<String> name = args.at<String>(1); 6871 Handle<String> name = args.at<String>(1);
6865 6872
6866 int index; 6873 int index;
6867 PropertyAttributes attributes; 6874 PropertyAttributes attributes;
6868 ContextLookupFlags flags = FOLLOW_CHAINS; 6875 ContextLookupFlags flags = FOLLOW_CHAINS;
6869 Handle<Object> holder = 6876 Handle<Object> holder =
6870 context->Lookup(name, flags, &index, &attributes); 6877 context->Lookup(name, flags, &index, &attributes);
6871 6878
6872 // If the index is non-negative, the slot has been found in a local 6879 // If the index is non-negative, the slot has been found in a local
6873 // variable or a parameter. Read it from the context object or the 6880 // variable or a parameter. Read it from the context object or the
6874 // arguments object. 6881 // arguments object.
6875 if (index >= 0) { 6882 if (index >= 0) {
6876 // If the "property" we were looking for is a local variable or an 6883 // If the "property" we were looking for is a local variable or an
6877 // argument in a context, the receiver is the global object; see 6884 // argument in a context, the receiver is the global object; see
6878 // ECMA-262, 3rd., 10.1.6 and 10.2.3. 6885 // ECMA-262, 3rd., 10.1.6 and 10.2.3.
6879 JSObject* receiver = Top::context()->global()->global_receiver(); 6886 JSObject* receiver =
6887 Isolate::Current()->context()->global()->global_receiver();
6880 Object* value = (holder->IsContext()) 6888 Object* value = (holder->IsContext())
6881 ? Context::cast(*holder)->get(index) 6889 ? Context::cast(*holder)->get(index)
6882 : JSObject::cast(*holder)->GetElement(index); 6890 : JSObject::cast(*holder)->GetElement(index);
6883 return MakePair(Unhole(value, attributes), receiver); 6891 return MakePair(Unhole(value, attributes), receiver);
6884 } 6892 }
6885 6893
6886 // If the holder is found, we read the property from it. 6894 // If the holder is found, we read the property from it.
6887 if (!holder.is_null() && holder->IsJSObject()) { 6895 if (!holder.is_null() && holder->IsJSObject()) {
6888 ASSERT(Handle<JSObject>::cast(holder)->HasProperty(*name)); 6896 ASSERT(Handle<JSObject>::cast(holder)->HasProperty(*name));
6889 JSObject* object = JSObject::cast(*holder); 6897 JSObject* object = JSObject::cast(*holder);
6890 JSObject* receiver; 6898 JSObject* receiver;
6891 if (object->IsGlobalObject()) { 6899 if (object->IsGlobalObject()) {
6892 receiver = GlobalObject::cast(object)->global_receiver(); 6900 receiver = GlobalObject::cast(object)->global_receiver();
6893 } else if (context->is_exception_holder(*holder)) { 6901 } else if (context->is_exception_holder(*holder)) {
6894 receiver = Top::context()->global()->global_receiver(); 6902 receiver = Isolate::Current()->context()->global()->global_receiver();
6895 } else { 6903 } else {
6896 receiver = ComputeReceiverForNonGlobal(object); 6904 receiver = ComputeReceiverForNonGlobal(object);
6897 } 6905 }
6898 // No need to unhole the value here. This is taken care of by the 6906 // No need to unhole the value here. This is taken care of by the
6899 // GetProperty function. 6907 // GetProperty function.
6900 Object* value = object->GetProperty(*name); 6908 Object* value = object->GetProperty(*name);
6901 return MakePair(value, receiver); 6909 return MakePair(value, receiver);
6902 } 6910 }
6903 6911
6904 if (throw_error) { 6912 if (throw_error) {
6905 // The property doesn't exist - throw exception. 6913 // The property doesn't exist - throw exception.
6906 Handle<Object> reference_error = 6914 Handle<Object> reference_error =
6907 Factory::NewReferenceError("not_defined", HandleVector(&name, 1)); 6915 Factory::NewReferenceError("not_defined", HandleVector(&name, 1));
6908 return MakePair(Top::Throw(*reference_error), NULL); 6916 return MakePair(Isolate::Current()->Throw(*reference_error), NULL);
6909 } else { 6917 } else {
6910 // The property doesn't exist - return undefined 6918 // The property doesn't exist - return undefined
6911 return MakePair(HEAP->undefined_value(), HEAP->undefined_value()); 6919 return MakePair(HEAP->undefined_value(), HEAP->undefined_value());
6912 } 6920 }
6913 } 6921 }
6914 6922
6915 6923
6916 static ObjectPair Runtime_LoadContextSlot(Arguments args) { 6924 static ObjectPair Runtime_LoadContextSlot(Arguments args) {
6917 return LoadContextSlotHelper(args, true); 6925 return LoadContextSlotHelper(args, true);
6918 } 6926 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6957 // It is either in an JSObject extension context or it was not found. 6965 // It is either in an JSObject extension context or it was not found.
6958 Handle<JSObject> context_ext; 6966 Handle<JSObject> context_ext;
6959 6967
6960 if (!holder.is_null()) { 6968 if (!holder.is_null()) {
6961 // The property exists in the extension context. 6969 // The property exists in the extension context.
6962 context_ext = Handle<JSObject>::cast(holder); 6970 context_ext = Handle<JSObject>::cast(holder);
6963 } else { 6971 } else {
6964 // The property was not found. It needs to be stored in the global context. 6972 // The property was not found. It needs to be stored in the global context.
6965 ASSERT(attributes == ABSENT); 6973 ASSERT(attributes == ABSENT);
6966 attributes = NONE; 6974 attributes = NONE;
6967 context_ext = Handle<JSObject>(Top::context()->global()); 6975 context_ext = Handle<JSObject>(Isolate::Current()->context()->global());
6968 } 6976 }
6969 6977
6970 // Set the property, but ignore if read_only variable on the context 6978 // Set the property, but ignore if read_only variable on the context
6971 // extension object itself. 6979 // extension object itself.
6972 if ((attributes & READ_ONLY) == 0 || 6980 if ((attributes & READ_ONLY) == 0 ||
6973 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) { 6981 (context_ext->GetLocalPropertyAttribute(*name) == ABSENT)) {
6974 Handle<Object> set = SetProperty(context_ext, name, value, attributes); 6982 Handle<Object> set = SetProperty(context_ext, name, value, attributes);
6975 if (set.is_null()) { 6983 if (set.is_null()) {
6976 // Failure::Exception is converted to a null handle in the 6984 // Failure::Exception is converted to a null handle in the
6977 // handle-based methods such as SetProperty. We therefore need 6985 // handle-based methods such as SetProperty. We therefore need
6978 // to convert null handles back to exceptions. 6986 // to convert null handles back to exceptions.
6979 ASSERT(Top::has_pending_exception()); 6987 ASSERT(Isolate::Current()->has_pending_exception());
6980 return Failure::Exception(); 6988 return Failure::Exception();
6981 } 6989 }
6982 } 6990 }
6983 return *value; 6991 return *value;
6984 } 6992 }
6985 6993
6986 6994
6987 static Object* Runtime_Throw(Arguments args) { 6995 static Object* Runtime_Throw(Arguments args) {
6988 HandleScope scope; 6996 HandleScope scope;
6989 ASSERT(args.length() == 1); 6997 ASSERT(args.length() == 1);
6990 6998
6991 return Top::Throw(args[0]); 6999 return Isolate::Current()->Throw(args[0]);
6992 } 7000 }
6993 7001
6994 7002
6995 static Object* Runtime_ReThrow(Arguments args) { 7003 static Object* Runtime_ReThrow(Arguments args) {
6996 HandleScope scope; 7004 HandleScope scope;
6997 ASSERT(args.length() == 1); 7005 ASSERT(args.length() == 1);
6998 7006
6999 return Top::ReThrow(args[0]); 7007 return Isolate::Current()->ReThrow(args[0]);
7000 } 7008 }
7001 7009
7002 7010
7003 static Object* Runtime_PromoteScheduledException(Arguments args) { 7011 static Object* Runtime_PromoteScheduledException(Arguments args) {
7004 ASSERT_EQ(0, args.length()); 7012 ASSERT_EQ(0, args.length());
7005 return Top::PromoteScheduledException(); 7013 return Isolate::Current()->PromoteScheduledException();
7006 } 7014 }
7007 7015
7008 7016
7009 static Object* Runtime_ThrowReferenceError(Arguments args) { 7017 static Object* Runtime_ThrowReferenceError(Arguments args) {
7010 HandleScope scope; 7018 HandleScope scope;
7011 ASSERT(args.length() == 1); 7019 ASSERT(args.length() == 1);
7012 7020
7013 Handle<Object> name(args[0]); 7021 Handle<Object> name(args[0]);
7014 Handle<Object> reference_error = 7022 Handle<Object> reference_error =
7015 Factory::NewReferenceError("not_defined", HandleVector(&name, 1)); 7023 Factory::NewReferenceError("not_defined", HandleVector(&name, 1));
7016 return Top::Throw(*reference_error); 7024 return Isolate::Current()->Throw(*reference_error);
7017 } 7025 }
7018 7026
7019 7027
7020 static Object* Runtime_StackOverflow(Arguments args) { 7028 static Object* Runtime_StackOverflow(Arguments args) {
7021 NoHandleAllocation na; 7029 NoHandleAllocation na;
7022 return Top::StackOverflow(); 7030 return Isolate::Current()->StackOverflow();
7023 } 7031 }
7024 7032
7025 7033
7026 static Object* Runtime_StackGuard(Arguments args) { 7034 static Object* Runtime_StackGuard(Arguments args) {
7027 ASSERT(args.length() == 1); 7035 ASSERT(args.length() == 1);
7028 Isolate* isolate = Isolate::Current(); 7036 Isolate* isolate = Isolate::Current();
7029 // First check if this is a real stack overflow. 7037 // First check if this is a real stack overflow.
7030 if (isolate->stack_guard()->IsStackOverflow()) { 7038 if (isolate->stack_guard()->IsStackOverflow()) {
7031 return Runtime_StackOverflow(args); 7039 return Runtime_StackOverflow(args);
7032 } 7040 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
7163 PrintF("\n"); 7171 PrintF("\n");
7164 Flush(); 7172 Flush();
7165 7173
7166 return args[0]; // return TOS 7174 return args[0]; // return TOS
7167 } 7175 }
7168 7176
7169 7177
7170 static Object* Runtime_DebugTrace(Arguments args) { 7178 static Object* Runtime_DebugTrace(Arguments args) {
7171 ASSERT(args.length() == 0); 7179 ASSERT(args.length() == 0);
7172 NoHandleAllocation ha; 7180 NoHandleAllocation ha;
7173 Top::PrintStack(); 7181 Isolate::Current()->PrintStack();
7174 return HEAP->undefined_value(); 7182 return HEAP->undefined_value();
7175 } 7183 }
7176 7184
7177 7185
7178 static Object* Runtime_DateCurrentTime(Arguments args) { 7186 static Object* Runtime_DateCurrentTime(Arguments args) {
7179 NoHandleAllocation ha; 7187 NoHandleAllocation ha;
7180 ASSERT(args.length() == 0); 7188 ASSERT(args.length() == 0);
7181 7189
7182 // According to ECMA-262, section 15.9.1, page 117, the precision of 7190 // According to ECMA-262, section 15.9.1, page 117, the precision of
7183 // the number in a Date object representing a particular instant in 7191 // the number in a Date object representing a particular instant in
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
7253 } 7261 }
7254 7262
7255 7263
7256 static Object* Runtime_CompileString(Arguments args) { 7264 static Object* Runtime_CompileString(Arguments args) {
7257 HandleScope scope; 7265 HandleScope scope;
7258 ASSERT_EQ(2, args.length()); 7266 ASSERT_EQ(2, args.length());
7259 CONVERT_ARG_CHECKED(String, source, 0); 7267 CONVERT_ARG_CHECKED(String, source, 0);
7260 CONVERT_ARG_CHECKED(Oddball, is_json, 1) 7268 CONVERT_ARG_CHECKED(Oddball, is_json, 1)
7261 7269
7262 // Compile source string in the global context. 7270 // Compile source string in the global context.
7263 Handle<Context> context(Top::context()->global_context()); 7271 Handle<Context> context(Isolate::Current()->context()->global_context());
7264 Compiler::ValidationState validate = (is_json->IsTrue()) 7272 Compiler::ValidationState validate = (is_json->IsTrue())
7265 ? Compiler::VALIDATE_JSON : Compiler::DONT_VALIDATE_JSON; 7273 ? Compiler::VALIDATE_JSON : Compiler::DONT_VALIDATE_JSON;
7266 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source, 7274 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source,
7267 context, 7275 context,
7268 true, 7276 true,
7269 validate); 7277 validate);
7270 if (shared.is_null()) return Failure::Exception(); 7278 if (shared.is_null()) return Failure::Exception();
7271 Handle<JSFunction> fun = 7279 Handle<JSFunction> fun =
7272 Factory::NewFunctionFromSharedFunctionInfo(shared, context, NOT_TENURED); 7280 Factory::NewFunctionFromSharedFunctionInfo(shared, context, NOT_TENURED);
7273 return *fun; 7281 return *fun;
7274 } 7282 }
7275 7283
7276 7284
7277 static ObjectPair CompileGlobalEval(Handle<String> source, 7285 static ObjectPair CompileGlobalEval(Handle<String> source,
7278 Handle<Object> receiver) { 7286 Handle<Object> receiver) {
7279 // Deal with a normal eval call with a string argument. Compile it 7287 // Deal with a normal eval call with a string argument. Compile it
7280 // and return the compiled function bound in the local context. 7288 // and return the compiled function bound in the local context.
7281 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 7289 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
7282 source, 7290 source,
7283 Handle<Context>(Top::context()), 7291 Handle<Context>(Isolate::Current()->context()),
7284 Top::context()->IsGlobalContext(), 7292 Isolate::Current()->context()->IsGlobalContext(),
7285 Compiler::DONT_VALIDATE_JSON); 7293 Compiler::DONT_VALIDATE_JSON);
7286 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); 7294 if (shared.is_null()) return MakePair(Failure::Exception(), NULL);
7287 Handle<JSFunction> compiled = Factory::NewFunctionFromSharedFunctionInfo( 7295 Handle<JSFunction> compiled = Factory::NewFunctionFromSharedFunctionInfo(
7288 shared, 7296 shared,
7289 Handle<Context>(Top::context()), 7297 Handle<Context>(Isolate::Current()->context()),
7290 NOT_TENURED); 7298 NOT_TENURED);
7291 return MakePair(*compiled, *receiver); 7299 return MakePair(*compiled, *receiver);
7292 } 7300 }
7293 7301
7294 7302
7295 static ObjectPair Runtime_ResolvePossiblyDirectEval(Arguments args) { 7303 static ObjectPair Runtime_ResolvePossiblyDirectEval(Arguments args) {
7296 ASSERT(args.length() == 3); 7304 ASSERT(args.length() == 3);
7297 if (!args[0]->IsJSFunction()) { 7305 if (!args[0]->IsJSFunction()) {
7298 return MakePair(Top::ThrowIllegalOperation(), NULL); 7306 return MakePair(Isolate::Current()->ThrowIllegalOperation(), NULL);
7299 } 7307 }
7300 7308
7301 HandleScope scope; 7309 HandleScope scope;
7302 Handle<JSFunction> callee = args.at<JSFunction>(0); 7310 Handle<JSFunction> callee = args.at<JSFunction>(0);
7303 Handle<Object> receiver; // Will be overwritten. 7311 Handle<Object> receiver; // Will be overwritten.
7304 7312
7305 // Compute the calling context. 7313 // Compute the calling context.
7306 Handle<Context> context = Handle<Context>(Top::context()); 7314 Handle<Context> context = Handle<Context>(Isolate::Current()->context());
7307 #ifdef DEBUG 7315 #ifdef DEBUG
7308 // Make sure Top::context() agrees with the old code that traversed 7316 // Make sure Isolate::context() agrees with the old code that traversed
7309 // the stack frames to compute the context. 7317 // the stack frames to compute the context.
7310 StackFrameLocator locator; 7318 StackFrameLocator locator;
7311 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); 7319 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
7312 ASSERT(Context::cast(frame->context()) == *context); 7320 ASSERT(Context::cast(frame->context()) == *context);
7313 #endif 7321 #endif
7314 7322
7315 // Find where the 'eval' symbol is bound. It is unaliased only if 7323 // Find where the 'eval' symbol is bound. It is unaliased only if
7316 // it is bound in the global context. 7324 // it is bound in the global context.
7317 int index = -1; 7325 int index = -1;
7318 PropertyAttributes attributes = ABSENT; 7326 PropertyAttributes attributes = ABSENT;
7319 while (true) { 7327 while (true) {
7320 receiver = context->Lookup(Factory::eval_symbol(), FOLLOW_PROTOTYPE_CHAIN, 7328 receiver = context->Lookup(Factory::eval_symbol(), FOLLOW_PROTOTYPE_CHAIN,
7321 &index, &attributes); 7329 &index, &attributes);
7322 // Stop search when eval is found or when the global context is 7330 // Stop search when eval is found or when the global context is
7323 // reached. 7331 // reached.
7324 if (attributes != ABSENT || context->IsGlobalContext()) break; 7332 if (attributes != ABSENT || context->IsGlobalContext()) break;
7325 if (context->is_function_context()) { 7333 if (context->is_function_context()) {
7326 context = Handle<Context>(Context::cast(context->closure()->context())); 7334 context = Handle<Context>(Context::cast(context->closure()->context()));
7327 } else { 7335 } else {
7328 context = Handle<Context>(context->previous()); 7336 context = Handle<Context>(context->previous());
7329 } 7337 }
7330 } 7338 }
7331 7339
7332 // If eval could not be resolved, it has been deleted and we need to 7340 // If eval could not be resolved, it has been deleted and we need to
7333 // throw a reference error. 7341 // throw a reference error.
7334 if (attributes == ABSENT) { 7342 if (attributes == ABSENT) {
7335 Handle<Object> name = Factory::eval_symbol(); 7343 Handle<Object> name = Factory::eval_symbol();
7336 Handle<Object> reference_error = 7344 Handle<Object> reference_error =
7337 Factory::NewReferenceError("not_defined", HandleVector(&name, 1)); 7345 Factory::NewReferenceError("not_defined", HandleVector(&name, 1));
7338 return MakePair(Top::Throw(*reference_error), NULL); 7346 return MakePair(Isolate::Current()->Throw(*reference_error), NULL);
7339 } 7347 }
7340 7348
7341 if (!context->IsGlobalContext()) { 7349 if (!context->IsGlobalContext()) {
7342 // 'eval' is not bound in the global context. Just call the function 7350 // 'eval' is not bound in the global context. Just call the function
7343 // with the given arguments. This is not necessarily the global eval. 7351 // with the given arguments. This is not necessarily the global eval.
7344 if (receiver->IsContext()) { 7352 if (receiver->IsContext()) {
7345 context = Handle<Context>::cast(receiver); 7353 context = Handle<Context>::cast(receiver);
7346 receiver = Handle<Object>(context->get(index)); 7354 receiver = Handle<Object>(context->get(index));
7347 } else if (receiver->IsJSContextExtensionObject()) { 7355 } else if (receiver->IsJSContextExtensionObject()) {
7348 receiver = Handle<JSObject>(Top::context()->global()->global_receiver()); 7356 receiver = Handle<JSObject>(
7357 Isolate::Current()->context()->global()->global_receiver());
7349 } 7358 }
7350 return MakePair(*callee, *receiver); 7359 return MakePair(*callee, *receiver);
7351 } 7360 }
7352 7361
7353 // 'eval' is bound in the global context, but it may have been overwritten. 7362 // 'eval' is bound in the global context, but it may have been overwritten.
7354 // Compare it to the builtin 'GlobalEval' function to make sure. 7363 // Compare it to the builtin 'GlobalEval' function to make sure.
7355 if (*callee != Top::global_context()->global_eval_fun() || 7364 if (*callee != Isolate::Current()->global_context()->global_eval_fun() ||
7356 !args[1]->IsString()) { 7365 !args[1]->IsString()) {
7357 return MakePair(*callee, Top::context()->global()->global_receiver()); 7366 return MakePair(*callee,
7367 Isolate::Current()->context()->global()->global_receiver());
7358 } 7368 }
7359 7369
7360 return CompileGlobalEval(args.at<String>(1), args.at<Object>(2)); 7370 return CompileGlobalEval(args.at<String>(1), args.at<Object>(2));
7361 } 7371 }
7362 7372
7363 7373
7364 static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup(Arguments args) { 7374 static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup(Arguments args) {
7365 ASSERT(args.length() == 3); 7375 ASSERT(args.length() == 3);
7366 if (!args[0]->IsJSFunction()) { 7376 if (!args[0]->IsJSFunction()) {
7367 return MakePair(Top::ThrowIllegalOperation(), NULL); 7377 return MakePair(Isolate::Current()->ThrowIllegalOperation(), NULL);
7368 } 7378 }
7369 7379
7370 HandleScope scope; 7380 HandleScope scope;
7371 Handle<JSFunction> callee = args.at<JSFunction>(0); 7381 Handle<JSFunction> callee = args.at<JSFunction>(0);
7372 7382
7373 // 'eval' is bound in the global context, but it may have been overwritten. 7383 // 'eval' is bound in the global context, but it may have been overwritten.
7374 // Compare it to the builtin 'GlobalEval' function to make sure. 7384 // Compare it to the builtin 'GlobalEval' function to make sure.
7375 if (*callee != Top::global_context()->global_eval_fun() || 7385 if (*callee != Isolate::Current()->global_context()->global_eval_fun() ||
7376 !args[1]->IsString()) { 7386 !args[1]->IsString()) {
7377 return MakePair(*callee, Top::context()->global()->global_receiver()); 7387 return MakePair(*callee,
7388 Isolate::Current()->context()->global()->global_receiver());
7378 } 7389 }
7379 7390
7380 return CompileGlobalEval(args.at<String>(1), args.at<Object>(2)); 7391 return CompileGlobalEval(args.at<String>(1), args.at<Object>(2));
7381 } 7392 }
7382 7393
7383 7394
7384 static Object* Runtime_SetNewFunctionAttributes(Arguments args) { 7395 static Object* Runtime_SetNewFunctionAttributes(Arguments args) {
7385 // This utility adjusts the property attributes for newly created Function 7396 // This utility adjusts the property attributes for newly created Function
7386 // object ("new Function(...)") by changing the map. 7397 // object ("new Function(...)") by changing the map.
7387 // All it does is changing the prototype property to enumerable 7398 // All it does is changing the prototype property to enumerable
7388 // as specified in ECMA262, 15.3.5.2. 7399 // as specified in ECMA262, 15.3.5.2.
7389 HandleScope scope; 7400 HandleScope scope;
7390 ASSERT(args.length() == 1); 7401 ASSERT(args.length() == 1);
7391 CONVERT_ARG_CHECKED(JSFunction, func, 0); 7402 CONVERT_ARG_CHECKED(JSFunction, func, 0);
7392 ASSERT(func->map()->instance_type() == 7403 ASSERT(func->map()->instance_type() ==
7393 Top::function_instance_map()->instance_type()); 7404 Isolate::Current()->function_instance_map()->instance_type());
7394 ASSERT(func->map()->instance_size() == 7405 ASSERT(func->map()->instance_size() ==
7395 Top::function_instance_map()->instance_size()); 7406 Isolate::Current()->function_instance_map()->instance_size());
7396 func->set_map(*Top::function_instance_map()); 7407 func->set_map(*Isolate::Current()->function_instance_map());
7397 return *func; 7408 return *func;
7398 } 7409 }
7399 7410
7400 7411
7401 // Push an array unto an array of arrays if it is not already in the 7412 // Push an array unto an array of arrays if it is not already in the
7402 // array. Returns true if the element was pushed on the stack and 7413 // array. Returns true if the element was pushed on the stack and
7403 // false otherwise. 7414 // false otherwise.
7404 static Object* Runtime_PushIfAbsent(Arguments args) { 7415 static Object* Runtime_PushIfAbsent(Arguments args) {
7405 ASSERT(args.length() == 2); 7416 ASSERT(args.length() == 2);
7406 CONVERT_CHECKED(JSArray, array, args[0]); 7417 CONVERT_CHECKED(JSArray, array, args[0]);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
7869 7880
7870 ASSERT_EQ(3, args.length()); 7881 ASSERT_EQ(3, args.length());
7871 7882
7872 CONVERT_ARG_CHECKED(JSObject, object, 0); 7883 CONVERT_ARG_CHECKED(JSObject, object, 0);
7873 Handle<Object> key1 = args.at<Object>(1); 7884 Handle<Object> key1 = args.at<Object>(1);
7874 Handle<Object> key2 = args.at<Object>(2); 7885 Handle<Object> key2 = args.at<Object>(2);
7875 7886
7876 uint32_t index1, index2; 7887 uint32_t index1, index2;
7877 if (!key1->ToArrayIndex(&index1) 7888 if (!key1->ToArrayIndex(&index1)
7878 || !key2->ToArrayIndex(&index2)) { 7889 || !key2->ToArrayIndex(&index2)) {
7879 return Top::ThrowIllegalOperation(); 7890 return Isolate::Current()->ThrowIllegalOperation();
7880 } 7891 }
7881 7892
7882 Handle<JSObject> jsobject = Handle<JSObject>::cast(object); 7893 Handle<JSObject> jsobject = Handle<JSObject>::cast(object);
7883 Handle<Object> tmp1 = GetElement(jsobject, index1); 7894 Handle<Object> tmp1 = GetElement(jsobject, index1);
7884 Handle<Object> tmp2 = GetElement(jsobject, index2); 7895 Handle<Object> tmp2 = GetElement(jsobject, index2);
7885 7896
7886 SetElement(jsobject, index1, tmp2); 7897 SetElement(jsobject, index1, tmp2);
7887 SetElement(jsobject, index2, tmp1); 7898 SetElement(jsobject, index2, tmp1);
7888 7899
7889 return HEAP->undefined_value(); 7900 return HEAP->undefined_value();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
8026 } 8037 }
8027 return value; 8038 return value;
8028 case CONSTANT_FUNCTION: 8039 case CONSTANT_FUNCTION:
8029 return result->GetConstantFunction(); 8040 return result->GetConstantFunction();
8030 case CALLBACKS: { 8041 case CALLBACKS: {
8031 Object* structure = result->GetCallbackObject(); 8042 Object* structure = result->GetCallbackObject();
8032 if (structure->IsProxy() || structure->IsAccessorInfo()) { 8043 if (structure->IsProxy() || structure->IsAccessorInfo()) {
8033 value = receiver->GetPropertyWithCallback( 8044 value = receiver->GetPropertyWithCallback(
8034 receiver, structure, name, result->holder()); 8045 receiver, structure, name, result->holder());
8035 if (value->IsException()) { 8046 if (value->IsException()) {
8036 value = Top::pending_exception(); 8047 value = Isolate::Current()->pending_exception();
8037 Top::clear_pending_exception(); 8048 Isolate::Current()->clear_pending_exception();
8038 if (caught_exception != NULL) { 8049 if (caught_exception != NULL) {
8039 *caught_exception = true; 8050 *caught_exception = true;
8040 } 8051 }
8041 } 8052 }
8042 return value; 8053 return value;
8043 } else { 8054 } else {
8044 return HEAP->undefined_value(); 8055 return HEAP->undefined_value();
8045 } 8056 }
8046 } 8057 }
8047 case INTERCEPTOR: 8058 case INTERCEPTOR:
(...skipping 30 matching lines...) Expand all
8078 CONVERT_ARG_CHECKED(String, name, 1); 8089 CONVERT_ARG_CHECKED(String, name, 1);
8079 8090
8080 // Make sure to set the current context to the context before the debugger was 8091 // Make sure to set the current context to the context before the debugger was
8081 // entered (if the debugger is entered). The reason for switching context here 8092 // entered (if the debugger is entered). The reason for switching context here
8082 // is that for some property lookups (accessors and interceptors) callbacks 8093 // is that for some property lookups (accessors and interceptors) callbacks
8083 // into the embedding application can occour, and the embedding application 8094 // into the embedding application can occour, and the embedding application
8084 // could have the assumption that its own global context is the current 8095 // could have the assumption that its own global context is the current
8085 // context and not some internal debugger context. 8096 // context and not some internal debugger context.
8086 SaveContext save; 8097 SaveContext save;
8087 if (Debug::InDebugger()) { 8098 if (Debug::InDebugger()) {
8088 Top::set_context(*Debug::debugger_entry()->GetContext()); 8099 Isolate::Current()->set_context(*Debug::debugger_entry()->GetContext());
8089 } 8100 }
8090 8101
8091 // Skip the global proxy as it has no properties and always delegates to the 8102 // Skip the global proxy as it has no properties and always delegates to the
8092 // real global object. 8103 // real global object.
8093 if (obj->IsJSGlobalProxy()) { 8104 if (obj->IsJSGlobalProxy()) {
8094 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); 8105 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype()));
8095 } 8106 }
8096 8107
8097 8108
8098 // Check if the name is trivially convertible to an index and get the element 8109 // Check if the name is trivially convertible to an index and get the element
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
8232 8243
8233 return obj->GetElementWithInterceptor(*obj, index); 8244 return obj->GetElementWithInterceptor(*obj, index);
8234 } 8245 }
8235 8246
8236 8247
8237 static Object* Runtime_CheckExecutionState(Arguments args) { 8248 static Object* Runtime_CheckExecutionState(Arguments args) {
8238 ASSERT(args.length() >= 1); 8249 ASSERT(args.length() >= 1);
8239 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 8250 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
8240 // Check that the break id is valid. 8251 // Check that the break id is valid.
8241 if (Debug::break_id() == 0 || break_id != Debug::break_id()) { 8252 if (Debug::break_id() == 0 || break_id != Debug::break_id()) {
8242 return Top::Throw(HEAP->illegal_execution_state_symbol()); 8253 return Isolate::Current()->Throw(HEAP->illegal_execution_state_symbol());
8243 } 8254 }
8244 8255
8245 return HEAP->true_value(); 8256 return HEAP->true_value();
8246 } 8257 }
8247 8258
8248 8259
8249 static Object* Runtime_GetFrameCount(Arguments args) { 8260 static Object* Runtime_GetFrameCount(Arguments args) {
8250 HandleScope scope; 8261 HandleScope scope;
8251 ASSERT(args.length() == 1); 8262 ASSERT(args.length() == 1);
8252 8263
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
8312 int count = 0; 8323 int count = 0;
8313 JavaScriptFrameIterator it(id); 8324 JavaScriptFrameIterator it(id);
8314 for (; !it.done(); it.Advance()) { 8325 for (; !it.done(); it.Advance()) {
8315 if (count == index) break; 8326 if (count == index) break;
8316 count++; 8327 count++;
8317 } 8328 }
8318 if (it.done()) return HEAP->undefined_value(); 8329 if (it.done()) return HEAP->undefined_value();
8319 8330
8320 // Traverse the saved contexts chain to find the active context for the 8331 // Traverse the saved contexts chain to find the active context for the
8321 // selected frame. 8332 // selected frame.
8322 SaveContext* save = Top::save_context(); 8333 SaveContext* save = Isolate::Current()->save_context();
8323 while (save != NULL && !save->below(it.frame())) { 8334 while (save != NULL && !save->below(it.frame())) {
8324 save = save->prev(); 8335 save = save->prev();
8325 } 8336 }
8326 ASSERT(save != NULL); 8337 ASSERT(save != NULL);
8327 8338
8328 // Get the frame id. 8339 // Get the frame id.
8329 Handle<Object> frame_id(WrapFrameId(it.frame()->id())); 8340 Handle<Object> frame_id(WrapFrameId(it.frame()->id()));
8330 8341
8331 // Find source position. 8342 // Find source position.
8332 int position = it.frame()->code()->SourcePosition(it.frame()->pc()); 8343 int position = it.frame()->code()->SourcePosition(it.frame()->pc());
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
8530 8541
8531 // Create a plain JSObject which materializes the local scope for the specified 8542 // Create a plain JSObject which materializes the local scope for the specified
8532 // frame. 8543 // frame.
8533 static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) { 8544 static Handle<JSObject> MaterializeLocalScope(JavaScriptFrame* frame) {
8534 Handle<JSFunction> function(JSFunction::cast(frame->function())); 8545 Handle<JSFunction> function(JSFunction::cast(frame->function()));
8535 Handle<Code> code(function->code()); 8546 Handle<Code> code(function->code());
8536 ScopeInfo<> scope_info(*code); 8547 ScopeInfo<> scope_info(*code);
8537 8548
8538 // Allocate and initialize a JSObject with all the arguments, stack locals 8549 // Allocate and initialize a JSObject with all the arguments, stack locals
8539 // heap locals and extension properties of the debugged function. 8550 // heap locals and extension properties of the debugged function.
8540 Handle<JSObject> local_scope = Factory::NewJSObject(Top::object_function()); 8551 Handle<JSObject> local_scope =
8552 Factory::NewJSObject(Isolate::Current()->object_function());
8541 8553
8542 // First fill all parameters. 8554 // First fill all parameters.
8543 for (int i = 0; i < scope_info.number_of_parameters(); ++i) { 8555 for (int i = 0; i < scope_info.number_of_parameters(); ++i) {
8544 SetProperty(local_scope, 8556 SetProperty(local_scope,
8545 scope_info.parameter_name(i), 8557 scope_info.parameter_name(i),
8546 Handle<Object>(frame->GetParameter(i)), NONE); 8558 Handle<Object>(frame->GetParameter(i)), NONE);
8547 } 8559 }
8548 8560
8549 // Second fill all stack locals. 8561 // Second fill all stack locals.
8550 for (int i = 0; i < scope_info.number_of_stack_slots(); i++) { 8562 for (int i = 0; i < scope_info.number_of_stack_slots(); i++) {
(...skipping 30 matching lines...) Expand all
8581 // Create a plain JSObject which materializes the closure content for the 8593 // Create a plain JSObject which materializes the closure content for the
8582 // context. 8594 // context.
8583 static Handle<JSObject> MaterializeClosure(Handle<Context> context) { 8595 static Handle<JSObject> MaterializeClosure(Handle<Context> context) {
8584 ASSERT(context->is_function_context()); 8596 ASSERT(context->is_function_context());
8585 8597
8586 Handle<Code> code(context->closure()->code()); 8598 Handle<Code> code(context->closure()->code());
8587 ScopeInfo<> scope_info(*code); 8599 ScopeInfo<> scope_info(*code);
8588 8600
8589 // Allocate and initialize a JSObject with all the content of theis function 8601 // Allocate and initialize a JSObject with all the content of theis function
8590 // closure. 8602 // closure.
8591 Handle<JSObject> closure_scope = Factory::NewJSObject(Top::object_function()); 8603 Handle<JSObject> closure_scope =
8604 Factory::NewJSObject(Isolate::Current()->object_function());
8592 8605
8593 // Check whether the arguments shadow object exists. 8606 // Check whether the arguments shadow object exists.
8594 int arguments_shadow_index = 8607 int arguments_shadow_index =
8595 ScopeInfo<>::ContextSlotIndex(*code, 8608 ScopeInfo<>::ContextSlotIndex(*code,
8596 HEAP->arguments_shadow_symbol(), 8609 HEAP->arguments_shadow_symbol(),
8597 NULL); 8610 NULL);
8598 if (arguments_shadow_index >= 0) { 8611 if (arguments_shadow_index >= 0) {
8599 // In this case all the arguments are available in the arguments shadow 8612 // In this case all the arguments are available in the arguments shadow
8600 // object. 8613 // object.
8601 Handle<JSObject> arguments_shadow( 8614 Handle<JSObject> arguments_shadow(
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
8939 ScopedVector<OS::StackFrame> frames(kMaxCFramesSize); 8952 ScopedVector<OS::StackFrame> frames(kMaxCFramesSize);
8940 int frames_count = OS::StackWalk(frames); 8953 int frames_count = OS::StackWalk(frames);
8941 if (frames_count == OS::kStackWalkError) { 8954 if (frames_count == OS::kStackWalkError) {
8942 return HEAP->undefined_value(); 8955 return HEAP->undefined_value();
8943 } 8956 }
8944 8957
8945 Handle<String> address_str = Factory::LookupAsciiSymbol("address"); 8958 Handle<String> address_str = Factory::LookupAsciiSymbol("address");
8946 Handle<String> text_str = Factory::LookupAsciiSymbol("text"); 8959 Handle<String> text_str = Factory::LookupAsciiSymbol("text");
8947 Handle<FixedArray> frames_array = Factory::NewFixedArray(frames_count); 8960 Handle<FixedArray> frames_array = Factory::NewFixedArray(frames_count);
8948 for (int i = 0; i < frames_count; i++) { 8961 for (int i = 0; i < frames_count; i++) {
8949 Handle<JSObject> frame_value = Factory::NewJSObject(Top::object_function()); 8962 Handle<JSObject> frame_value =
8963 Factory::NewJSObject(Isolate::Current()->object_function());
8950 frame_value->SetProperty( 8964 frame_value->SetProperty(
8951 *address_str, 8965 *address_str,
8952 *Factory::NewNumberFromInt(reinterpret_cast<int>(frames[i].address)), 8966 *Factory::NewNumberFromInt(reinterpret_cast<int>(frames[i].address)),
8953 NONE); 8967 NONE);
8954 8968
8955 // Get the stack walk text for this frame. 8969 // Get the stack walk text for this frame.
8956 Handle<String> frame_text; 8970 Handle<String> frame_text;
8957 int frame_text_length = StrLength(frames[i].text); 8971 int frame_text_length = StrLength(frames[i].text);
8958 if (frame_text_length > 0) { 8972 if (frame_text_length > 0) {
8959 Vector<const char> str(frames[i].text, frame_text_length); 8973 Vector<const char> str(frames[i].text, frame_text_length);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
9245 // args[1]: step action from the enumeration StepAction 9259 // args[1]: step action from the enumeration StepAction
9246 // args[2]: number of times to perform the step, for step out it is the number 9260 // args[2]: number of times to perform the step, for step out it is the number
9247 // of frames to step down. 9261 // of frames to step down.
9248 static Object* Runtime_PrepareStep(Arguments args) { 9262 static Object* Runtime_PrepareStep(Arguments args) {
9249 HandleScope scope; 9263 HandleScope scope;
9250 ASSERT(args.length() == 3); 9264 ASSERT(args.length() == 3);
9251 // Check arguments. 9265 // Check arguments.
9252 Object* check = Runtime_CheckExecutionState(args); 9266 Object* check = Runtime_CheckExecutionState(args);
9253 if (check->IsFailure()) return check; 9267 if (check->IsFailure()) return check;
9254 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { 9268 if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
9255 return Top::Throw(HEAP->illegal_argument_symbol()); 9269 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
9256 } 9270 }
9257 9271
9258 // Get the step action and check validity. 9272 // Get the step action and check validity.
9259 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); 9273 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1]));
9260 if (step_action != StepIn && 9274 if (step_action != StepIn &&
9261 step_action != StepNext && 9275 step_action != StepNext &&
9262 step_action != StepOut && 9276 step_action != StepOut &&
9263 step_action != StepInMin && 9277 step_action != StepInMin &&
9264 step_action != StepMin) { 9278 step_action != StepMin) {
9265 return Top::Throw(HEAP->illegal_argument_symbol()); 9279 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
9266 } 9280 }
9267 9281
9268 // Get the number of steps. 9282 // Get the number of steps.
9269 int step_count = NumberToInt32(args[2]); 9283 int step_count = NumberToInt32(args[2]);
9270 if (step_count < 1) { 9284 if (step_count < 1) {
9271 return Top::Throw(HEAP->illegal_argument_symbol()); 9285 return Isolate::Current()->Throw(HEAP->illegal_argument_symbol());
9272 } 9286 }
9273 9287
9274 // Clear all current stepping setup. 9288 // Clear all current stepping setup.
9275 Debug::ClearStepping(); 9289 Debug::ClearStepping();
9276 9290
9277 // Prepare step. 9291 // Prepare step.
9278 Debug::PrepareStep(static_cast<StepAction>(step_action), step_count); 9292 Debug::PrepareStep(static_cast<StepAction>(step_action), step_count);
9279 return HEAP->undefined_value(); 9293 return HEAP->undefined_value();
9280 } 9294 }
9281 9295
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
9377 // Get the frame where the debugging is performed. 9391 // Get the frame where the debugging is performed.
9378 StackFrame::Id id = UnwrapFrameId(wrapped_id); 9392 StackFrame::Id id = UnwrapFrameId(wrapped_id);
9379 JavaScriptFrameIterator it(id); 9393 JavaScriptFrameIterator it(id);
9380 JavaScriptFrame* frame = it.frame(); 9394 JavaScriptFrame* frame = it.frame();
9381 Handle<JSFunction> function(JSFunction::cast(frame->function())); 9395 Handle<JSFunction> function(JSFunction::cast(frame->function()));
9382 Handle<Code> code(function->code()); 9396 Handle<Code> code(function->code());
9383 ScopeInfo<> sinfo(*code); 9397 ScopeInfo<> sinfo(*code);
9384 9398
9385 // Traverse the saved contexts chain to find the active context for the 9399 // Traverse the saved contexts chain to find the active context for the
9386 // selected frame. 9400 // selected frame.
9387 SaveContext* save = Top::save_context(); 9401 SaveContext* save = Isolate::Current()->save_context();
9388 while (save != NULL && !save->below(frame)) { 9402 while (save != NULL && !save->below(frame)) {
9389 save = save->prev(); 9403 save = save->prev();
9390 } 9404 }
9391 ASSERT(save != NULL); 9405 ASSERT(save != NULL);
9392 SaveContext savex; 9406 SaveContext savex;
9393 Top::set_context(*(save->context())); 9407 Isolate::Current()->set_context(*(save->context()));
9394 9408
9395 // Create the (empty) function replacing the function on the stack frame for 9409 // Create the (empty) function replacing the function on the stack frame for
9396 // the purpose of evaluating in the context created below. It is important 9410 // the purpose of evaluating in the context created below. It is important
9397 // that this function does not describe any parameters and local variables 9411 // that this function does not describe any parameters and local variables
9398 // in the context. If it does then this will cause problems with the lookup 9412 // in the context. If it does then this will cause problems with the lookup
9399 // in Context::Lookup, where context slots for parameters and local variables 9413 // in Context::Lookup, where context slots for parameters and local variables
9400 // are looked at before the extension object. 9414 // are looked at before the extension object.
9401 Handle<JSFunction> go_between = 9415 Handle<JSFunction> go_between =
9402 Factory::NewFunction(Factory::empty_string(), Factory::undefined_value()); 9416 Factory::NewFunction(Factory::empty_string(), Factory::undefined_value());
9403 go_between->set_context(function->context()); 9417 go_between->set_context(function->context());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
9484 // Handle the processing of break. 9498 // Handle the processing of break.
9485 DisableBreak disable_break_save(disable_break); 9499 DisableBreak disable_break_save(disable_break);
9486 9500
9487 // Enter the top context from before the debugger was invoked. 9501 // Enter the top context from before the debugger was invoked.
9488 SaveContext save; 9502 SaveContext save;
9489 SaveContext* top = &save; 9503 SaveContext* top = &save;
9490 while (top != NULL && *top->context() == *Debug::debug_context()) { 9504 while (top != NULL && *top->context() == *Debug::debug_context()) {
9491 top = top->prev(); 9505 top = top->prev();
9492 } 9506 }
9493 if (top != NULL) { 9507 if (top != NULL) {
9494 Top::set_context(*top->context()); 9508 Isolate::Current()->set_context(*top->context());
9495 } 9509 }
9496 9510
9497 // Get the global context now set to the top context from before the 9511 // Get the global context now set to the top context from before the
9498 // debugger was invoked. 9512 // debugger was invoked.
9499 Handle<Context> context = Top::global_context(); 9513 Handle<Context> context = Isolate::Current()->global_context();
9500 9514
9501 // Compile the source to be evaluated. 9515 // Compile the source to be evaluated.
9502 Handle<SharedFunctionInfo> shared = 9516 Handle<SharedFunctionInfo> shared =
9503 Compiler::CompileEval(source, 9517 Compiler::CompileEval(source,
9504 context, 9518 context,
9505 true, 9519 true,
9506 Compiler::DONT_VALIDATE_JSON); 9520 Compiler::DONT_VALIDATE_JSON);
9507 if (shared.is_null()) return Failure::Exception(); 9521 if (shared.is_null()) return Failure::Exception();
9508 Handle<JSFunction> compiled_function = 9522 Handle<JSFunction> compiled_function =
9509 Handle<JSFunction>(Factory::NewFunctionFromSharedFunctionInfo(shared, 9523 Handle<JSFunction>(Factory::NewFunctionFromSharedFunctionInfo(shared,
9510 context)); 9524 context));
9511 9525
9512 // Invoke the result of the compilation to get the evaluation function. 9526 // Invoke the result of the compilation to get the evaluation function.
9513 bool has_pending_exception; 9527 bool has_pending_exception;
9514 Handle<Object> receiver = Top::global(); 9528 Handle<Object> receiver = Isolate::Current()->global();
9515 Handle<Object> result = 9529 Handle<Object> result =
9516 Execution::Call(compiled_function, receiver, 0, NULL, 9530 Execution::Call(compiled_function, receiver, 0, NULL,
9517 &has_pending_exception); 9531 &has_pending_exception);
9518 if (has_pending_exception) return Failure::Exception(); 9532 if (has_pending_exception) return Failure::Exception();
9519 return *result; 9533 return *result;
9520 } 9534 }
9521 9535
9522 9536
9523 static Object* Runtime_DebugGetLoadedScripts(Arguments args) { 9537 static Object* Runtime_DebugGetLoadedScripts(Arguments args) {
9524 HandleScope scope; 9538 HandleScope scope;
9525 ASSERT(args.length() == 0); 9539 ASSERT(args.length() == 0);
9526 9540
9527 // Fill the script objects. 9541 // Fill the script objects.
9528 Handle<FixedArray> instances = Debug::GetLoadedScripts(); 9542 Handle<FixedArray> instances = Debug::GetLoadedScripts();
9529 9543
9530 // Convert the script objects to proper JS objects. 9544 // Convert the script objects to proper JS objects.
9531 for (int i = 0; i < instances->length(); i++) { 9545 for (int i = 0; i < instances->length(); i++) {
9532 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); 9546 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i)));
9533 // Get the script wrapper in a local handle before calling GetScriptWrapper, 9547 // Get the script wrapper in a local handle before calling GetScriptWrapper,
9534 // because using 9548 // because using
9535 // instances->set(i, *GetScriptWrapper(script)) 9549 // instances->set(i, *GetScriptWrapper(script))
9536 // is unsafe as GetScriptWrapper might call GC and the C++ compiler might 9550 // is unsafe as GetScriptWrapper might call GC and the C++ compiler might
9537 // already have deferenced the instances handle. 9551 // already have deferenced the instances handle.
9538 Handle<JSValue> wrapper = GetScriptWrapper(script); 9552 Handle<JSValue> wrapper = GetScriptWrapper(script);
9539 instances->set(i, *wrapper); 9553 instances->set(i, *wrapper);
9540 } 9554 }
9541 9555
9542 // Return result as a JS array. 9556 // Return result as a JS array.
9543 Handle<JSObject> result = Factory::NewJSObject(Top::array_function()); 9557 Handle<JSObject> result = Factory::NewJSObject(
9558 Isolate::Current()->array_function());
9544 Handle<JSArray>::cast(result)->SetContent(*instances); 9559 Handle<JSArray>::cast(result)->SetContent(*instances);
9545 return *result; 9560 return *result;
9546 } 9561 }
9547 9562
9548 9563
9549 // Helper function used by Runtime_DebugReferencedBy below. 9564 // Helper function used by Runtime_DebugReferencedBy below.
9550 static int DebugReferencedBy(JSObject* target, 9565 static int DebugReferencedBy(JSObject* target,
9551 Object* instance_filter, int max_references, 9566 Object* instance_filter, int max_references,
9552 FixedArray* instances, int instances_size, 9567 FixedArray* instances, int instances_size,
9553 JSFunction* arguments_function) { 9568 JSFunction* arguments_function) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
9629 // Check parameters. 9644 // Check parameters.
9630 CONVERT_CHECKED(JSObject, target, args[0]); 9645 CONVERT_CHECKED(JSObject, target, args[0]);
9631 Object* instance_filter = args[1]; 9646 Object* instance_filter = args[1];
9632 RUNTIME_ASSERT(instance_filter->IsUndefined() || 9647 RUNTIME_ASSERT(instance_filter->IsUndefined() ||
9633 instance_filter->IsJSObject()); 9648 instance_filter->IsJSObject());
9634 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); 9649 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]);
9635 RUNTIME_ASSERT(max_references >= 0); 9650 RUNTIME_ASSERT(max_references >= 0);
9636 9651
9637 // Get the constructor function for context extension and arguments array. 9652 // Get the constructor function for context extension and arguments array.
9638 JSObject* arguments_boilerplate = 9653 JSObject* arguments_boilerplate =
9639 Top::context()->global_context()->arguments_boilerplate(); 9654 Isolate::Current()->context()->global_context()->arguments_boilerplate();
9640 JSFunction* arguments_function = 9655 JSFunction* arguments_function =
9641 JSFunction::cast(arguments_boilerplate->map()->constructor()); 9656 JSFunction::cast(arguments_boilerplate->map()->constructor());
9642 9657
9643 // Get the number of referencing objects. 9658 // Get the number of referencing objects.
9644 int count; 9659 int count;
9645 count = DebugReferencedBy(target, instance_filter, max_references, 9660 count = DebugReferencedBy(target, instance_filter, max_references,
9646 NULL, 0, arguments_function); 9661 NULL, 0, arguments_function);
9647 9662
9648 // Allocate an array to hold the result. 9663 // Allocate an array to hold the result.
9649 Object* object = HEAP->AllocateFixedArray(count); 9664 Object* object = HEAP->AllocateFixedArray(count);
9650 if (object->IsFailure()) return object; 9665 if (object->IsFailure()) return object;
9651 FixedArray* instances = FixedArray::cast(object); 9666 FixedArray* instances = FixedArray::cast(object);
9652 9667
9653 // Fill the referencing objects. 9668 // Fill the referencing objects.
9654 count = DebugReferencedBy(target, instance_filter, max_references, 9669 count = DebugReferencedBy(target, instance_filter, max_references,
9655 instances, count, arguments_function); 9670 instances, count, arguments_function);
9656 9671
9657 // Return result as JS array. 9672 // Return result as JS array.
9658 Object* result = 9673 Object* result =
9659 HEAP->AllocateJSObject( 9674 HEAP->AllocateJSObject(
9660 Top::context()->global_context()->array_function()); 9675 Isolate::Current()->context()->global_context()->array_function());
9661 if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances); 9676 if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances);
9662 return result; 9677 return result;
9663 } 9678 }
9664 9679
9665 9680
9666 // Helper function used by Runtime_DebugConstructedBy below. 9681 // Helper function used by Runtime_DebugConstructedBy below.
9667 static int DebugConstructedBy(JSFunction* constructor, int max_references, 9682 static int DebugConstructedBy(JSFunction* constructor, int max_references,
9668 FixedArray* instances, int instances_size) { 9683 FixedArray* instances, int instances_size) {
9669 AssertNoAllocation no_alloc; 9684 AssertNoAllocation no_alloc;
9670 9685
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
9715 Object* object = HEAP->AllocateFixedArray(count); 9730 Object* object = HEAP->AllocateFixedArray(count);
9716 if (object->IsFailure()) return object; 9731 if (object->IsFailure()) return object;
9717 FixedArray* instances = FixedArray::cast(object); 9732 FixedArray* instances = FixedArray::cast(object);
9718 9733
9719 // Fill the referencing objects. 9734 // Fill the referencing objects.
9720 count = DebugConstructedBy(constructor, max_references, instances, count); 9735 count = DebugConstructedBy(constructor, max_references, instances, count);
9721 9736
9722 // Return result as JS array. 9737 // Return result as JS array.
9723 Object* result = 9738 Object* result =
9724 HEAP->AllocateJSObject( 9739 HEAP->AllocateJSObject(
9725 Top::context()->global_context()->array_function()); 9740 Isolate::Current()->context()->global_context()->array_function());
9726 if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances); 9741 if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances);
9727 return result; 9742 return result;
9728 } 9743 }
9729 9744
9730 9745
9731 // Find the effective prototype object as returned by __proto__. 9746 // Find the effective prototype object as returned by __proto__.
9732 // args[0]: the object to find the prototype for. 9747 // args[0]: the object to find the prototype for.
9733 static Object* Runtime_DebugGetPrototype(Arguments args) { 9748 static Object* Runtime_DebugGetPrototype(Arguments args) {
9734 ASSERT(args.length() == 1); 9749 ASSERT(args.length() == 1);
9735 9750
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
9850 // with the function itself going first. The root function is a script function. 9865 // with the function itself going first. The root function is a script function.
9851 static Object* Runtime_LiveEditGatherCompileInfo(Arguments args) { 9866 static Object* Runtime_LiveEditGatherCompileInfo(Arguments args) {
9852 ASSERT(args.length() == 2); 9867 ASSERT(args.length() == 2);
9853 HandleScope scope; 9868 HandleScope scope;
9854 CONVERT_CHECKED(JSValue, script, args[0]); 9869 CONVERT_CHECKED(JSValue, script, args[0]);
9855 CONVERT_ARG_CHECKED(String, source, 1); 9870 CONVERT_ARG_CHECKED(String, source, 1);
9856 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 9871 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
9857 9872
9858 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); 9873 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
9859 9874
9860 if (Top::has_pending_exception()) { 9875 if (Isolate::Current()->has_pending_exception()) {
9861 return Failure::Exception(); 9876 return Failure::Exception();
9862 } 9877 }
9863 9878
9864 return result; 9879 return result;
9865 } 9880 }
9866 9881
9867 // Changes the source of the script to a new_source. 9882 // Changes the source of the script to a new_source.
9868 // If old_script_name is provided (i.e. is a String), also creates a copy of 9883 // If old_script_name is provided (i.e. is a String), also creates a copy of
9869 // the script with its original source and sends notification to debugger. 9884 // the script with its original source and sends notification to debugger.
9870 static Object* Runtime_LiveEditReplaceScript(Arguments args) { 9885 static Object* Runtime_LiveEditReplaceScript(Arguments args) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
10019 static Object* Runtime_ExecuteInDebugContext(Arguments args) { 10034 static Object* Runtime_ExecuteInDebugContext(Arguments args) {
10020 ASSERT(args.length() == 2); 10035 ASSERT(args.length() == 2);
10021 HandleScope scope; 10036 HandleScope scope;
10022 CONVERT_ARG_CHECKED(JSFunction, function, 0); 10037 CONVERT_ARG_CHECKED(JSFunction, function, 0);
10023 CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]); 10038 CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]);
10024 10039
10025 Handle<Object> result; 10040 Handle<Object> result;
10026 bool pending_exception; 10041 bool pending_exception;
10027 { 10042 {
10028 if (without_debugger) { 10043 if (without_debugger) {
10029 result = Execution::Call(function, Top::global(), 0, NULL, 10044 result = Execution::Call(function, Isolate::Current()->global(), 0, NULL,
10030 &pending_exception); 10045 &pending_exception);
10031 } else { 10046 } else {
10032 EnterDebugger enter_debugger; 10047 EnterDebugger enter_debugger;
10033 result = Execution::Call(function, Top::global(), 0, NULL, 10048 result = Execution::Call(function, Isolate::Current()->global(), 0, NULL,
10034 &pending_exception); 10049 &pending_exception);
10035 } 10050 }
10036 } 10051 }
10037 if (!pending_exception) { 10052 if (!pending_exception) {
10038 return *result; 10053 return *result;
10039 } else { 10054 } else {
10040 return Failure::Exception(); 10055 return Failure::Exception();
10041 } 10056 }
10042 } 10057 }
10043 10058
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
10207 const char* version_string = v8::V8::GetVersion(); 10222 const char* version_string = v8::V8::GetVersion();
10208 10223
10209 return HEAP->AllocateStringFromAscii(CStrVector(version_string), NOT_TENURED); 10224 return HEAP->AllocateStringFromAscii(CStrVector(version_string), NOT_TENURED);
10210 } 10225 }
10211 10226
10212 10227
10213 static Object* Runtime_Abort(Arguments args) { 10228 static Object* Runtime_Abort(Arguments args) {
10214 ASSERT(args.length() == 2); 10229 ASSERT(args.length() == 2);
10215 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + 10230 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) +
10216 Smi::cast(args[1])->value()); 10231 Smi::cast(args[1])->value());
10217 Top::PrintStack(); 10232 Isolate::Current()->PrintStack();
10218 OS::Abort(); 10233 OS::Abort();
10219 UNREACHABLE(); 10234 UNREACHABLE();
10220 return NULL; 10235 return NULL;
10221 } 10236 }
10222 10237
10223 10238
10224 static Object* Runtime_DeleteHandleScopeExtensions(Arguments args) { 10239 static Object* Runtime_DeleteHandleScopeExtensions(Arguments args) {
10225 ASSERT(args.length() == 0); 10240 ASSERT(args.length() == 0);
10226 Isolate* isolate = Isolate::Current(); 10241 Isolate* isolate = Isolate::Current();
10227 HandleScope::DeleteExtensions(isolate); 10242 HandleScope::DeleteExtensions(isolate);
10228 return isolate->heap()->undefined_value(); 10243 return isolate->heap()->undefined_value();
10229 } 10244 }
10230 10245
10231 10246
10232 static Object* CacheMiss(FixedArray* cache_obj, int index, Object* key_obj) { 10247 static Object* CacheMiss(FixedArray* cache_obj, int index, Object* key_obj) {
10233 ASSERT(index % 2 == 0); // index of the key 10248 ASSERT(index % 2 == 0); // index of the key
10234 ASSERT(index >= JSFunctionResultCache::kEntriesIndex); 10249 ASSERT(index >= JSFunctionResultCache::kEntriesIndex);
10235 ASSERT(index < cache_obj->length()); 10250 ASSERT(index < cache_obj->length());
10236 10251
10237 HandleScope scope; 10252 HandleScope scope;
10238 10253
10239 Handle<FixedArray> cache(cache_obj); 10254 Handle<FixedArray> cache(cache_obj);
10240 Handle<Object> key(key_obj); 10255 Handle<Object> key(key_obj);
10241 Handle<JSFunction> factory(JSFunction::cast( 10256 Handle<JSFunction> factory(JSFunction::cast(
10242 cache->get(JSFunctionResultCache::kFactoryIndex))); 10257 cache->get(JSFunctionResultCache::kFactoryIndex)));
10243 // TODO(antonm): consider passing a receiver when constructing a cache. 10258 // TODO(antonm): consider passing a receiver when constructing a cache.
10244 Handle<Object> receiver(Top::global_context()->global()); 10259 Handle<Object> receiver(Isolate::Current()->global_context()->global());
10245 10260
10246 Handle<Object> value; 10261 Handle<Object> value;
10247 { 10262 {
10248 // This handle is nor shared, nor used later, so it's safe. 10263 // This handle is nor shared, nor used later, so it's safe.
10249 Object** argv[] = { key.location() }; 10264 Object** argv[] = { key.location() };
10250 bool pending_exception = false; 10265 bool pending_exception = false;
10251 value = Execution::Call(factory, 10266 value = Execution::Call(factory,
10252 receiver, 10267 receiver,
10253 1, 10268 1,
10254 argv, 10269 argv,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
10406 } else { 10421 } else {
10407 // Handle last resort GC and make sure to allow future allocations 10422 // Handle last resort GC and make sure to allow future allocations
10408 // to grow the heap without causing GCs (if possible). 10423 // to grow the heap without causing GCs (if possible).
10409 Counters::gc_last_resort_from_js.Increment(); 10424 Counters::gc_last_resort_from_js.Increment();
10410 HEAP->CollectAllGarbage(false); 10425 HEAP->CollectAllGarbage(false);
10411 } 10426 }
10412 } 10427 }
10413 10428
10414 10429
10415 } } // namespace v8::internal 10430 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp-stack.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698