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: test/cctest/test-api.cc

Issue 328343003: Remove dependency on Vector from platform files (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 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/x87/disasm-x87.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 CHECK(env->GetIsolate()->InContext()); 179 CHECK(env->GetIsolate()->InContext());
180 CHECK(env->GetIsolate() == CcTest::isolate()); 180 CHECK(env->GetIsolate() == CcTest::isolate());
181 env->Exit(); 181 env->Exit();
182 CHECK(!env->GetIsolate()->InContext()); 182 CHECK(!env->GetIsolate()->InContext());
183 CHECK(env->GetIsolate() == CcTest::isolate()); 183 CHECK(env->GetIsolate() == CcTest::isolate());
184 } 184 }
185 185
186 186
187 static void TestSignature(const char* loop_js, Local<Value> receiver) { 187 static void TestSignature(const char* loop_js, Local<Value> receiver) {
188 i::ScopedVector<char> source(200); 188 i::ScopedVector<char> source(200);
189 i::OS::SNPrintF(source, 189 i::SNPrintF(source,
190 "for (var i = 0; i < 10; i++) {" 190 "for (var i = 0; i < 10; i++) {"
191 " %s" 191 " %s"
192 "}", 192 "}",
193 loop_js); 193 loop_js);
194 signature_callback_count = 0; 194 signature_callback_count = 0;
195 signature_expected_receiver = receiver; 195 signature_expected_receiver = receiver;
196 bool expected_to_throw = receiver.IsEmpty(); 196 bool expected_to_throw = receiver.IsEmpty();
197 v8::TryCatch try_catch; 197 v8::TryCatch try_catch;
198 CompileRun(source.start()); 198 CompileRun(source.start());
199 CHECK_EQ(expected_to_throw, try_catch.HasCaught()); 199 CHECK_EQ(expected_to_throw, try_catch.HasCaught());
200 if (!expected_to_throw) { 200 if (!expected_to_throw) {
201 CHECK_EQ(10, signature_callback_count); 201 CHECK_EQ(10, signature_callback_count);
202 } else { 202 } else {
203 CHECK_EQ(v8_str("TypeError: Illegal invocation"), 203 CHECK_EQ(v8_str("TypeError: Illegal invocation"),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 "var obj = {};" 256 "var obj = {};"
257 "copy_props(obj);" 257 "copy_props(obj);"
258 "var unrel = new UnrelFun();" 258 "var unrel = new UnrelFun();"
259 "copy_props(unrel);"); 259 "copy_props(unrel);");
260 // Test with and without ICs 260 // Test with and without ICs
261 const char* test_objects[] = { 261 const char* test_objects[] = {
262 "fun_instance", "sub_fun_instance", "obj", "unrel" }; 262 "fun_instance", "sub_fun_instance", "obj", "unrel" };
263 unsigned bad_signature_start_offset = 2; 263 unsigned bad_signature_start_offset = 2;
264 for (unsigned i = 0; i < ARRAY_SIZE(test_objects); i++) { 264 for (unsigned i = 0; i < ARRAY_SIZE(test_objects); i++) {
265 i::ScopedVector<char> source(200); 265 i::ScopedVector<char> source(200);
266 i::OS::SNPrintF( 266 i::SNPrintF(
267 source, "var test_object = %s; test_object", test_objects[i]); 267 source, "var test_object = %s; test_object", test_objects[i]);
268 Local<Value> test_object = CompileRun(source.start()); 268 Local<Value> test_object = CompileRun(source.start());
269 TestSignature("test_object.prop();", test_object); 269 TestSignature("test_object.prop();", test_object);
270 TestSignature("test_object.accessor;", test_object); 270 TestSignature("test_object.accessor;", test_object);
271 TestSignature("test_object[accessor_key];", test_object); 271 TestSignature("test_object[accessor_key];", test_object);
272 TestSignature("test_object.accessor = 1;", test_object); 272 TestSignature("test_object.accessor = 1;", test_object);
273 TestSignature("test_object[accessor_key] = 1;", test_object); 273 TestSignature("test_object[accessor_key] = 1;", test_object);
274 if (i >= bad_signature_start_offset) test_object = Local<Value>(); 274 if (i >= bad_signature_start_offset) test_object = Local<Value>();
275 TestSignature("test_object.prop_sig();", test_object); 275 TestSignature("test_object.prop_sig();", test_object);
276 TestSignature("test_object.accessor_sig;", test_object); 276 TestSignature("test_object.accessor_sig;", test_object);
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 3074
3075 static void CheckIsNeutered(v8::Handle<v8::TypedArray> ta) { 3075 static void CheckIsNeutered(v8::Handle<v8::TypedArray> ta) {
3076 CHECK_EQ(0, static_cast<int>(ta->ByteLength())); 3076 CHECK_EQ(0, static_cast<int>(ta->ByteLength()));
3077 CHECK_EQ(0, static_cast<int>(ta->Length())); 3077 CHECK_EQ(0, static_cast<int>(ta->Length()));
3078 CHECK_EQ(0, static_cast<int>(ta->ByteOffset())); 3078 CHECK_EQ(0, static_cast<int>(ta->ByteOffset()));
3079 } 3079 }
3080 3080
3081 3081
3082 static void CheckIsTypedArrayVarNeutered(const char* name) { 3082 static void CheckIsTypedArrayVarNeutered(const char* name) {
3083 i::ScopedVector<char> source(1024); 3083 i::ScopedVector<char> source(1024);
3084 i::OS::SNPrintF(source, 3084 i::SNPrintF(source,
3085 "%s.byteLength == 0 && %s.byteOffset == 0 && %s.length == 0", 3085 "%s.byteLength == 0 && %s.byteOffset == 0 && %s.length == 0",
3086 name, name, name); 3086 name, name, name);
3087 CHECK(CompileRun(source.start())->IsTrue()); 3087 CHECK(CompileRun(source.start())->IsTrue());
3088 v8::Handle<v8::TypedArray> ta = 3088 v8::Handle<v8::TypedArray> ta =
3089 v8::Handle<v8::TypedArray>::Cast(CompileRun(name)); 3089 v8::Handle<v8::TypedArray>::Cast(CompileRun(name));
3090 CheckIsNeutered(ta); 3090 CheckIsNeutered(ta);
3091 } 3091 }
3092 3092
3093 3093
3094 template <typename TypedArray, int kElementSize> 3094 template <typename TypedArray, int kElementSize>
(...skipping 3628 matching lines...) Expand 10 before | Expand all | Expand 10 after
6723 Context::New(CcTest::isolate(), &extensions); 6723 Context::New(CcTest::isolate(), &extensions);
6724 CHECK_EQ(0, *context); 6724 CHECK_EQ(0, *context);
6725 } 6725 }
6726 6726
6727 6727
6728 TEST(ExtensionWithSourceLength) { 6728 TEST(ExtensionWithSourceLength) {
6729 for (int source_len = kEmbeddedExtensionSourceValidLen - 1; 6729 for (int source_len = kEmbeddedExtensionSourceValidLen - 1;
6730 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { 6730 source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) {
6731 v8::HandleScope handle_scope(CcTest::isolate()); 6731 v8::HandleScope handle_scope(CcTest::isolate());
6732 i::ScopedVector<char> extension_name(32); 6732 i::ScopedVector<char> extension_name(32);
6733 i::OS::SNPrintF(extension_name, "ext #%d", source_len); 6733 i::SNPrintF(extension_name, "ext #%d", source_len);
6734 v8::RegisterExtension(new Extension(extension_name.start(), 6734 v8::RegisterExtension(new Extension(extension_name.start(),
6735 kEmbeddedExtensionSource, 0, 0, 6735 kEmbeddedExtensionSource, 0, 0,
6736 source_len)); 6736 source_len));
6737 const char* extension_names[1] = { extension_name.start() }; 6737 const char* extension_names[1] = { extension_name.start() };
6738 v8::ExtensionConfiguration extensions(1, extension_names); 6738 v8::ExtensionConfiguration extensions(1, extension_names);
6739 v8::Handle<Context> context = 6739 v8::Handle<Context> context =
6740 Context::New(CcTest::isolate(), &extensions); 6740 Context::New(CcTest::isolate(), &extensions);
6741 if (source_len == kEmbeddedExtensionSourceValidLen) { 6741 if (source_len == kEmbeddedExtensionSourceValidLen) {
6742 Context::Scope lock(context); 6742 Context::Scope lock(context);
6743 v8::Handle<Value> result = CompileRun("Ret54321()"); 6743 v8::Handle<Value> result = CompileRun("Ret54321()");
(...skipping 3557 matching lines...) Expand 10 before | Expand all | Expand 10 after
10301 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2)); 10301 t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2));
10302 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate); 10302 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
10303 t3->SetHiddenPrototype(true); 10303 t3->SetHiddenPrototype(true);
10304 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3)); 10304 t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3));
10305 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate); 10305 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(isolate);
10306 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4)); 10306 t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4));
10307 10307
10308 // Force dictionary-based properties. 10308 // Force dictionary-based properties.
10309 i::ScopedVector<char> name_buf(1024); 10309 i::ScopedVector<char> name_buf(1024);
10310 for (int i = 1; i <= 1000; i++) { 10310 for (int i = 1; i <= 1000; i++) {
10311 i::OS::SNPrintF(name_buf, "sdf%d", i); 10311 i::SNPrintF(name_buf, "sdf%d", i);
10312 t2->InstanceTemplate()->Set(v8_str(name_buf.start()), v8_num(2)); 10312 t2->InstanceTemplate()->Set(v8_str(name_buf.start()), v8_num(2));
10313 } 10313 }
10314 10314
10315 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); 10315 Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
10316 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); 10316 Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
10317 Local<v8::Object> o3 = t3->GetFunction()->NewInstance(); 10317 Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
10318 Local<v8::Object> o4 = t4->GetFunction()->NewInstance(); 10318 Local<v8::Object> o4 = t4->GetFunction()->NewInstance();
10319 10319
10320 // Create prototype chain of hidden prototypes. 10320 // Create prototype chain of hidden prototypes.
10321 CHECK(o4->SetPrototype(o3)); 10321 CHECK(o4->SetPrototype(o3));
(...skipping 5987 matching lines...) Expand 10 before | Expand all | Expand 10 after
16309 // The repeated loads and stores ensure the ICs are exercised. 16309 // The repeated loads and stores ensure the ICs are exercised.
16310 const char* boundary_program = 16310 const char* boundary_program =
16311 "var res = 0;" 16311 "var res = 0;"
16312 "for (var i = 0; i < 16; i++) {" 16312 "for (var i = 0; i < 16; i++) {"
16313 " ext_array[i] = %lld;" 16313 " ext_array[i] = %lld;"
16314 " if (i > 8) {" 16314 " if (i > 8) {"
16315 " res = ext_array[i];" 16315 " res = ext_array[i];"
16316 " }" 16316 " }"
16317 "}" 16317 "}"
16318 "res;"; 16318 "res;";
16319 i::OS::SNPrintF(test_buf, 16319 i::SNPrintF(test_buf,
16320 boundary_program, 16320 boundary_program,
16321 low); 16321 low);
16322 result = CompileRun(test_buf.start()); 16322 result = CompileRun(test_buf.start());
16323 CHECK_EQ(low, result->IntegerValue()); 16323 CHECK_EQ(low, result->IntegerValue());
16324 16324
16325 i::OS::SNPrintF(test_buf, 16325 i::SNPrintF(test_buf,
16326 boundary_program, 16326 boundary_program,
16327 high); 16327 high);
16328 result = CompileRun(test_buf.start()); 16328 result = CompileRun(test_buf.start());
16329 CHECK_EQ(high, result->IntegerValue()); 16329 CHECK_EQ(high, result->IntegerValue());
16330 16330
16331 // Check misprediction of type in IC. 16331 // Check misprediction of type in IC.
16332 result = CompileRun("var tmp_array = ext_array;" 16332 result = CompileRun("var tmp_array = ext_array;"
16333 "var sum = 0;" 16333 "var sum = 0;"
16334 "for (var i = 0; i < 8; i++) {" 16334 "for (var i = 0; i < 8; i++) {"
16335 " tmp_array[i] = i;" 16335 " tmp_array[i] = i;"
16336 " sum += tmp_array[i];" 16336 " sum += tmp_array[i];"
16337 " if (i == 4) {" 16337 " if (i == 4) {"
16338 " tmp_array = {};" 16338 " tmp_array = {};"
16339 " }" 16339 " }"
16340 "}" 16340 "}"
16341 "sum;"); 16341 "sum;");
16342 // Force GC to trigger verification. 16342 // Force GC to trigger verification.
16343 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 16343 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
16344 CHECK_EQ(28, result->Int32Value()); 16344 CHECK_EQ(28, result->Int32Value());
16345 16345
16346 // Make sure out-of-range loads do not throw. 16346 // Make sure out-of-range loads do not throw.
16347 i::OS::SNPrintF(test_buf, 16347 i::SNPrintF(test_buf,
16348 "var caught_exception = false;" 16348 "var caught_exception = false;"
16349 "try {" 16349 "try {"
16350 " ext_array[%d];" 16350 " ext_array[%d];"
16351 "} catch (e) {" 16351 "} catch (e) {"
16352 " caught_exception = true;" 16352 " caught_exception = true;"
16353 "}" 16353 "}"
16354 "caught_exception;", 16354 "caught_exception;",
16355 element_count); 16355 element_count);
16356 result = CompileRun(test_buf.start()); 16356 result = CompileRun(test_buf.start());
16357 CHECK_EQ(false, result->BooleanValue()); 16357 CHECK_EQ(false, result->BooleanValue());
16358 16358
16359 // Make sure out-of-range stores do not throw. 16359 // Make sure out-of-range stores do not throw.
16360 i::OS::SNPrintF(test_buf, 16360 i::SNPrintF(test_buf,
16361 "var caught_exception = false;" 16361 "var caught_exception = false;"
16362 "try {" 16362 "try {"
16363 " ext_array[%d] = 1;" 16363 " ext_array[%d] = 1;"
16364 "} catch (e) {" 16364 "} catch (e) {"
16365 " caught_exception = true;" 16365 " caught_exception = true;"
16366 "}" 16366 "}"
16367 "caught_exception;", 16367 "caught_exception;",
16368 element_count); 16368 element_count);
16369 result = CompileRun(test_buf.start()); 16369 result = CompileRun(test_buf.start());
16370 CHECK_EQ(false, result->BooleanValue()); 16370 CHECK_EQ(false, result->BooleanValue());
16371 16371
16372 // Check other boundary conditions, values and operations. 16372 // Check other boundary conditions, values and operations.
16373 result = CompileRun("for (var i = 0; i < 8; i++) {" 16373 result = CompileRun("for (var i = 0; i < 8; i++) {"
16374 " ext_array[7] = undefined;" 16374 " ext_array[7] = undefined;"
16375 "}" 16375 "}"
16376 "ext_array[7];"); 16376 "ext_array[7];");
16377 CHECK_EQ(0, result->Int32Value()); 16377 CHECK_EQ(0, result->Int32Value());
16378 if (array_type == v8::kExternalFloat64Array || 16378 if (array_type == v8::kExternalFloat64Array ||
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
16440 "var expected_results = [0, 10, 0, -10];"; 16440 "var expected_results = [0, 10, 0, -10];";
16441 const char* pixel_data = 16441 const char* pixel_data =
16442 "var source_data = [0.6, 10.6];" 16442 "var source_data = [0.6, 10.6];"
16443 "var expected_results = [1, 11];"; 16443 "var expected_results = [1, 11];";
16444 bool is_unsigned = 16444 bool is_unsigned =
16445 (array_type == v8::kExternalUint8Array || 16445 (array_type == v8::kExternalUint8Array ||
16446 array_type == v8::kExternalUint16Array || 16446 array_type == v8::kExternalUint16Array ||
16447 array_type == v8::kExternalUint32Array); 16447 array_type == v8::kExternalUint32Array);
16448 bool is_pixel_data = array_type == v8::kExternalUint8ClampedArray; 16448 bool is_pixel_data = array_type == v8::kExternalUint8ClampedArray;
16449 16449
16450 i::OS::SNPrintF(test_buf, 16450 i::SNPrintF(test_buf,
16451 "%s" 16451 "%s"
16452 "var all_passed = true;" 16452 "var all_passed = true;"
16453 "for (var i = 0; i < source_data.length; i++) {" 16453 "for (var i = 0; i < source_data.length; i++) {"
16454 " for (var j = 0; j < 8; j++) {" 16454 " for (var j = 0; j < 8; j++) {"
16455 " ext_array[j] = source_data[i];" 16455 " ext_array[j] = source_data[i];"
16456 " }" 16456 " }"
16457 " all_passed = all_passed &&" 16457 " all_passed = all_passed &&"
16458 " (ext_array[5] == expected_results[i]);" 16458 " (ext_array[5] == expected_results[i]);"
16459 "}" 16459 "}"
16460 "all_passed;", 16460 "all_passed;",
16461 (is_unsigned ? 16461 (is_unsigned ?
16462 unsigned_data : 16462 unsigned_data :
16463 (is_pixel_data ? pixel_data : signed_data))); 16463 (is_pixel_data ? pixel_data : signed_data)));
16464 result = CompileRun(test_buf.start()); 16464 result = CompileRun(test_buf.start());
16465 CHECK_EQ(true, result->BooleanValue()); 16465 CHECK_EQ(true, result->BooleanValue());
16466 } 16466 }
16467 16467
16468 i::Handle<ExternalArrayClass> array( 16468 i::Handle<ExternalArrayClass> array(
16469 ExternalArrayClass::cast(jsobj->elements())); 16469 ExternalArrayClass::cast(jsobj->elements()));
16470 for (int i = 0; i < element_count; i++) { 16470 for (int i = 0; i < element_count; i++) {
16471 array->set(i, static_cast<ElementType>(i)); 16471 array->set(i, static_cast<ElementType>(i));
16472 } 16472 }
16473 16473
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
17534 "}\n" 17534 "}\n"
17535 "function foo() {\n" 17535 "function foo() {\n"
17536 "\n" 17536 "\n"
17537 " bar();\n" 17537 " bar();\n"
17538 "}\n" 17538 "}\n"
17539 "foo();\n" 17539 "foo();\n"
17540 "}\n" 17540 "}\n"
17541 "eval('(' + outer +')()%s');"; 17541 "eval('(' + outer +')()%s');";
17542 17542
17543 i::ScopedVector<char> code(1024); 17543 i::ScopedVector<char> code(1024);
17544 i::OS::SNPrintF(code, source, "//# sourceURL=eval_url"); 17544 i::SNPrintF(code, source, "//# sourceURL=eval_url");
17545 CHECK(CompileRun(code.start())->IsUndefined()); 17545 CHECK(CompileRun(code.start())->IsUndefined());
17546 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); 17546 i::SNPrintF(code, source, "//@ sourceURL=eval_url");
17547 CHECK(CompileRun(code.start())->IsUndefined()); 17547 CHECK(CompileRun(code.start())->IsUndefined());
17548 } 17548 }
17549 17549
17550 17550
17551 static int scriptIdInStack[2]; 17551 static int scriptIdInStack[2];
17552 17552
17553 void AnalyzeScriptIdInStack( 17553 void AnalyzeScriptIdInStack(
17554 const v8::FunctionCallbackInfo<v8::Value>& args) { 17554 const v8::FunctionCallbackInfo<v8::Value>& args) {
17555 v8::HandleScope scope(args.GetIsolate()); 17555 v8::HandleScope scope(args.GetIsolate());
17556 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( 17556 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
17617 "}\n" 17617 "}\n"
17618 "function foo() {\n" 17618 "function foo() {\n"
17619 "\n" 17619 "\n"
17620 " bar();\n" 17620 " bar();\n"
17621 "}\n" 17621 "}\n"
17622 "foo();\n" 17622 "foo();\n"
17623 "}\n" 17623 "}\n"
17624 "outer()\n%s"; 17624 "outer()\n%s";
17625 17625
17626 i::ScopedVector<char> code(1024); 17626 i::ScopedVector<char> code(1024);
17627 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); 17627 i::SNPrintF(code, source, "//# sourceURL=source_url");
17628 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); 17628 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
17629 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); 17629 i::SNPrintF(code, source, "//@ sourceURL=source_url");
17630 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined()); 17630 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
17631 } 17631 }
17632 17632
17633 17633
17634 void AnalyzeStackOfDynamicScriptWithSourceURL( 17634 void AnalyzeStackOfDynamicScriptWithSourceURL(
17635 const v8::FunctionCallbackInfo<v8::Value>& args) { 17635 const v8::FunctionCallbackInfo<v8::Value>& args) {
17636 v8::HandleScope scope(args.GetIsolate()); 17636 v8::HandleScope scope(args.GetIsolate());
17637 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( 17637 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
17638 args.GetIsolate(), 10, v8::StackTrace::kDetailed); 17638 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
17639 CHECK_EQ(4, stackTrace->GetFrameCount()); 17639 CHECK_EQ(4, stackTrace->GetFrameCount());
(...skipping 23 matching lines...) Expand all
17663 "}\n" 17663 "}\n"
17664 "function foo() {\n" 17664 "function foo() {\n"
17665 "\n" 17665 "\n"
17666 " bar();\n" 17666 " bar();\n"
17667 "}\n" 17667 "}\n"
17668 "foo();\n" 17668 "foo();\n"
17669 "}\n" 17669 "}\n"
17670 "outer()\n%s"; 17670 "outer()\n%s";
17671 17671
17672 i::ScopedVector<char> code(1024); 17672 i::ScopedVector<char> code(1024);
17673 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); 17673 i::SNPrintF(code, source, "//# sourceURL=source_url");
17674 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); 17674 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
17675 i::OS::SNPrintF(code, source, "//@ sourceURL=source_url"); 17675 i::SNPrintF(code, source, "//@ sourceURL=source_url");
17676 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined()); 17676 CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
17677 } 17677 }
17678 17678
17679 17679
17680 TEST(DynamicWithSourceURLInStackTraceString) { 17680 TEST(DynamicWithSourceURLInStackTraceString) {
17681 LocalContext context; 17681 LocalContext context;
17682 v8::HandleScope scope(context->GetIsolate()); 17682 v8::HandleScope scope(context->GetIsolate());
17683 17683
17684 const char *source = 17684 const char *source =
17685 "function outer() {\n" 17685 "function outer() {\n"
17686 " function foo() {\n" 17686 " function foo() {\n"
17687 " FAIL.FAIL;\n" 17687 " FAIL.FAIL;\n"
17688 " }\n" 17688 " }\n"
17689 " foo();\n" 17689 " foo();\n"
17690 "}\n" 17690 "}\n"
17691 "outer()\n%s"; 17691 "outer()\n%s";
17692 17692
17693 i::ScopedVector<char> code(1024); 17693 i::ScopedVector<char> code(1024);
17694 i::OS::SNPrintF(code, source, "//# sourceURL=source_url"); 17694 i::SNPrintF(code, source, "//# sourceURL=source_url");
17695 v8::TryCatch try_catch; 17695 v8::TryCatch try_catch;
17696 CompileRunWithOrigin(code.start(), "", 0, 0); 17696 CompileRunWithOrigin(code.start(), "", 0, 0);
17697 CHECK(try_catch.HasCaught()); 17697 CHECK(try_catch.HasCaught());
17698 v8::String::Utf8Value stack(try_catch.StackTrace()); 17698 v8::String::Utf8Value stack(try_catch.StackTrace());
17699 CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL); 17699 CHECK(strstr(*stack, "at foo (source_url:3:5)") != NULL);
17700 } 17700 }
17701 17701
17702 17702
17703 static void CreateGarbageInOldSpace() { 17703 static void CreateGarbageInOldSpace() {
17704 i::Factory* factory = CcTest::i_isolate()->factory(); 17704 i::Factory* factory = CcTest::i_isolate()->factory();
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
19422 ExpectTrue("function f() { return isDefaultIsolate; }; f()"); 19422 ExpectTrue("function f() { return isDefaultIsolate; }; f()");
19423 } 19423 }
19424 } 19424 }
19425 19425
19426 19426
19427 static int CalcFibonacci(v8::Isolate* isolate, int limit) { 19427 static int CalcFibonacci(v8::Isolate* isolate, int limit) {
19428 v8::Isolate::Scope isolate_scope(isolate); 19428 v8::Isolate::Scope isolate_scope(isolate);
19429 v8::HandleScope scope(isolate); 19429 v8::HandleScope scope(isolate);
19430 LocalContext context(isolate); 19430 LocalContext context(isolate);
19431 i::ScopedVector<char> code(1024); 19431 i::ScopedVector<char> code(1024);
19432 i::OS::SNPrintF(code, "function fib(n) {" 19432 i::SNPrintF(code, "function fib(n) {"
19433 " if (n <= 2) return 1;" 19433 " if (n <= 2) return 1;"
19434 " return fib(n-1) + fib(n-2);" 19434 " return fib(n-1) + fib(n-2);"
19435 "}" 19435 "}"
19436 "fib(%d)", limit); 19436 "fib(%d)", limit);
19437 Local<Value> value = CompileRun(code.start()); 19437 Local<Value> value = CompileRun(code.start());
19438 CHECK(value->IsNumber()); 19438 CHECK(value->IsNumber());
19439 return static_cast<int>(value->NumberValue()); 19439 return static_cast<int>(value->NumberValue());
19440 } 19440 }
19441 19441
19442 class IsolateThread : public v8::internal::Thread { 19442 class IsolateThread : public v8::internal::Thread {
19443 public: 19443 public:
19444 IsolateThread(v8::Isolate* isolate, int fib_limit) 19444 IsolateThread(v8::Isolate* isolate, int fib_limit)
19445 : Thread("IsolateThread"), 19445 : Thread("IsolateThread"),
19446 isolate_(isolate), 19446 isolate_(isolate),
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
20633 } 20633 }
20634 20634
20635 20635
20636 void RecursiveCall(const v8::FunctionCallbackInfo<v8::Value>& args) { 20636 void RecursiveCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
20637 int32_t level = args[0]->Int32Value(); 20637 int32_t level = args[0]->Int32Value();
20638 if (level < 3) { 20638 if (level < 3) {
20639 level++; 20639 level++;
20640 i::OS::Print("Entering recursion level %d.\n", level); 20640 i::OS::Print("Entering recursion level %d.\n", level);
20641 char script[64]; 20641 char script[64];
20642 i::Vector<char> script_vector(script, sizeof(script)); 20642 i::Vector<char> script_vector(script, sizeof(script));
20643 i::OS::SNPrintF(script_vector, "recursion(%d)", level); 20643 i::SNPrintF(script_vector, "recursion(%d)", level);
20644 CompileRun(script_vector.start()); 20644 CompileRun(script_vector.start());
20645 i::OS::Print("Leaving recursion level %d.\n", level); 20645 i::OS::Print("Leaving recursion level %d.\n", level);
20646 CHECK_EQ(0, callback_fired); 20646 CHECK_EQ(0, callback_fired);
20647 } else { 20647 } else {
20648 i::OS::Print("Recursion ends.\n"); 20648 i::OS::Print("Recursion ends.\n");
20649 CHECK_EQ(0, callback_fired); 20649 CHECK_EQ(0, callback_fired);
20650 } 20650 }
20651 } 20651 }
20652 20652
20653 20653
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
21699 } 21699 }
21700 21700
21701 21701
21702 void CheckCorrectThrow(const char* script) { 21702 void CheckCorrectThrow(const char* script) {
21703 // Test that the script, when wrapped into a try-catch, triggers the catch 21703 // Test that the script, when wrapped into a try-catch, triggers the catch
21704 // clause due to failed access check throwing an exception. 21704 // clause due to failed access check throwing an exception.
21705 // The subsequent try-catch should run without any exception. 21705 // The subsequent try-catch should run without any exception.
21706 access_check_fail_thrown = false; 21706 access_check_fail_thrown = false;
21707 catch_callback_called = false; 21707 catch_callback_called = false;
21708 i::ScopedVector<char> source(1024); 21708 i::ScopedVector<char> source(1024);
21709 i::OS::SNPrintF(source, "try { %s; } catch (e) { catcher(e); }", script); 21709 i::SNPrintF(source, "try { %s; } catch (e) { catcher(e); }", script);
21710 CompileRun(source.start()); 21710 CompileRun(source.start());
21711 CHECK(access_check_fail_thrown); 21711 CHECK(access_check_fail_thrown);
21712 CHECK(catch_callback_called); 21712 CHECK(catch_callback_called);
21713 21713
21714 access_check_fail_thrown = false; 21714 access_check_fail_thrown = false;
21715 catch_callback_called = false; 21715 catch_callback_called = false;
21716 CompileRun("try { [1, 2, 3].sort(); } catch (e) { catcher(e) };"); 21716 CompileRun("try { [1, 2, 3].sort(); } catch (e) { catcher(e) };");
21717 CHECK(!access_check_fail_thrown); 21717 CHECK(!access_check_fail_thrown);
21718 CHECK(!catch_callback_called); 21718 CHECK(!catch_callback_called);
21719 } 21719 }
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
22413 receiver = Local<Object>::Cast(CompileRun( 22413 receiver = Local<Object>::Cast(CompileRun(
22414 "var receiver_subclass = function_receiver;\n" 22414 "var receiver_subclass = function_receiver;\n"
22415 "receiver_subclass")); 22415 "receiver_subclass"));
22416 } 22416 }
22417 } 22417 }
22418 // With no signature, the holder is not set. 22418 // With no signature, the holder is not set.
22419 if (signature_type == kNoSignature) holder = receiver; 22419 if (signature_type == kNoSignature) holder = receiver;
22420 // build wrap_function 22420 // build wrap_function
22421 i::ScopedVector<char> wrap_function(200); 22421 i::ScopedVector<char> wrap_function(200);
22422 if (global) { 22422 if (global) {
22423 i::OS::SNPrintF( 22423 i::SNPrintF(
22424 wrap_function, 22424 wrap_function,
22425 "function wrap_f_%d() { var f = g_f; return f(); }\n" 22425 "function wrap_f_%d() { var f = g_f; return f(); }\n"
22426 "function wrap_get_%d() { return this.g_acc; }\n" 22426 "function wrap_get_%d() { return this.g_acc; }\n"
22427 "function wrap_set_%d() { return this.g_acc = 1; }\n", 22427 "function wrap_set_%d() { return this.g_acc = 1; }\n",
22428 key, key, key); 22428 key, key, key);
22429 } else { 22429 } else {
22430 i::OS::SNPrintF( 22430 i::SNPrintF(
22431 wrap_function, 22431 wrap_function,
22432 "function wrap_f_%d() { return receiver_subclass.f(); }\n" 22432 "function wrap_f_%d() { return receiver_subclass.f(); }\n"
22433 "function wrap_get_%d() { return receiver_subclass.acc; }\n" 22433 "function wrap_get_%d() { return receiver_subclass.acc; }\n"
22434 "function wrap_set_%d() { return receiver_subclass.acc = 1; }\n", 22434 "function wrap_set_%d() { return receiver_subclass.acc = 1; }\n",
22435 key, key, key); 22435 key, key, key);
22436 } 22436 }
22437 // build source string 22437 // build source string
22438 i::ScopedVector<char> source(1000); 22438 i::ScopedVector<char> source(1000);
22439 i::OS::SNPrintF( 22439 i::SNPrintF(
22440 source, 22440 source,
22441 "%s\n" // wrap functions 22441 "%s\n" // wrap functions
22442 "function wrap_f() { return wrap_f_%d(); }\n" 22442 "function wrap_f() { return wrap_f_%d(); }\n"
22443 "function wrap_get() { return wrap_get_%d(); }\n" 22443 "function wrap_get() { return wrap_get_%d(); }\n"
22444 "function wrap_set() { return wrap_set_%d(); }\n" 22444 "function wrap_set() { return wrap_set_%d(); }\n"
22445 "check = function(returned) {\n" 22445 "check = function(returned) {\n"
22446 " if (returned !== 'returned') { throw returned; }\n" 22446 " if (returned !== 'returned') { throw returned; }\n"
22447 "}\n" 22447 "}\n"
22448 "\n" 22448 "\n"
22449 "check(wrap_f());\n" 22449 "check(wrap_f());\n"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
22799 call_eval_context = v8::Context::New(isolate); 22799 call_eval_context = v8::Context::New(isolate);
22800 v8::Context::Scope scope(call_eval_context); 22800 v8::Context::Scope scope(call_eval_context);
22801 call_eval_bound_function = 22801 call_eval_bound_function =
22802 Local<Function>::Cast(CompileRun("eval.bind(this, '1')")); 22802 Local<Function>::Cast(CompileRun("eval.bind(this, '1')"));
22803 } 22803 }
22804 env->Global()->Set(v8_str("CallEval"), 22804 env->Global()->Set(v8_str("CallEval"),
22805 v8::FunctionTemplate::New(isolate, CallEval)->GetFunction()); 22805 v8::FunctionTemplate::New(isolate, CallEval)->GetFunction());
22806 Local<Value> result = CompileRun("CallEval();"); 22806 Local<Value> result = CompileRun("CallEval();");
22807 CHECK_EQ(result, v8::Integer::New(isolate, 1)); 22807 CHECK_EQ(result, v8::Integer::New(isolate, 1));
22808 } 22808 }
OLDNEW
« no previous file with comments | « src/x87/disasm-x87.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698