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

Side by Side Diff: src/runtime.cc

Issue 181543002: Eliminate extended mode, and other modes clean-up (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 147
148 // Cast the given argument to PropertyDetails and store its value in a 148 // Cast the given argument to PropertyDetails and store its value in a
149 // variable with the given name. If the argument is not a Smi call 149 // variable with the given name. If the argument is not a Smi call
150 // IllegalOperation and return. 150 // IllegalOperation and return.
151 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \ 151 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \
152 RUNTIME_ASSERT(args[index]->IsSmi()); \ 152 RUNTIME_ASSERT(args[index]->IsSmi()); \
153 PropertyDetails name = PropertyDetails(Smi::cast(args[index])); 153 PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
154 154
155 155
156 // Assert that the given argument has a valid value for a StrictModeFlag 156 // Assert that the given argument has a valid value for a StrictMode
157 // and store it in a StrictModeFlag variable with the given name. 157 // and store it in a StrictMode variable with the given name.
158 #define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \ 158 #define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
159 RUNTIME_ASSERT(args[index]->IsSmi()); \ 159 RUNTIME_ASSERT(args[index]->IsSmi()); \
160 RUNTIME_ASSERT(args.smi_at(index) == kStrictMode || \ 160 RUNTIME_ASSERT(args.smi_at(index) == STRICT || \
161 args.smi_at(index) == kSloppyMode); \ 161 args.smi_at(index) == SLOPPY); \
162 StrictModeFlag name = \ 162 StrictMode name = static_cast<StrictMode>(args.smi_at(index));
163 static_cast<StrictModeFlag>(args.smi_at(index));
164
165
166 // Assert that the given argument has a valid value for a LanguageMode
167 // and store it in a LanguageMode variable with the given name.
168 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \
169 ASSERT(args[index]->IsSmi()); \
170 ASSERT(args.smi_at(index) == SLOPPY_MODE || \
171 args.smi_at(index) == STRICT_MODE || \
172 args.smi_at(index) == EXTENDED_MODE); \
173 LanguageMode name = \
174 static_cast<LanguageMode>(args.smi_at(index));
175 163
176 164
177 static Handle<Map> ComputeObjectLiteralMap( 165 static Handle<Map> ComputeObjectLiteralMap(
178 Handle<Context> context, 166 Handle<Context> context,
179 Handle<FixedArray> constant_properties, 167 Handle<FixedArray> constant_properties,
180 bool* is_result_from_cache) { 168 bool* is_result_from_cache) {
181 Isolate* isolate = context->GetIsolate(); 169 Isolate* isolate = context->GetIsolate();
182 int properties_length = constant_properties->length(); 170 int properties_length = constant_properties->length();
183 int number_of_properties = properties_length / 2; 171 int number_of_properties = properties_length / 2;
184 // Check that there are only internal strings and array indices among keys. 172 // Check that there are only internal strings and array indices among keys.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 value = CreateLiteralBoilerplate(isolate, literals, array); 279 value = CreateLiteralBoilerplate(isolate, literals, array);
292 if (value.is_null()) return value; 280 if (value.is_null()) return value;
293 } 281 }
294 Handle<Object> result; 282 Handle<Object> result;
295 uint32_t element_index = 0; 283 uint32_t element_index = 0;
296 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT; 284 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT;
297 if (key->IsInternalizedString()) { 285 if (key->IsInternalizedString()) {
298 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 286 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
299 // Array index as string (uint32). 287 // Array index as string (uint32).
300 result = JSObject::SetOwnElement( 288 result = JSObject::SetOwnElement(
301 boilerplate, element_index, value, kSloppyMode); 289 boilerplate, element_index, value, SLOPPY);
302 } else { 290 } else {
303 Handle<String> name(String::cast(*key)); 291 Handle<String> name(String::cast(*key));
304 ASSERT(!name->AsArrayIndex(&element_index)); 292 ASSERT(!name->AsArrayIndex(&element_index));
305 result = JSObject::SetLocalPropertyIgnoreAttributes( 293 result = JSObject::SetLocalPropertyIgnoreAttributes(
306 boilerplate, name, value, NONE, 294 boilerplate, name, value, NONE,
307 Object::OPTIMAL_REPRESENTATION, mode); 295 Object::OPTIMAL_REPRESENTATION, mode);
308 } 296 }
309 } else if (key->ToArrayIndex(&element_index)) { 297 } else if (key->ToArrayIndex(&element_index)) {
310 // Array index (uint32). 298 // Array index (uint32).
311 result = JSObject::SetOwnElement( 299 result = JSObject::SetOwnElement(
312 boilerplate, element_index, value, kSloppyMode); 300 boilerplate, element_index, value, SLOPPY);
313 } else { 301 } else {
314 // Non-uint32 number. 302 // Non-uint32 number.
315 ASSERT(key->IsNumber()); 303 ASSERT(key->IsNumber());
316 double num = key->Number(); 304 double num = key->Number();
317 char arr[100]; 305 char arr[100];
318 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 306 Vector<char> buffer(arr, ARRAY_SIZE(arr));
319 const char* str = DoubleToCString(num, buffer); 307 const char* str = DoubleToCString(num, buffer);
320 Handle<String> name = 308 Handle<String> name =
321 isolate->factory()->NewStringFromAscii(CStrVector(str)); 309 isolate->factory()->NewStringFromAscii(CStrVector(str));
322 result = JSObject::SetLocalPropertyIgnoreAttributes( 310 result = JSObject::SetLocalPropertyIgnoreAttributes(
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 int attr = NONE; 2079 int attr = NONE;
2092 bool is_eval = DeclareGlobalsEvalFlag::decode(flags); 2080 bool is_eval = DeclareGlobalsEvalFlag::decode(flags);
2093 if (!is_eval) { 2081 if (!is_eval) {
2094 attr |= DONT_DELETE; 2082 attr |= DONT_DELETE;
2095 } 2083 }
2096 bool is_native = DeclareGlobalsNativeFlag::decode(flags); 2084 bool is_native = DeclareGlobalsNativeFlag::decode(flags);
2097 if (is_const || (is_native && is_function)) { 2085 if (is_const || (is_native && is_function)) {
2098 attr |= READ_ONLY; 2086 attr |= READ_ONLY;
2099 } 2087 }
2100 2088
2101 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); 2089 StrictMode strict_mode = DeclareGlobalsStrictMode::decode(flags);
2102 2090
2103 if (!lookup.IsFound() || is_function) { 2091 if (!lookup.IsFound() || is_function) {
2104 // If the local property exists, check that we can reconfigure it 2092 // If the local property exists, check that we can reconfigure it
2105 // as required for function declarations. 2093 // as required for function declarations.
2106 if (lookup.IsFound() && lookup.IsDontDelete()) { 2094 if (lookup.IsFound() && lookup.IsDontDelete()) {
2107 if (lookup.IsReadOnly() || lookup.IsDontEnum() || 2095 if (lookup.IsReadOnly() || lookup.IsDontEnum() ||
2108 lookup.IsPropertyCallbacks()) { 2096 lookup.IsPropertyCallbacks()) {
2109 return ThrowRedeclarationError(isolate, "function", name); 2097 return ThrowRedeclarationError(isolate, "function", name);
2110 } 2098 }
2111 // If the existing property is not configurable, keep its attributes. 2099 // If the existing property is not configurable, keep its attributes.
2112 attr = lookup.GetAttributes(); 2100 attr = lookup.GetAttributes();
2113 } 2101 }
2114 // Define or redefine own property. 2102 // Define or redefine own property.
2115 RETURN_IF_EMPTY_HANDLE(isolate, 2103 RETURN_IF_EMPTY_HANDLE(isolate,
2116 JSObject::SetLocalPropertyIgnoreAttributes( 2104 JSObject::SetLocalPropertyIgnoreAttributes(
2117 global, name, value, static_cast<PropertyAttributes>(attr))); 2105 global, name, value, static_cast<PropertyAttributes>(attr)));
2118 } else { 2106 } else {
2119 // Do a [[Put]] on the existing (own) property. 2107 // Do a [[Put]] on the existing (own) property.
2120 RETURN_IF_EMPTY_HANDLE(isolate, 2108 RETURN_IF_EMPTY_HANDLE(isolate,
2121 JSObject::SetProperty( 2109 JSObject::SetProperty(
2122 global, name, value, static_cast<PropertyAttributes>(attr), 2110 global, name, value, static_cast<PropertyAttributes>(attr),
2123 language_mode == SLOPPY_MODE ? kSloppyMode : kStrictMode)); 2111 strict_mode));
2124 } 2112 }
2125 } 2113 }
2126 2114
2127 ASSERT(!isolate->has_pending_exception()); 2115 ASSERT(!isolate->has_pending_exception());
2128 return isolate->heap()->undefined_value(); 2116 return isolate->heap()->undefined_value();
2129 } 2117 }
2130 2118
2131 2119
2132 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { 2120 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
2133 HandleScope scope(isolate); 2121 HandleScope scope(isolate);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 if (((attributes & READ_ONLY) == 0) || 2157 if (((attributes & READ_ONLY) == 0) ||
2170 context->get(index)->IsTheHole()) { 2158 context->get(index)->IsTheHole()) {
2171 context->set(index, *initial_value); 2159 context->set(index, *initial_value);
2172 } 2160 }
2173 } else { 2161 } else {
2174 // Slow case: The property is in the context extension object of a 2162 // Slow case: The property is in the context extension object of a
2175 // function context or the global object of a native context. 2163 // function context or the global object of a native context.
2176 Handle<JSObject> object = Handle<JSObject>::cast(holder); 2164 Handle<JSObject> object = Handle<JSObject>::cast(holder);
2177 RETURN_IF_EMPTY_HANDLE( 2165 RETURN_IF_EMPTY_HANDLE(
2178 isolate, 2166 isolate,
2179 JSReceiver::SetProperty(object, name, initial_value, mode, 2167 JSReceiver::SetProperty(object, name, initial_value, mode, SLOPPY));
2180 kSloppyMode));
2181 } 2168 }
2182 } 2169 }
2183 2170
2184 } else { 2171 } else {
2185 // The property is not in the function context. It needs to be 2172 // The property is not in the function context. It needs to be
2186 // "declared" in the function context's extension context or as a 2173 // "declared" in the function context's extension context or as a
2187 // property of the the global object. 2174 // property of the the global object.
2188 Handle<JSObject> object; 2175 Handle<JSObject> object;
2189 if (context->has_extension()) { 2176 if (context->has_extension()) {
2190 object = Handle<JSObject>(JSObject::cast(context->extension())); 2177 object = Handle<JSObject>(JSObject::cast(context->extension()));
(...skipping 25 matching lines...) Expand all
2216 if (lookup.IsPropertyCallbacks()) { 2203 if (lookup.IsPropertyCallbacks()) {
2217 return ThrowRedeclarationError(isolate, "const", name); 2204 return ThrowRedeclarationError(isolate, "const", name);
2218 } 2205 }
2219 } 2206 }
2220 if (object->IsJSGlobalObject()) { 2207 if (object->IsJSGlobalObject()) {
2221 // Define own property on the global object. 2208 // Define own property on the global object.
2222 RETURN_IF_EMPTY_HANDLE(isolate, 2209 RETURN_IF_EMPTY_HANDLE(isolate,
2223 JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode)); 2210 JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode));
2224 } else { 2211 } else {
2225 RETURN_IF_EMPTY_HANDLE(isolate, 2212 RETURN_IF_EMPTY_HANDLE(isolate,
2226 JSReceiver::SetProperty(object, name, value, mode, kSloppyMode)); 2213 JSReceiver::SetProperty(object, name, value, mode, SLOPPY));
2227 } 2214 }
2228 } 2215 }
2229 2216
2230 return isolate->heap()->undefined_value(); 2217 return isolate->heap()->undefined_value();
2231 } 2218 }
2232 2219
2233 2220
2234 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { 2221 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
2235 HandleScope scope(isolate); 2222 HandleScope scope(isolate);
2236 // args[0] == name 2223 // args[0] == name
2237 // args[1] == language_mode 2224 // args[1] == language_mode
2238 // args[2] == value (optional) 2225 // args[2] == value (optional)
2239 2226
2240 // Determine if we need to assign to the variable if it already 2227 // Determine if we need to assign to the variable if it already
2241 // exists (based on the number of arguments). 2228 // exists (based on the number of arguments).
2242 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 2229 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
2243 bool assign = args.length() == 3; 2230 bool assign = args.length() == 3;
2244 2231
2245 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 2232 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
2246 RUNTIME_ASSERT(args[1]->IsSmi()); 2233 RUNTIME_ASSERT(args[1]->IsSmi());
2247 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1); 2234 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 1);
2248 StrictModeFlag strict_mode_flag = (language_mode == SLOPPY_MODE)
2249 ? kSloppyMode : kStrictMode;
2250 2235
2251 // According to ECMA-262, section 12.2, page 62, the property must 2236 // According to ECMA-262, section 12.2, page 62, the property must
2252 // not be deletable. 2237 // not be deletable.
2253 PropertyAttributes attributes = DONT_DELETE; 2238 PropertyAttributes attributes = DONT_DELETE;
2254 2239
2255 // Lookup the property locally in the global object. If it isn't 2240 // Lookup the property locally in the global object. If it isn't
2256 // there, there is a property with this name in the prototype chain. 2241 // there, there is a property with this name in the prototype chain.
2257 // We follow Safari and Firefox behavior and only set the property 2242 // We follow Safari and Firefox behavior and only set the property
2258 // locally if there is an explicit initialization value that we have 2243 // locally if there is an explicit initialization value that we have
2259 // to assign to the property. 2244 // to assign to the property.
2260 // Note that objects can have hidden prototypes, so we need to traverse 2245 // Note that objects can have hidden prototypes, so we need to traverse
2261 // the whole chain of hidden prototypes to do a 'local' lookup. 2246 // the whole chain of hidden prototypes to do a 'local' lookup.
2262 LookupResult lookup(isolate); 2247 LookupResult lookup(isolate);
2263 isolate->context()->global_object()->LocalLookup(*name, &lookup, true); 2248 isolate->context()->global_object()->LocalLookup(*name, &lookup, true);
2264 if (lookup.IsInterceptor()) { 2249 if (lookup.IsInterceptor()) {
2265 PropertyAttributes intercepted = 2250 PropertyAttributes intercepted =
2266 lookup.holder()->GetPropertyAttribute(*name); 2251 lookup.holder()->GetPropertyAttribute(*name);
2267 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { 2252 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
2268 // Found an interceptor that's not read only. 2253 // Found an interceptor that's not read only.
2269 if (assign) { 2254 if (assign) {
2270 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2255 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
2271 Handle<Object> result = JSObject::SetPropertyForResult( 2256 Handle<Object> result = JSObject::SetPropertyForResult(
2272 handle(lookup.holder()), &lookup, name, value, attributes, 2257 handle(lookup.holder()), &lookup, name, value, attributes,
2273 strict_mode_flag); 2258 strict_mode);
2274 RETURN_IF_EMPTY_HANDLE(isolate, result); 2259 RETURN_IF_EMPTY_HANDLE(isolate, result);
2275 return *result; 2260 return *result;
2276 } else { 2261 } else {
2277 return isolate->heap()->undefined_value(); 2262 return isolate->heap()->undefined_value();
2278 } 2263 }
2279 } 2264 }
2280 } 2265 }
2281 2266
2282 if (assign) { 2267 if (assign) {
2283 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 2268 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
2284 Handle<GlobalObject> global(isolate->context()->global_object()); 2269 Handle<GlobalObject> global(isolate->context()->global_object());
2285 Handle<Object> result = JSReceiver::SetProperty( 2270 Handle<Object> result = JSReceiver::SetProperty(
2286 global, name, value, attributes, strict_mode_flag); 2271 global, name, value, attributes, strict_mode);
2287 RETURN_IF_EMPTY_HANDLE(isolate, result); 2272 RETURN_IF_EMPTY_HANDLE(isolate, result);
2288 return *result; 2273 return *result;
2289 } 2274 }
2290 return isolate->heap()->undefined_value(); 2275 return isolate->heap()->undefined_value();
2291 } 2276 }
2292 2277
2293 2278
2294 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { 2279 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) {
2295 SealHandleScope shs(isolate); 2280 SealHandleScope shs(isolate);
2296 // All constants are declared with an initial value. The name 2281 // All constants are declared with an initial value. The name
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 // with setting the value. 2315 // with setting the value.
2331 HandleScope handle_scope(isolate); 2316 HandleScope handle_scope(isolate);
2332 Handle<GlobalObject> global(isolate->context()->global_object()); 2317 Handle<GlobalObject> global(isolate->context()->global_object());
2333 2318
2334 // BUG 1213575: Handle the case where we have to set a read-only 2319 // BUG 1213575: Handle the case where we have to set a read-only
2335 // property through an interceptor and only do it if it's 2320 // property through an interceptor and only do it if it's
2336 // uninitialized, e.g. the hole. Nirk... 2321 // uninitialized, e.g. the hole. Nirk...
2337 // Passing sloppy mode because the property is writable. 2322 // Passing sloppy mode because the property is writable.
2338 RETURN_IF_EMPTY_HANDLE( 2323 RETURN_IF_EMPTY_HANDLE(
2339 isolate, 2324 isolate,
2340 JSReceiver::SetProperty(global, name, value, attributes, kSloppyMode)); 2325 JSReceiver::SetProperty(global, name, value, attributes, SLOPPY));
2341 return *value; 2326 return *value;
2342 } 2327 }
2343 2328
2344 // Set the value, but only if we're assigning the initial value to a 2329 // Set the value, but only if we're assigning the initial value to a
2345 // constant. For now, we determine this by checking if the 2330 // constant. For now, we determine this by checking if the
2346 // current value is the hole. 2331 // current value is the hole.
2347 // Strict mode handling not needed (const is disallowed in strict mode). 2332 // Strict mode handling not needed (const is disallowed in strict mode).
2348 if (lookup.IsField()) { 2333 if (lookup.IsField()) {
2349 FixedArray* properties = global->properties(); 2334 FixedArray* properties = global->properties();
2350 int index = lookup.GetFieldIndex().field_index(); 2335 int index = lookup.GetFieldIndex().field_index();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 } 2385 }
2401 2386
2402 // The property could not be found, we introduce it as a property of the 2387 // The property could not be found, we introduce it as a property of the
2403 // global object. 2388 // global object.
2404 if (attributes == ABSENT) { 2389 if (attributes == ABSENT) {
2405 Handle<JSObject> global = Handle<JSObject>( 2390 Handle<JSObject> global = Handle<JSObject>(
2406 isolate->context()->global_object()); 2391 isolate->context()->global_object());
2407 // Strict mode not needed (const disallowed in strict mode). 2392 // Strict mode not needed (const disallowed in strict mode).
2408 RETURN_IF_EMPTY_HANDLE( 2393 RETURN_IF_EMPTY_HANDLE(
2409 isolate, 2394 isolate,
2410 JSReceiver::SetProperty(global, name, value, NONE, kSloppyMode)); 2395 JSReceiver::SetProperty(global, name, value, NONE, SLOPPY));
2411 return *value; 2396 return *value;
2412 } 2397 }
2413 2398
2414 // The property was present in some function's context extension object, 2399 // The property was present in some function's context extension object,
2415 // as a property on the subject of a with, or as a property of the global 2400 // as a property on the subject of a with, or as a property of the global
2416 // object. 2401 // object.
2417 // 2402 //
2418 // In most situations, eval-introduced consts should still be present in 2403 // In most situations, eval-introduced consts should still be present in
2419 // the context extension object. However, because declaration and 2404 // the context extension object. However, because declaration and
2420 // initialization are separate, the property might have been deleted 2405 // initialization are separate, the property might have been deleted
(...skipping 30 matching lines...) Expand all
2451 // either a field or a dictionary slot. 2436 // either a field or a dictionary slot.
2452 UNREACHABLE(); 2437 UNREACHABLE();
2453 } 2438 }
2454 } else { 2439 } else {
2455 // The property was found on some other object. Set it if it is not a 2440 // The property was found on some other object. Set it if it is not a
2456 // read-only property. 2441 // read-only property.
2457 if ((attributes & READ_ONLY) == 0) { 2442 if ((attributes & READ_ONLY) == 0) {
2458 // Strict mode not needed (const disallowed in strict mode). 2443 // Strict mode not needed (const disallowed in strict mode).
2459 RETURN_IF_EMPTY_HANDLE( 2444 RETURN_IF_EMPTY_HANDLE(
2460 isolate, 2445 isolate,
2461 JSReceiver::SetProperty(object, name, value, attributes, 2446 JSReceiver::SetProperty(object, name, value, attributes, SLOPPY));
2462 kSloppyMode));
2463 } 2447 }
2464 } 2448 }
2465 2449
2466 return *value; 2450 return *value;
2467 } 2451 }
2468 2452
2469 2453
2470 RUNTIME_FUNCTION(MaybeObject*, 2454 RUNTIME_FUNCTION(MaybeObject*,
2471 Runtime_OptimizeObjectForAddingMultipleProperties) { 2455 Runtime_OptimizeObjectForAddingMultipleProperties) {
2472 HandleScope scope(isolate); 2456 HandleScope scope(isolate);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 Builtins::Name builtin_name) { 2597 Builtins::Name builtin_name) {
2614 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); 2598 Handle<String> key = isolate->factory()->InternalizeUtf8String(name);
2615 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); 2599 Handle<Code> code(isolate->builtins()->builtin(builtin_name));
2616 Handle<JSFunction> optimized = 2600 Handle<JSFunction> optimized =
2617 isolate->factory()->NewFunction(key, 2601 isolate->factory()->NewFunction(key,
2618 JS_OBJECT_TYPE, 2602 JS_OBJECT_TYPE,
2619 JSObject::kHeaderSize, 2603 JSObject::kHeaderSize,
2620 code, 2604 code,
2621 false); 2605 false);
2622 optimized->shared()->DontAdaptArguments(); 2606 optimized->shared()->DontAdaptArguments();
2623 JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode); 2607 JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT);
2624 return optimized; 2608 return optimized;
2625 } 2609 }
2626 2610
2627 2611
2628 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { 2612 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) {
2629 HandleScope scope(isolate); 2613 HandleScope scope(isolate);
2630 ASSERT(args.length() == 1); 2614 ASSERT(args.length() == 1);
2631 CONVERT_ARG_HANDLE_CHECKED(JSObject, holder, 0); 2615 CONVERT_ARG_HANDLE_CHECKED(JSObject, holder, 0);
2632 2616
2633 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); 2617 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop);
(...skipping 15 matching lines...) Expand all
2649 if (!callable->IsJSFunction()) { 2633 if (!callable->IsJSFunction()) {
2650 HandleScope scope(isolate); 2634 HandleScope scope(isolate);
2651 bool threw = false; 2635 bool threw = false;
2652 Handle<Object> delegate = Execution::TryGetFunctionDelegate( 2636 Handle<Object> delegate = Execution::TryGetFunctionDelegate(
2653 isolate, Handle<JSReceiver>(callable), &threw); 2637 isolate, Handle<JSReceiver>(callable), &threw);
2654 if (threw) return Failure::Exception(); 2638 if (threw) return Failure::Exception();
2655 callable = JSFunction::cast(*delegate); 2639 callable = JSFunction::cast(*delegate);
2656 } 2640 }
2657 JSFunction* function = JSFunction::cast(callable); 2641 JSFunction* function = JSFunction::cast(callable);
2658 SharedFunctionInfo* shared = function->shared(); 2642 SharedFunctionInfo* shared = function->shared();
2659 return isolate->heap()->ToBoolean(shared->is_sloppy_mode()); 2643 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY);
2660 } 2644 }
2661 2645
2662 2646
2663 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { 2647 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
2664 SealHandleScope shs(isolate); 2648 SealHandleScope shs(isolate);
2665 ASSERT(args.length() == 1); 2649 ASSERT(args.length() == 1);
2666 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2650 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2667 2651
2668 if (!callable->IsJSFunction()) { 2652 if (!callable->IsJSFunction()) {
2669 HandleScope scope(isolate); 2653 HandleScope scope(isolate);
2670 bool threw = false; 2654 bool threw = false;
2671 Handle<Object> delegate = Execution::TryGetFunctionDelegate( 2655 Handle<Object> delegate = Execution::TryGetFunctionDelegate(
2672 isolate, Handle<JSReceiver>(callable), &threw); 2656 isolate, Handle<JSReceiver>(callable), &threw);
2673 if (threw) return Failure::Exception(); 2657 if (threw) return Failure::Exception();
2674 callable = JSFunction::cast(*delegate); 2658 callable = JSFunction::cast(*delegate);
2675 } 2659 }
2676 JSFunction* function = JSFunction::cast(callable); 2660 JSFunction* function = JSFunction::cast(callable);
2677 2661
2678 SharedFunctionInfo* shared = function->shared(); 2662 SharedFunctionInfo* shared = function->shared();
2679 if (shared->native() || !shared->is_sloppy_mode()) { 2663 if (shared->native() || shared->strict_mode() == STRICT) {
2680 return isolate->heap()->undefined_value(); 2664 return isolate->heap()->undefined_value();
2681 } 2665 }
2682 // Returns undefined for strict or native functions, or 2666 // Returns undefined for strict or native functions, or
2683 // the associated global receiver for "normal" functions. 2667 // the associated global receiver for "normal" functions.
2684 2668
2685 Context* native_context = 2669 Context* native_context =
2686 function->context()->global_object()->native_context(); 2670 function->context()->global_object()->native_context();
2687 return native_context->global_object()->global_receiver(); 2671 return native_context->global_object()->global_receiver();
2688 } 2672 }
2689 2673
(...skipping 2384 matching lines...) Expand 10 before | Expand all | Expand 10 after
5074 // setter to update the value instead. 5058 // setter to update the value instead.
5075 // TODO(mstarzinger): So far this only works if property attributes don't 5059 // TODO(mstarzinger): So far this only works if property attributes don't
5076 // change, this should be fixed once we cleanup the underlying code. 5060 // change, this should be fixed once we cleanup the underlying code.
5077 if (callback->IsForeign() && lookup.GetAttributes() == attr) { 5061 if (callback->IsForeign() && lookup.GetAttributes() == attr) {
5078 Handle<Object> result_object = 5062 Handle<Object> result_object =
5079 JSObject::SetPropertyWithCallback(js_object, 5063 JSObject::SetPropertyWithCallback(js_object,
5080 callback, 5064 callback,
5081 name, 5065 name,
5082 obj_value, 5066 obj_value,
5083 handle(lookup.holder()), 5067 handle(lookup.holder()),
5084 kStrictMode); 5068 STRICT);
5085 RETURN_IF_EMPTY_HANDLE(isolate, result_object); 5069 RETURN_IF_EMPTY_HANDLE(isolate, result_object);
5086 return *result_object; 5070 return *result_object;
5087 } 5071 }
5088 } 5072 }
5089 5073
5090 // Take special care when attributes are different and there is already 5074 // Take special care when attributes are different and there is already
5091 // a property. For simplicity we normalize the property which enables us 5075 // a property. For simplicity we normalize the property which enables us
5092 // to not worry about changing the instance_descriptor and creating a new 5076 // to not worry about changing the instance_descriptor and creating a new
5093 // map. The current version of SetObjectProperty does not handle attributes 5077 // map. The current version of SetObjectProperty does not handle attributes
5094 // correctly in the case where a property is a field and is reset with 5078 // correctly in the case where a property is a field and is reset with
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5147 } 5131 }
5148 return isolate->heap()->undefined_value(); 5132 return isolate->heap()->undefined_value();
5149 } 5133 }
5150 5134
5151 5135
5152 Handle<Object> Runtime::SetObjectProperty(Isolate* isolate, 5136 Handle<Object> Runtime::SetObjectProperty(Isolate* isolate,
5153 Handle<Object> object, 5137 Handle<Object> object,
5154 Handle<Object> key, 5138 Handle<Object> key,
5155 Handle<Object> value, 5139 Handle<Object> value,
5156 PropertyAttributes attr, 5140 PropertyAttributes attr,
5157 StrictModeFlag strict_mode) { 5141 StrictMode strict_mode) {
5158 SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; 5142 SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY;
5159 5143
5160 if (object->IsUndefined() || object->IsNull()) { 5144 if (object->IsUndefined() || object->IsNull()) {
5161 Handle<Object> args[2] = { key, object }; 5145 Handle<Object> args[2] = { key, object };
5162 Handle<Object> error = 5146 Handle<Object> error =
5163 isolate->factory()->NewTypeError("non_object_property_store", 5147 isolate->factory()->NewTypeError("non_object_property_store",
5164 HandleVector(args, 2)); 5148 HandleVector(args, 2));
5165 isolate->Throw(*error); 5149 isolate->Throw(*error);
5166 return Handle<Object>(); 5150 return Handle<Object>();
5167 } 5151 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
5265 // of a string using [] notation. We need to support this too in 5249 // of a string using [] notation. We need to support this too in
5266 // JavaScript. 5250 // JavaScript.
5267 // In the case of a String object we just need to redirect the assignment to 5251 // In the case of a String object we just need to redirect the assignment to
5268 // the underlying string if the index is in range. Since the underlying 5252 // the underlying string if the index is in range. Since the underlying
5269 // string does nothing with the assignment then we can ignore such 5253 // string does nothing with the assignment then we can ignore such
5270 // assignments. 5254 // assignments.
5271 if (js_object->IsStringObjectWithCharacterAt(index)) { 5255 if (js_object->IsStringObjectWithCharacterAt(index)) {
5272 return value; 5256 return value;
5273 } 5257 }
5274 5258
5275 return JSObject::SetElement(js_object, index, value, attr, kSloppyMode, 5259 return JSObject::SetElement(js_object, index, value, attr, SLOPPY,
5276 false, 5260 false,
5277 DEFINE_PROPERTY); 5261 DEFINE_PROPERTY);
5278 } 5262 }
5279 5263
5280 if (key->IsName()) { 5264 if (key->IsName()) {
5281 Handle<Name> name = Handle<Name>::cast(key); 5265 Handle<Name> name = Handle<Name>::cast(key);
5282 if (name->AsArrayIndex(&index)) { 5266 if (name->AsArrayIndex(&index)) {
5283 return JSObject::SetElement(js_object, index, value, attr, kSloppyMode, 5267 return JSObject::SetElement(js_object, index, value, attr, SLOPPY,
5284 false, 5268 false,
5285 DEFINE_PROPERTY); 5269 DEFINE_PROPERTY);
5286 } else { 5270 } else {
5287 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5271 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5288 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, 5272 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name,
5289 value, attr); 5273 value, attr);
5290 } 5274 }
5291 } 5275 }
5292 5276
5293 // Call-back into JavaScript to convert the key to a string. 5277 // Call-back into JavaScript to convert the key to a string.
5294 bool has_pending_exception = false; 5278 bool has_pending_exception = false;
5295 Handle<Object> converted = 5279 Handle<Object> converted =
5296 Execution::ToString(isolate, key, &has_pending_exception); 5280 Execution::ToString(isolate, key, &has_pending_exception);
5297 if (has_pending_exception) return Handle<Object>(); // exception 5281 if (has_pending_exception) return Handle<Object>(); // exception
5298 Handle<String> name = Handle<String>::cast(converted); 5282 Handle<String> name = Handle<String>::cast(converted);
5299 5283
5300 if (name->AsArrayIndex(&index)) { 5284 if (name->AsArrayIndex(&index)) {
5301 return JSObject::SetElement(js_object, index, value, attr, kSloppyMode, 5285 return JSObject::SetElement(js_object, index, value, attr, SLOPPY,
5302 false, 5286 false,
5303 DEFINE_PROPERTY); 5287 DEFINE_PROPERTY);
5304 } else { 5288 } else {
5305 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value, 5289 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value,
5306 attr); 5290 attr);
5307 } 5291 }
5308 } 5292 }
5309 5293
5310 5294
5311 MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate, 5295 MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5358 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 5342 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
5359 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 5343 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
5360 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 5344 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5361 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); 5345 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
5362 RUNTIME_ASSERT( 5346 RUNTIME_ASSERT(
5363 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 5347 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5364 // Compute attributes. 5348 // Compute attributes.
5365 PropertyAttributes attributes = 5349 PropertyAttributes attributes =
5366 static_cast<PropertyAttributes>(unchecked_attributes); 5350 static_cast<PropertyAttributes>(unchecked_attributes);
5367 5351
5368 StrictModeFlag strict_mode = kSloppyMode; 5352 StrictMode strict_mode = SLOPPY;
5369 if (args.length() == 5) { 5353 if (args.length() == 5) {
5370 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_flag, 4); 5354 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4);
5371 strict_mode = strict_mode_flag; 5355 strict_mode = strict_mode_arg;
5372 } 5356 }
5373 5357
5374 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, 5358 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
5375 value, 5359 value,
5376 attributes, 5360 attributes,
5377 strict_mode); 5361 strict_mode);
5378 RETURN_IF_EMPTY_HANDLE(isolate, result); 5362 RETURN_IF_EMPTY_HANDLE(isolate, result);
5379 return *result; 5363 return *result;
5380 } 5364 }
5381 5365
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
5540 return *result; 5524 return *result;
5541 } 5525 }
5542 5526
5543 5527
5544 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { 5528 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) {
5545 HandleScope scope(isolate); 5529 HandleScope scope(isolate);
5546 ASSERT(args.length() == 3); 5530 ASSERT(args.length() == 3);
5547 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); 5531 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
5548 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 5532 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5549 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); 5533 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2);
5550 JSReceiver::DeleteMode delete_mode = (strict_mode == kStrictMode) 5534 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT
5551 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; 5535 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION;
5552 Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode); 5536 Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode);
5553 RETURN_IF_EMPTY_HANDLE(isolate, result); 5537 RETURN_IF_EMPTY_HANDLE(isolate, result);
5554 return *result; 5538 return *result;
5555 } 5539 }
5556 5540
5557 5541
5558 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate, 5542 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate,
5559 Handle<JSObject> object, 5543 Handle<JSObject> object,
5560 Handle<Name> key) { 5544 Handle<Name> key) {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
5982 return frame->GetParameter(index); 5966 return frame->GetParameter(index);
5983 } else { 5967 } else {
5984 return isolate->initial_object_prototype()->GetElement(isolate, index); 5968 return isolate->initial_object_prototype()->GetElement(isolate, index);
5985 } 5969 }
5986 } 5970 }
5987 5971
5988 // Handle special arguments properties. 5972 // Handle special arguments properties.
5989 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n); 5973 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n);
5990 if (key->Equals(isolate->heap()->callee_string())) { 5974 if (key->Equals(isolate->heap()->callee_string())) {
5991 JSFunction* function = frame->function(); 5975 JSFunction* function = frame->function();
5992 if (!function->shared()->is_sloppy_mode()) { 5976 if (function->shared()->strict_mode() == STRICT) {
5993 return isolate->Throw(*isolate->factory()->NewTypeError( 5977 return isolate->Throw(*isolate->factory()->NewTypeError(
5994 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); 5978 "strict_arguments_callee", HandleVector<Object>(NULL, 0)));
5995 } 5979 }
5996 return function; 5980 return function;
5997 } 5981 }
5998 5982
5999 // Lookup in the initial Object.prototype object. 5983 // Lookup in the initial Object.prototype object.
6000 return isolate->initial_object_prototype()->GetProperty(*key); 5984 return isolate->initial_object_prototype()->GetProperty(*key);
6001 } 5985 }
6002 5986
(...skipping 3100 matching lines...) Expand 10 before | Expand all | Expand 10 after
9103 Handle<JSModule> module(context->module()); 9087 Handle<JSModule> module(context->module());
9104 9088
9105 for (int j = 0; j < description->length(); ++j) { 9089 for (int j = 0; j < description->length(); ++j) {
9106 Handle<String> name(description->name(j)); 9090 Handle<String> name(description->name(j));
9107 VariableMode mode = description->mode(j); 9091 VariableMode mode = description->mode(j);
9108 int index = description->index(j); 9092 int index = description->index(j);
9109 switch (mode) { 9093 switch (mode) {
9110 case VAR: 9094 case VAR:
9111 case LET: 9095 case LET:
9112 case CONST: 9096 case CONST:
9113 case CONST_HARMONY: { 9097 case CONST_LEGACY: {
9114 PropertyAttributes attr = 9098 PropertyAttributes attr =
9115 IsImmutableVariableMode(mode) ? FROZEN : SEALED; 9099 IsImmutableVariableMode(mode) ? FROZEN : SEALED;
9116 Handle<AccessorInfo> info = 9100 Handle<AccessorInfo> info =
9117 Accessors::MakeModuleExport(name, index, attr); 9101 Accessors::MakeModuleExport(name, index, attr);
9118 Handle<Object> result = JSObject::SetAccessor(module, info); 9102 Handle<Object> result = JSObject::SetAccessor(module, info);
9119 ASSERT(!(result.is_null() || result->IsUndefined())); 9103 ASSERT(!(result.is_null() || result->IsUndefined()));
9120 USE(result); 9104 USE(result);
9121 break; 9105 break;
9122 } 9106 }
9123 case MODULE: { 9107 case MODULE: {
9124 Object* referenced_context = Context::cast(host_context)->get(index); 9108 Object* referenced_context = Context::cast(host_context)->get(index);
9125 Handle<JSModule> value(Context::cast(referenced_context)->module()); 9109 Handle<JSModule> value(Context::cast(referenced_context)->module());
9126 JSReceiver::SetProperty(module, name, value, FROZEN, kStrictMode); 9110 JSReceiver::SetProperty(module, name, value, FROZEN, STRICT);
9127 break; 9111 break;
9128 } 9112 }
9129 case INTERNAL: 9113 case INTERNAL:
9130 case TEMPORARY: 9114 case TEMPORARY:
9131 case DYNAMIC: 9115 case DYNAMIC:
9132 case DYNAMIC_GLOBAL: 9116 case DYNAMIC_GLOBAL:
9133 case DYNAMIC_LOCAL: 9117 case DYNAMIC_LOCAL:
9134 UNREACHABLE(); 9118 UNREACHABLE();
9135 } 9119 }
9136 } 9120 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
9339 } 9323 }
9340 9324
9341 9325
9342 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { 9326 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
9343 HandleScope scope(isolate); 9327 HandleScope scope(isolate);
9344 ASSERT(args.length() == 4); 9328 ASSERT(args.length() == 4);
9345 9329
9346 Handle<Object> value(args[0], isolate); 9330 Handle<Object> value(args[0], isolate);
9347 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); 9331 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1);
9348 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); 9332 CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
9349 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); 9333 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3);
9350 StrictModeFlag strict_mode = (language_mode == SLOPPY_MODE)
9351 ? kSloppyMode : kStrictMode;
9352 9334
9353 int index; 9335 int index;
9354 PropertyAttributes attributes; 9336 PropertyAttributes attributes;
9355 ContextLookupFlags flags = FOLLOW_CHAINS; 9337 ContextLookupFlags flags = FOLLOW_CHAINS;
9356 BindingFlags binding_flags; 9338 BindingFlags binding_flags;
9357 Handle<Object> holder = context->Lookup(name, 9339 Handle<Object> holder = context->Lookup(name,
9358 flags, 9340 flags,
9359 &index, 9341 &index,
9360 &attributes, 9342 &attributes,
9361 &binding_flags); 9343 &binding_flags);
9362 if (isolate->has_pending_exception()) return Failure::Exception(); 9344 if (isolate->has_pending_exception()) return Failure::Exception();
9363 9345
9364 if (index >= 0) { 9346 if (index >= 0) {
9365 // The property was found in a context slot. 9347 // The property was found in a context slot.
9366 Handle<Context> context = Handle<Context>::cast(holder); 9348 Handle<Context> context = Handle<Context>::cast(holder);
9367 if (binding_flags == MUTABLE_CHECK_INITIALIZED && 9349 if (binding_flags == MUTABLE_CHECK_INITIALIZED &&
9368 context->get(index)->IsTheHole()) { 9350 context->get(index)->IsTheHole()) {
9369 Handle<Object> error = 9351 Handle<Object> error =
9370 isolate->factory()->NewReferenceError("not_defined", 9352 isolate->factory()->NewReferenceError("not_defined",
9371 HandleVector(&name, 1)); 9353 HandleVector(&name, 1));
9372 return isolate->Throw(*error); 9354 return isolate->Throw(*error);
9373 } 9355 }
9374 // Ignore if read_only variable. 9356 // Ignore if read_only variable.
9375 if ((attributes & READ_ONLY) == 0) { 9357 if ((attributes & READ_ONLY) == 0) {
9376 // Context is a fixed array and set cannot fail. 9358 // Context is a fixed array and set cannot fail.
9377 context->set(index, *value); 9359 context->set(index, *value);
9378 } else if (strict_mode == kStrictMode) { 9360 } else if (strict_mode == STRICT) {
9379 // Setting read only property in strict mode. 9361 // Setting read only property in strict mode.
9380 Handle<Object> error = 9362 Handle<Object> error =
9381 isolate->factory()->NewTypeError("strict_cannot_assign", 9363 isolate->factory()->NewTypeError("strict_cannot_assign",
9382 HandleVector(&name, 1)); 9364 HandleVector(&name, 1));
9383 return isolate->Throw(*error); 9365 return isolate->Throw(*error);
9384 } 9366 }
9385 return *value; 9367 return *value;
9386 } 9368 }
9387 9369
9388 // Slow case: The property is not in a context slot. It is either in a 9370 // Slow case: The property is not in a context slot. It is either in a
9389 // context extension object, a property of the subject of a with, or a 9371 // context extension object, a property of the subject of a with, or a
9390 // property of the global object. 9372 // property of the global object.
9391 Handle<JSReceiver> object; 9373 Handle<JSReceiver> object;
9392 9374
9393 if (!holder.is_null()) { 9375 if (!holder.is_null()) {
9394 // The property exists on the holder. 9376 // The property exists on the holder.
9395 object = Handle<JSReceiver>::cast(holder); 9377 object = Handle<JSReceiver>::cast(holder);
9396 } else { 9378 } else {
9397 // The property was not found. 9379 // The property was not found.
9398 ASSERT(attributes == ABSENT); 9380 ASSERT(attributes == ABSENT);
9399 9381
9400 if (strict_mode == kStrictMode) { 9382 if (strict_mode == STRICT) {
9401 // Throw in strict mode (assignment to undefined variable). 9383 // Throw in strict mode (assignment to undefined variable).
9402 Handle<Object> error = 9384 Handle<Object> error =
9403 isolate->factory()->NewReferenceError( 9385 isolate->factory()->NewReferenceError(
9404 "not_defined", HandleVector(&name, 1)); 9386 "not_defined", HandleVector(&name, 1));
9405 return isolate->Throw(*error); 9387 return isolate->Throw(*error);
9406 } 9388 }
9407 // In sloppy mode, the property is added to the global object. 9389 // In sloppy mode, the property is added to the global object.
9408 attributes = NONE; 9390 attributes = NONE;
9409 object = Handle<JSReceiver>(isolate->context()->global_object()); 9391 object = Handle<JSReceiver>(isolate->context()->global_object());
9410 } 9392 }
9411 9393
9412 // Set the property if it's not read only or doesn't yet exist. 9394 // Set the property if it's not read only or doesn't yet exist.
9413 if ((attributes & READ_ONLY) == 0 || 9395 if ((attributes & READ_ONLY) == 0 ||
9414 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { 9396 (object->GetLocalPropertyAttribute(*name) == ABSENT)) {
9415 RETURN_IF_EMPTY_HANDLE( 9397 RETURN_IF_EMPTY_HANDLE(
9416 isolate, 9398 isolate,
9417 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); 9399 JSReceiver::SetProperty(object, name, value, NONE, strict_mode));
9418 } else if (strict_mode == kStrictMode && (attributes & READ_ONLY) != 0) { 9400 } else if (strict_mode == STRICT && (attributes & READ_ONLY) != 0) {
9419 // Setting read only property in strict mode. 9401 // Setting read only property in strict mode.
9420 Handle<Object> error = 9402 Handle<Object> error =
9421 isolate->factory()->NewTypeError( 9403 isolate->factory()->NewTypeError(
9422 "strict_cannot_assign", HandleVector(&name, 1)); 9404 "strict_cannot_assign", HandleVector(&name, 1));
9423 return isolate->Throw(*error); 9405 return isolate->Throw(*error);
9424 } 9406 }
9425 return *value; 9407 return *value;
9426 } 9408 }
9427 9409
9428 9410
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
9747 Handle<Object> error_message = 9729 Handle<Object> error_message =
9748 context->ErrorMessageForCodeGenerationFromStrings(); 9730 context->ErrorMessageForCodeGenerationFromStrings();
9749 return isolate->Throw(*isolate->factory()->NewEvalError( 9731 return isolate->Throw(*isolate->factory()->NewEvalError(
9750 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9732 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9751 } 9733 }
9752 9734
9753 // Compile source string in the native context. 9735 // Compile source string in the native context.
9754 ParseRestriction restriction = function_literal_only 9736 ParseRestriction restriction = function_literal_only
9755 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; 9737 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION;
9756 Handle<JSFunction> fun = Compiler::GetFunctionFromEval( 9738 Handle<JSFunction> fun = Compiler::GetFunctionFromEval(
9757 source, context, SLOPPY_MODE, restriction, RelocInfo::kNoPosition); 9739 source, context, SLOPPY, restriction, RelocInfo::kNoPosition);
9758 RETURN_IF_EMPTY_HANDLE(isolate, fun); 9740 RETURN_IF_EMPTY_HANDLE(isolate, fun);
9759 return *fun; 9741 return *fun;
9760 } 9742 }
9761 9743
9762 9744
9763 static ObjectPair CompileGlobalEval(Isolate* isolate, 9745 static ObjectPair CompileGlobalEval(Isolate* isolate,
9764 Handle<String> source, 9746 Handle<String> source,
9765 Handle<Object> receiver, 9747 Handle<Object> receiver,
9766 LanguageMode language_mode, 9748 StrictMode strict_mode,
9767 int scope_position) { 9749 int scope_position) {
9768 Handle<Context> context = Handle<Context>(isolate->context()); 9750 Handle<Context> context = Handle<Context>(isolate->context());
9769 Handle<Context> native_context = Handle<Context>(context->native_context()); 9751 Handle<Context> native_context = Handle<Context>(context->native_context());
9770 9752
9771 // Check if native context allows code generation from 9753 // Check if native context allows code generation from
9772 // strings. Throw an exception if it doesn't. 9754 // strings. Throw an exception if it doesn't.
9773 if (native_context->allow_code_gen_from_strings()->IsFalse() && 9755 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
9774 !CodeGenerationFromStringsAllowed(isolate, native_context)) { 9756 !CodeGenerationFromStringsAllowed(isolate, native_context)) {
9775 Handle<Object> error_message = 9757 Handle<Object> error_message =
9776 native_context->ErrorMessageForCodeGenerationFromStrings(); 9758 native_context->ErrorMessageForCodeGenerationFromStrings();
9777 isolate->Throw(*isolate->factory()->NewEvalError( 9759 isolate->Throw(*isolate->factory()->NewEvalError(
9778 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9760 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9779 return MakePair(Failure::Exception(), NULL); 9761 return MakePair(Failure::Exception(), NULL);
9780 } 9762 }
9781 9763
9782 // Deal with a normal eval call with a string argument. Compile it 9764 // Deal with a normal eval call with a string argument. Compile it
9783 // and return the compiled function bound in the local context. 9765 // and return the compiled function bound in the local context.
9784 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; 9766 static const ParseRestriction restriction = NO_PARSE_RESTRICTION;
9785 Handle<JSFunction> compiled = Compiler::GetFunctionFromEval( 9767 Handle<JSFunction> compiled = Compiler::GetFunctionFromEval(
9786 source, context, language_mode, restriction, scope_position); 9768 source, context, strict_mode, restriction, scope_position);
9787 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, compiled, 9769 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, compiled,
9788 MakePair(Failure::Exception(), NULL)); 9770 MakePair(Failure::Exception(), NULL));
9789 return MakePair(*compiled, *receiver); 9771 return MakePair(*compiled, *receiver);
9790 } 9772 }
9791 9773
9792 9774
9793 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { 9775 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
9794 HandleScope scope(isolate); 9776 HandleScope scope(isolate);
9795 ASSERT(args.length() == 5); 9777 ASSERT(args.length() == 5);
9796 9778
9797 Handle<Object> callee = args.at<Object>(0); 9779 Handle<Object> callee = args.at<Object>(0);
9798 9780
9799 // If "eval" didn't refer to the original GlobalEval, it's not a 9781 // If "eval" didn't refer to the original GlobalEval, it's not a
9800 // direct call to eval. 9782 // direct call to eval.
9801 // (And even if it is, but the first argument isn't a string, just let 9783 // (And even if it is, but the first argument isn't a string, just let
9802 // execution default to an indirect call to eval, which will also return 9784 // execution default to an indirect call to eval, which will also return
9803 // the first argument without doing anything). 9785 // the first argument without doing anything).
9804 if (*callee != isolate->native_context()->global_eval_fun() || 9786 if (*callee != isolate->native_context()->global_eval_fun() ||
9805 !args[1]->IsString()) { 9787 !args[1]->IsString()) {
9806 return MakePair(*callee, isolate->heap()->undefined_value()); 9788 return MakePair(*callee, isolate->heap()->undefined_value());
9807 } 9789 }
9808 9790
9809 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); 9791 ASSERT(args[3]->IsSmi());
9792 ASSERT(args.smi_at(3) == SLOPPY || args.smi_at(3) == STRICT);
9793 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3));
9810 ASSERT(args[4]->IsSmi()); 9794 ASSERT(args[4]->IsSmi());
9811 return CompileGlobalEval(isolate, 9795 return CompileGlobalEval(isolate,
9812 args.at<String>(1), 9796 args.at<String>(1),
9813 args.at<Object>(2), 9797 args.at<Object>(2),
9814 language_mode, 9798 strict_mode,
9815 args.smi_at(4)); 9799 args.smi_at(4));
9816 } 9800 }
9817 9801
9818 9802
9819 // Allocate a block of memory in the given space (filled with a filler). 9803 // Allocate a block of memory in the given space (filled with a filler).
9820 // Used as a fall-back for generated code when the space is full. 9804 // Used as a fall-back for generated code when the space is full.
9821 static MaybeObject* Allocate(Isolate* isolate, 9805 static MaybeObject* Allocate(Isolate* isolate,
9822 int size, 9806 int size,
9823 bool double_align, 9807 bool double_align,
9824 AllocationSpace space) { 9808 AllocationSpace space) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
9869 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); 9853 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements());
9870 int length = Smi::cast(array->length())->value(); 9854 int length = Smi::cast(array->length())->value();
9871 FixedArray* elements = FixedArray::cast(array->elements()); 9855 FixedArray* elements = FixedArray::cast(array->elements());
9872 for (int i = 0; i < length; i++) { 9856 for (int i = 0; i < length; i++) {
9873 if (elements->get(i) == *element) return isolate->heap()->false_value(); 9857 if (elements->get(i) == *element) return isolate->heap()->false_value();
9874 } 9858 }
9875 9859
9876 // Strict not needed. Used for cycle detection in Array join implementation. 9860 // Strict not needed. Used for cycle detection in Array join implementation.
9877 RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length, 9861 RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length,
9878 element, 9862 element,
9879 kSloppyMode, 9863 SLOPPY,
9880 true)); 9864 true));
9881 return isolate->heap()->true_value(); 9865 return isolate->heap()->true_value();
9882 } 9866 }
9883 9867
9884 9868
9885 /** 9869 /**
9886 * A simple visitor visits every element of Array's. 9870 * A simple visitor visits every element of Array's.
9887 * The backend storage can be a fixed array for fast elements case, 9871 * The backend storage can be a fixed array for fast elements case,
9888 * or a dictionary for sparse array. Since Dictionary is a subtype 9872 * or a dictionary for sparse array. Since Dictionary is a subtype
9889 * of FixedArray, the class can be used by both fast and slow cases. 9873 * of FixedArray, the class can be used by both fast and slow cases.
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
11341 // Add the value being returned. 11325 // Add the value being returned.
11342 if (at_return) { 11326 if (at_return) {
11343 details->set(details_index++, *return_value); 11327 details->set(details_index++, *return_value);
11344 } 11328 }
11345 11329
11346 // Add the receiver (same as in function frame). 11330 // Add the receiver (same as in function frame).
11347 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE 11331 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE
11348 // THE FRAME ITERATOR TO WRAP THE RECEIVER. 11332 // THE FRAME ITERATOR TO WRAP THE RECEIVER.
11349 Handle<Object> receiver(it.frame()->receiver(), isolate); 11333 Handle<Object> receiver(it.frame()->receiver(), isolate);
11350 if (!receiver->IsJSObject() && 11334 if (!receiver->IsJSObject() &&
11351 shared->is_sloppy_mode() && 11335 shared->strict_mode() == SLOPPY &&
11352 !function->IsBuiltin()) { 11336 !function->IsBuiltin()) {
11353 // If the receiver is not a JSObject and the function is not a 11337 // If the receiver is not a JSObject and the function is not a
11354 // builtin or strict-mode we have hit an optimization where a 11338 // builtin or strict-mode we have hit an optimization where a
11355 // value object is not converted into a wrapped JS objects. To 11339 // value object is not converted into a wrapped JS objects. To
11356 // hide this optimization from the debugger, we wrap the receiver 11340 // hide this optimization from the debugger, we wrap the receiver
11357 // by creating correct wrapper object based on the calling frame's 11341 // by creating correct wrapper object based on the calling frame's
11358 // native context. 11342 // native context.
11359 it.Advance(); 11343 it.Advance();
11360 if (receiver->IsUndefined()) { 11344 if (receiver->IsUndefined()) {
11361 Context* context = function->context(); 11345 Context* context = function->context();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
11393 if (scope_info->ContextSlotIndex(*name, &mode, &init_flag) != -1) continue; 11377 if (scope_info->ContextSlotIndex(*name, &mode, &init_flag) != -1) continue;
11394 11378
11395 Handle<Object> value(i < frame_inspector->GetParametersCount() 11379 Handle<Object> value(i < frame_inspector->GetParametersCount()
11396 ? frame_inspector->GetParameter(i) 11380 ? frame_inspector->GetParameter(i)
11397 : isolate->heap()->undefined_value(), 11381 : isolate->heap()->undefined_value(),
11398 isolate); 11382 isolate);
11399 ASSERT(!value->IsTheHole()); 11383 ASSERT(!value->IsTheHole());
11400 11384
11401 RETURN_IF_EMPTY_HANDLE_VALUE( 11385 RETURN_IF_EMPTY_HANDLE_VALUE(
11402 isolate, 11386 isolate,
11403 Runtime::SetObjectProperty( 11387 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY),
11404 isolate, target, name, value, NONE, kSloppyMode),
11405 Handle<JSObject>()); 11388 Handle<JSObject>());
11406 } 11389 }
11407 11390
11408 // Second fill all stack locals. 11391 // Second fill all stack locals.
11409 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 11392 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
11410 Handle<String> name(scope_info->StackLocalName(i)); 11393 Handle<String> name(scope_info->StackLocalName(i));
11411 Handle<Object> value(frame_inspector->GetExpression(i), isolate); 11394 Handle<Object> value(frame_inspector->GetExpression(i), isolate);
11412 if (value->IsTheHole()) continue; 11395 if (value->IsTheHole()) continue;
11413 11396
11414 RETURN_IF_EMPTY_HANDLE_VALUE( 11397 RETURN_IF_EMPTY_HANDLE_VALUE(
11415 isolate, 11398 isolate,
11416 Runtime::SetObjectProperty( 11399 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY),
11417 isolate, target, name, value, NONE, kSloppyMode),
11418 Handle<JSObject>()); 11400 Handle<JSObject>());
11419 } 11401 }
11420 11402
11421 return target; 11403 return target;
11422 } 11404 }
11423 11405
11424 11406
11425 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate, 11407 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
11426 Handle<JSObject> target, 11408 Handle<JSObject> target,
11427 Handle<JSFunction> function, 11409 Handle<JSFunction> function,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
11490 // Names of variables introduced by eval are strings. 11472 // Names of variables introduced by eval are strings.
11491 ASSERT(keys->get(i)->IsString()); 11473 ASSERT(keys->get(i)->IsString());
11492 Handle<String> key(String::cast(keys->get(i))); 11474 Handle<String> key(String::cast(keys->get(i)));
11493 RETURN_IF_EMPTY_HANDLE_VALUE( 11475 RETURN_IF_EMPTY_HANDLE_VALUE(
11494 isolate, 11476 isolate,
11495 Runtime::SetObjectProperty(isolate, 11477 Runtime::SetObjectProperty(isolate,
11496 target, 11478 target,
11497 key, 11479 key,
11498 GetProperty(isolate, ext, key), 11480 GetProperty(isolate, ext, key),
11499 NONE, 11481 NONE,
11500 kSloppyMode), 11482 SLOPPY),
11501 Handle<JSObject>()); 11483 Handle<JSObject>());
11502 } 11484 }
11503 } 11485 }
11504 } 11486 }
11505 11487
11506 return target; 11488 return target;
11507 } 11489 }
11508 11490
11509 11491
11510 static Handle<JSObject> MaterializeLocalScope( 11492 static Handle<JSObject> MaterializeLocalScope(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
11591 // Function context extension. These are variables introduced by eval. 11573 // Function context extension. These are variables introduced by eval.
11592 if (function_context->closure() == *function) { 11574 if (function_context->closure() == *function) {
11593 if (function_context->has_extension() && 11575 if (function_context->has_extension() &&
11594 !function_context->IsNativeContext()) { 11576 !function_context->IsNativeContext()) {
11595 Handle<JSObject> ext(JSObject::cast(function_context->extension())); 11577 Handle<JSObject> ext(JSObject::cast(function_context->extension()));
11596 11578
11597 if (JSReceiver::HasProperty(ext, variable_name)) { 11579 if (JSReceiver::HasProperty(ext, variable_name)) {
11598 // We don't expect this to do anything except replacing 11580 // We don't expect this to do anything except replacing
11599 // property value. 11581 // property value.
11600 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, 11582 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
11601 NONE, 11583 NONE, SLOPPY);
11602 kSloppyMode);
11603 return true; 11584 return true;
11604 } 11585 }
11605 } 11586 }
11606 } 11587 }
11607 } 11588 }
11608 11589
11609 return default_result; 11590 return default_result;
11610 } 11591 }
11611 11592
11612 11593
(...skipping 27 matching lines...) Expand all
11640 if (threw) return Handle<JSObject>(); 11621 if (threw) return Handle<JSObject>();
11641 11622
11642 for (int i = 0; i < keys->length(); i++) { 11623 for (int i = 0; i < keys->length(); i++) {
11643 // Names of variables introduced by eval are strings. 11624 // Names of variables introduced by eval are strings.
11644 ASSERT(keys->get(i)->IsString()); 11625 ASSERT(keys->get(i)->IsString());
11645 Handle<String> key(String::cast(keys->get(i))); 11626 Handle<String> key(String::cast(keys->get(i)));
11646 RETURN_IF_EMPTY_HANDLE_VALUE( 11627 RETURN_IF_EMPTY_HANDLE_VALUE(
11647 isolate, 11628 isolate,
11648 Runtime::SetObjectProperty(isolate, closure_scope, key, 11629 Runtime::SetObjectProperty(isolate, closure_scope, key,
11649 GetProperty(isolate, ext, key), 11630 GetProperty(isolate, ext, key),
11650 NONE, 11631 NONE, SLOPPY),
11651 kSloppyMode),
11652 Handle<JSObject>()); 11632 Handle<JSObject>());
11653 } 11633 }
11654 } 11634 }
11655 11635
11656 return closure_scope; 11636 return closure_scope;
11657 } 11637 }
11658 11638
11659 11639
11660 // This method copies structure of MaterializeClosure method above. 11640 // This method copies structure of MaterializeClosure method above.
11661 static bool SetClosureVariableValue(Isolate* isolate, 11641 static bool SetClosureVariableValue(Isolate* isolate,
(...skipping 11 matching lines...) Expand all
11673 return true; 11653 return true;
11674 } 11654 }
11675 11655
11676 // Properties from the function context extension. This will 11656 // Properties from the function context extension. This will
11677 // be variables introduced by eval. 11657 // be variables introduced by eval.
11678 if (context->has_extension()) { 11658 if (context->has_extension()) {
11679 Handle<JSObject> ext(JSObject::cast(context->extension())); 11659 Handle<JSObject> ext(JSObject::cast(context->extension()));
11680 if (JSReceiver::HasProperty(ext, variable_name)) { 11660 if (JSReceiver::HasProperty(ext, variable_name)) {
11681 // We don't expect this to do anything except replacing property value. 11661 // We don't expect this to do anything except replacing property value.
11682 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, 11662 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
11683 NONE, 11663 NONE, SLOPPY);
11684 kSloppyMode);
11685 return true; 11664 return true;
11686 } 11665 }
11687 } 11666 }
11688 11667
11689 return false; 11668 return false;
11690 } 11669 }
11691 11670
11692 11671
11693 // Create a plain JSObject which materializes the scope for the specified 11672 // Create a plain JSObject which materializes the scope for the specified
11694 // catch context. 11673 // catch context.
11695 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, 11674 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate,
11696 Handle<Context> context) { 11675 Handle<Context> context) {
11697 ASSERT(context->IsCatchContext()); 11676 ASSERT(context->IsCatchContext());
11698 Handle<String> name(String::cast(context->extension())); 11677 Handle<String> name(String::cast(context->extension()));
11699 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), 11678 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX),
11700 isolate); 11679 isolate);
11701 Handle<JSObject> catch_scope = 11680 Handle<JSObject> catch_scope =
11702 isolate->factory()->NewJSObject(isolate->object_function()); 11681 isolate->factory()->NewJSObject(isolate->object_function());
11703 RETURN_IF_EMPTY_HANDLE_VALUE( 11682 RETURN_IF_EMPTY_HANDLE_VALUE(
11704 isolate, 11683 isolate,
11705 Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object, 11684 Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object,
11706 NONE, 11685 NONE, SLOPPY),
11707 kSloppyMode),
11708 Handle<JSObject>()); 11686 Handle<JSObject>());
11709 return catch_scope; 11687 return catch_scope;
11710 } 11688 }
11711 11689
11712 11690
11713 static bool SetCatchVariableValue(Isolate* isolate, 11691 static bool SetCatchVariableValue(Isolate* isolate,
11714 Handle<Context> context, 11692 Handle<Context> context,
11715 Handle<String> variable_name, 11693 Handle<String> variable_name,
11716 Handle<Object> new_value) { 11694 Handle<Object> new_value) {
11717 ASSERT(context->IsCatchContext()); 11695 ASSERT(context->IsCatchContext());
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
12210 // If our frame is a top frame and we are stepping, we can do step-in 12188 // If our frame is a top frame and we are stepping, we can do step-in
12211 // at this place. 12189 // at this place.
12212 accept = additional_frame_it.frame()->id() == id; 12190 accept = additional_frame_it.frame()->id() == id;
12213 } 12191 }
12214 } 12192 }
12215 if (accept) { 12193 if (accept) {
12216 if (break_location_iterator.IsStepInLocation(isolate)) { 12194 if (break_location_iterator.IsStepInLocation(isolate)) {
12217 Smi* position_value = Smi::FromInt(break_location_iterator.position()); 12195 Smi* position_value = Smi::FromInt(break_location_iterator.position());
12218 JSObject::SetElement(array, len, 12196 JSObject::SetElement(array, len,
12219 Handle<Object>(position_value, isolate), 12197 Handle<Object>(position_value, isolate),
12220 NONE, kSloppyMode); 12198 NONE, SLOPPY);
12221 len++; 12199 len++;
12222 } 12200 }
12223 } 12201 }
12224 // Advance iterator. 12202 // Advance iterator.
12225 break_location_iterator.Next(); 12203 break_location_iterator.Next();
12226 if (current_statement_pos != 12204 if (current_statement_pos !=
12227 break_location_iterator.statement_position()) { 12205 break_location_iterator.statement_position()) {
12228 break; 12206 break;
12229 } 12207 }
12230 } 12208 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
12719 return target; 12697 return target;
12720 } 12698 }
12721 12699
12722 // FunctionGetArguments can't throw an exception. 12700 // FunctionGetArguments can't throw an exception.
12723 Handle<JSObject> arguments = Handle<JSObject>::cast( 12701 Handle<JSObject> arguments = Handle<JSObject>::cast(
12724 Accessors::FunctionGetArguments(function)); 12702 Accessors::FunctionGetArguments(function));
12725 Runtime::SetObjectProperty(isolate, target, 12703 Runtime::SetObjectProperty(isolate, target,
12726 isolate->factory()->arguments_string(), 12704 isolate->factory()->arguments_string(),
12727 arguments, 12705 arguments,
12728 ::NONE, 12706 ::NONE,
12729 kSloppyMode); 12707 SLOPPY);
12730 return target; 12708 return target;
12731 } 12709 }
12732 12710
12733 12711
12734 // Compile and evaluate source for the given context. 12712 // Compile and evaluate source for the given context.
12735 static MaybeObject* DebugEvaluate(Isolate* isolate, 12713 static MaybeObject* DebugEvaluate(Isolate* isolate,
12736 Handle<Context> context, 12714 Handle<Context> context,
12737 Handle<Object> context_extension, 12715 Handle<Object> context_extension,
12738 Handle<Object> receiver, 12716 Handle<Object> receiver,
12739 Handle<String> source) { 12717 Handle<String> source) {
12740 if (context_extension->IsJSObject()) { 12718 if (context_extension->IsJSObject()) {
12741 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); 12719 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension);
12742 Handle<JSFunction> closure(context->closure(), isolate); 12720 Handle<JSFunction> closure(context->closure(), isolate);
12743 context = isolate->factory()->NewWithContext(closure, context, extension); 12721 context = isolate->factory()->NewWithContext(closure, context, extension);
12744 } 12722 }
12745 12723
12746 Handle<JSFunction> eval_fun = 12724 Handle<JSFunction> eval_fun =
12747 Compiler::GetFunctionFromEval(source, 12725 Compiler::GetFunctionFromEval(source,
12748 context, 12726 context,
12749 SLOPPY_MODE, 12727 SLOPPY,
12750 NO_PARSE_RESTRICTION, 12728 NO_PARSE_RESTRICTION,
12751 RelocInfo::kNoPosition); 12729 RelocInfo::kNoPosition);
12752 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun); 12730 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun);
12753 12731
12754 bool pending_exception; 12732 bool pending_exception;
12755 Handle<Object> result = Execution::Call( 12733 Handle<Object> result = Execution::Call(
12756 isolate, eval_fun, receiver, 0, NULL, &pending_exception); 12734 isolate, eval_fun, receiver, 0, NULL, &pending_exception);
12757 12735
12758 if (pending_exception) return Failure::Exception(); 12736 if (pending_exception) return Failure::Exception();
12759 12737
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
12997 CONVERT_ARG_CHECKED(JSObject, target, 0); 12975 CONVERT_ARG_CHECKED(JSObject, target, 0);
12998 Object* instance_filter = args[1]; 12976 Object* instance_filter = args[1];
12999 RUNTIME_ASSERT(instance_filter->IsUndefined() || 12977 RUNTIME_ASSERT(instance_filter->IsUndefined() ||
13000 instance_filter->IsJSObject()); 12978 instance_filter->IsJSObject());
13001 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); 12979 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]);
13002 RUNTIME_ASSERT(max_references >= 0); 12980 RUNTIME_ASSERT(max_references >= 0);
13003 12981
13004 12982
13005 // Get the constructor function for context extension and arguments array. 12983 // Get the constructor function for context extension and arguments array.
13006 JSObject* arguments_boilerplate = 12984 JSObject* arguments_boilerplate =
13007 isolate->context()->native_context()->arguments_boilerplate(); 12985 isolate->context()->native_context()->sloppy_arguments_boilerplate();
13008 JSFunction* arguments_function = 12986 JSFunction* arguments_function =
13009 JSFunction::cast(arguments_boilerplate->map()->constructor()); 12987 JSFunction::cast(arguments_boilerplate->map()->constructor());
13010 12988
13011 // Get the number of referencing objects. 12989 // Get the number of referencing objects.
13012 int count; 12990 int count;
13013 Heap* heap = isolate->heap(); 12991 Heap* heap = isolate->heap();
13014 HeapIterator heap_iterator(heap); 12992 HeapIterator heap_iterator(heap);
13015 count = DebugReferencedBy(&heap_iterator, 12993 count = DebugReferencedBy(&heap_iterator,
13016 target, instance_filter, max_references, 12994 target, instance_filter, max_references,
13017 NULL, 0, arguments_function); 12995 NULL, 0, arguments_function);
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
14960 // Handle last resort GC and make sure to allow future allocations 14938 // Handle last resort GC and make sure to allow future allocations
14961 // to grow the heap without causing GCs (if possible). 14939 // to grow the heap without causing GCs (if possible).
14962 isolate->counters()->gc_last_resort_from_js()->Increment(); 14940 isolate->counters()->gc_last_resort_from_js()->Increment();
14963 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14941 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14964 "Runtime::PerformGC"); 14942 "Runtime::PerformGC");
14965 } 14943 }
14966 } 14944 }
14967 14945
14968 14946
14969 } } // namespace v8::internal 14947 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698